CG-Bench/Makefile

79 lines
2.0 KiB
Makefile
Raw Permalink Normal View History

2025-01-03 14:23:28 +01:00
#=======================================================================================
# Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
# All rights reserved.
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file.
#=======================================================================================
#CONFIGURE BUILD SYSTEM
TARGET = exe-$(TOOLCHAIN)
BUILD_DIR = ./build/$(TOOLCHAIN)
SRC_DIR = ./src
MAKE_DIR = ./mk
Q ?= @
#DO NOT EDIT BELOW
include config.mk
include $(MAKE_DIR)/include_$(TOOLCHAIN).mk
INCLUDES += -I$(SRC_DIR)/includes -I$(BUILD_DIR)
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))
SRC = $(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/*.c)
CPPFLAGS := $(CPPFLAGS) $(DEFINES) $(OPTIONS) $(INCLUDES)
c := ,
clist = $(subst $(eval) ,$c,$(strip $1))
define CLANGD_TEMPLATE
CompileFlags:
Add: [$(call clist,$(INCLUDES)), $(call clist,$(DEFINES)), $(call clist,$(OPTIONS)), -xc]
2025-01-03 14:23:28 +01:00
Compiler: clang
endef
${TARGET}: $(BUILD_DIR) .clangd $(OBJ)
$(info ===> LINKING $(TARGET))
$(Q)${LD} ${LFLAGS} -o $(TARGET) $(OBJ) $(LIBS)
$(BUILD_DIR)/%.o: %.c $(MAKE_DIR)/include_$(TOOLCHAIN).mk
$(info ===> COMPILE $@)
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(Q)$(CC) $(CPPFLAGS) -MT $(@:.d=.o) -MM $< > $(BUILD_DIR)/$*.d
$(BUILD_DIR)/%.s: %.c
$(info ===> GENERATE ASM $@)
$(CC) -S $(CPPFLAGS) $(CFLAGS) $< -o $@
.PHONY: clean distclean info asm format
clean:
$(info ===> CLEAN)
@rm -rf $(BUILD_DIR)
distclean:
$(info ===> DIST CLEAN)
@rm -rf build
@rm -f $(TARGET)
@rm -f tags .clangd
info:
$(info $(CFLAGS))
$(Q)$(CC) $(VERSION)
asm: $(BUILD_DIR) $(ASM)
format:
@for src in $(SRC) ; do \
echo "Formatting $$src" ; \
clang-format -i $$src ; \
done
@echo "Done"
$(BUILD_DIR):
@mkdir -p $(BUILD_DIR)
.clangd:
$(file > .clangd,$(CLANGD_TEMPLATE))
-include $(OBJ:.o=.d)