Introduce generic variant targets

Change Makefiles to allow multiple binary targets specified by VARIANT
environment variabel. For specified variants a matching main-<VARIANT>.c
source file must be present.
This commit is contained in:
Jan Eitzinger 2021-04-12 08:24:27 +02:00
parent 77a0774208
commit 35273c491b
10 changed files with 15 additions and 25 deletions

View File

@ -1,12 +1,10 @@
#CONFIGURE BUILD SYSTEM
TARGET = MDBench-$(TAG)
BUILD_DIR = ./$(TAG)
SRC_DIR = ./src/core
SRC_DIR = ./src
MAKE_DIR = ./
Q ?= @
TARGET_MDBENCH = MDBench-$(TAG)
TARGET_STUB = stub
#DO NOT EDIT BELOW
include $(MAKE_DIR)/config.mk
include $(MAKE_DIR)/include_$(TAG).mk
@ -23,31 +21,23 @@ endif
VPATH = $(SRC_DIR)
ASM = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.s,$(wildcard $(SRC_DIR)/*.c))
OBJ = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o,$(wildcard $(SRC_DIR)/*.c))
OBJ = $(filter-out $(BUILD_DIR)/main%,$(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o,$(wildcard $(SRC_DIR)/*.c)))
CPPFLAGS := $(CPPFLAGS) $(DEFINES) $(OPTIONS) $(INCLUDES)
all: ${TARGET_MDBENCH} ${TARGET_STUB}
ifneq ($(VARIANT),)
.DEFAULT_GOAL := ${TARGET}-$(VARIANT)
endif
${TARGET_MDBENCH}: $(BUILD_DIR) $(OBJ) $(BUILD_DIR)/main.o
@echo "===> LINKING $(TARGET_MDBENCH)"
$(Q)${LINKER} ${LFLAGS} -o $(TARGET_MDBENCH) $(OBJ) $(BUILD_DIR)/main.o $(LIBS)
${TARGET}: $(BUILD_DIR) $(OBJ) $(SRC_DIR)/main.c
@echo "===> LINKING $(TARGET)"
$(Q)${LINKER} $(CPPFLAGS) ${LFLAGS} -o $(TARGET) $(SRC_DIR)/main.c $(OBJ) $(LIBS)
${TARGET_STUB}: $(BUILD_DIR) $(OBJ) $(BUILD_DIR)/stub.o
@echo "===> LINKING $(TARGET_STUB)"
$(Q)${LINKER} ${LFLAGS} -o $(TARGET_STUB) $(OBJ) $(BUILD_DIR)/stub.o $(LIBS)
${TARGET}-%: $(BUILD_DIR) $(OBJ) $(SRC_DIR)/main-%.c
@echo "===> LINKING $(TARGET)-$* "
$(Q)${LINKER} $(CPPFLAGS) ${LFLAGS} -o $(TARGET)-$* $(SRC_DIR)/main-$*.c $(OBJ) $(LIBS)
asm: $(BUILD_DIR) $(ASM)
$(BUILD_DIR)/main.o: ./src/main.c
@echo "===> COMPILE $@"
$(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(Q)$(CC) $(CPPFLAGS) -MT $(@:.d=.o) -MM $< > $(BUILD_DIR)/main.d
$(BUILD_DIR)/stub.o: ./src/stub.c
@echo "===> COMPILE $@"
$(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(Q)$(CC) $(CPPFLAGS) -MT $(@:.d=.o) -MM $< > $(BUILD_DIR)/stub.d
$(BUILD_DIR)/%.o: %.c
@echo "===> COMPILE $@"
$(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@

View File

@ -39,9 +39,9 @@ void init(Parameter *param) {
}
// Show debug messages
//#define DEBUG printf
//#define DEBUG(msg) printf(msg)
// Do not show debug messages
#define DEBUG
#define DEBUG(msg)
#define ADD_ATOM(x, y, z, vx, vy, vz) atom_x(atom->Nlocal) = base_x + x * NEIGH_DISTANCE; \
atom_y(atom->Nlocal) = base_y + y * NEIGH_DISTANCE; \