MD-Bench/Makefile

92 lines
2.4 KiB
Makefile
Raw Normal View History

#CONFIGURE BUILD SYSTEM
2024-05-15 14:20:40 +02:00
TAG = $(OPT_TAG)-$(TOOLCHAIN)-$(DATA_TYPE)
TARGET = MDBench-$(TAG)
BUILD_DIR = ./build/build-$(TAG)
SRC_ROOT = ./src
SRC_DIR = $(SRC_ROOT)/$(OPT_SCHEME)
COMMON_DIR = $(SRC_ROOT)/common
CUDA_DIR = $(SRC_DIR)/cuda
MAKE_DIR = ./make
Q ?= @
#DO NOT EDIT BELOW
2024-05-15 14:20:40 +02:00
include config.mk
include $(MAKE_DIR)/include_$(TOOLCHAIN).mk
include $(MAKE_DIR)/include_LIKWID.mk
2024-05-15 14:20:40 +02:00
ifneq ($(strip $(ISA)),NONE)
include $(MAKE_DIR)/include_ISA.mk
endif
2024-05-15 14:20:40 +02:00
INCLUDES += -I./$(SRC_DIR) -I./$(COMMON_DIR)
2024-05-15 14:20:40 +02:00
VPATH = $(SRC_DIR) $(COMMON_DIR) $(CUDA_DIR)
ASM = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.s,$(wildcard $(SRC_DIR)/*.c))
2024-05-15 15:30:11 +02:00
OBJ = $(filter-out $(BUILD_DIR)/main%, $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o,$(wildcard $(SRC_DIR)/*.c)))
2024-05-15 14:20:40 +02:00
OBJ += $(patsubst $(COMMON_DIR)/%.c, $(BUILD_DIR)/%.o,$(wildcard $(COMMON_DIR)/*.c))
ifeq ($(strip $(TAG)),NVCC)
OBJ += $(patsubst $(CUDA_DIR)/%.cu, $(BUILD_DIR)/%-cuda.o,$(wildcard $(CUDA_DIR)/*.cu))
endif
2021-03-24 08:43:44 +01:00
CPPFLAGS := $(CPPFLAGS) $(DEFINES) $(OPTIONS) $(INCLUDES)
ifneq ($(VARIANT),)
.DEFAULT_GOAL := ${TARGET}-$(VARIANT)
DEFINES += -DVARIANT=$(VARIANT)
endif
${TARGET}: $(BUILD_DIR) $(OBJ) $(SRC_DIR)/main.c
@echo "===> LINKING $(TARGET)"
$(Q)${LINKER} $(CPPFLAGS) ${LFLAGS} -o $(TARGET) $(SRC_DIR)/main.c $(OBJ) $(LIBS)
${TARGET}-%: $(BUILD_DIR) $(OBJ) $(SRC_DIR)/main-%.c
@echo "===> LINKING $(TARGET)-$* "
$(Q)${LINKER} $(CPPFLAGS) ${LFLAGS} -o $(TARGET)-$* $(SRC_DIR)/main-$*.c $(OBJ) $(LIBS)
$(BUILD_DIR)/%.o: %.c
$(info ===> COMPILE $@)
$(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(Q)$(CC) $(CPPFLAGS) -MT $@ -MM $< > $(BUILD_DIR)/$*.d
$(BUILD_DIR)/%-cuda.o: %.cu
$(info ===> COMPILE $@)
$(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(Q)$(CC) $(CPPFLAGS) -MT $@ -MM $< > $(BUILD_DIR)/$*.d
$(BUILD_DIR)/%.s: %.c
$(info ===> GENERATE ASM $@)
$(Q)$(CC) -S $(ASFLAGS) $(CPPFLAGS) $(CFLAGS) $< -o $@
$(BUILD_DIR)/%.o: %.s
$(info ===> ASSEMBLE $@)
$(Q)$(AS) $< -o $@
.PHONY: clean distclean tags info asm
clean:
$(info ===> CLEAN)
@rm -rf $(BUILD_DIR)
cleanall:
$(info ===> CLEAN)
2024-05-15 14:20:40 +02:00
@rm -rf build
@rm -rf MDBench-*
@rm -f tags
distclean: clean
$(info ===> DIST CLEAN)
2024-05-15 14:20:40 +02:00
@rm -f $(TARGET)
@rm -f tags
info:
$(info $(CFLAGS))
$(Q)$(CC) $(VERSION)
asm: $(BUILD_DIR) $(ASM)
tags:
$(info ===> GENERATE TAGS)
$(Q)ctags -R
$(BUILD_DIR):
2024-05-15 14:20:40 +02:00
@mkdir -p $(BUILD_DIR)
-include $(OBJ:.o=.d)