############################################################## # ############################################################## include ../config/make/rules.mk MAINFILE = $(EXE_DIR)/$(APP)$(ELF_EXT) BINFILE = $(EXE_DIR)/$(APP)$(BIN_EXT) HEXFILE = $(EXE_DIR)/$(APP)$(HEX_EXT) SIZEFILE = $(SIZE_DIR)/$(APP)$(SIZE_EXT) INCLUDES += $(SRC_DIR) SUB_FOLDER := CHECK_FOLDER := SOURCES := $(wildcard $(SRC_DIR)/*.c) ASM_SOURCES := $(wildcard $(SRC_DIR)/*.s) OBJECTS = $(SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o) ASM_OBJECTS = $(ASMSOURCES:$(SRC_DIR)/%.s=$(OBJ_DIR)/%.o) DEPS = $(SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.d) #include subfolders include application/application.mk include firmware/firmware.mk SOURCES += $(foreach folder, $(SUB_FOLDER), $(wildcard $(SRC_DIR)/$(folder)/*.c)) CHECKSOURCES += $(foreach folder, $(CHECK_FOLDER), $(wildcard $(SRC_DIR)/$(folder)/*.c)) ASMSOURCES += $(foreach folder, $(SUB_FOLDER), $(wildcard $(SRC_DIR)/$(folder)/*.s)) all: $(MAINFILE) check: $(CPPCHECK) $(CPPCHECK_FLAGS) $(CHECKSOURCES) $(MAINFILE): $(OBJECTS) $(ASM_OBJECTS) @$(MKDIR) $(EXE_DIR) @$(MKDIR) $(MAP_DIR) @$(MKDIR) $(SIZE_DIR) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(ASM_OBJECTS) -o $(MAINFILE) $(OBJCOPY) $(MAINFILE) -O binary $(BINFILE) $(OBJCOPY) $(MAINFILE) -O ihex $(HEXFILE) $(NM) --size-sort --print-size $(MAINFILE) > $(SIZEFILE) @echo @$(SIZE) --format=berkeley -x $(MAINFILE) @echo $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c @rm -rf $(LIB) @$(MKDIR) $(OBJ_DIR) @$(foreach folder, $(SUB_FOLDER), $(shell mkdir -p $(OBJ_DIR)/$(folder))) $(call makedep,$<,$@,$(subst .o,.d,$@)) $(CC) $(CFLAGS) -c $< -o $@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.s @$(MKDIR) $(OBJ_DIR) @$(foreach folder, $(SUB_FOLDER), $(shell mkdir -p $(OBJ_DIR)/$(folder))) $(CC) $(CFLAGS) -c $< -o $@ clean: $(foreach folder, $(SUB_FOLDER), $(shell rm -f $(OBJ_DIR)/$(folder)/*.o)) $(foreach folder, $(SUB_FOLDER), $(shell rm -f $(OBJ_DIR)/$(folder)/*.d)) -rm -f $(OBJ_DIR)/*.o \ $(OBJ_DIR)/*.d \ $(MAINFILE) \ $(BINFILE) \ $(HEXFILE) \ $(SIZEFILE) distclean: -rm -rf $(ROOT_DIR)/release install: all $(PRE_PROGRAM) $(PROGRAM) doc: @$(MKDIR) $(DOC_DIR) (cat $(DOXYFILE) ; echo "INPUT=$(DOC_SRC)" ; echo "OUTPUT_DIRECTORY=$(DOC_DIR)") | doxygen - ifneq "$(MAKECMDGOALS)" "clean" -include $(DEPS) else ifneq "$(MAKECMDGOALS)" "distclean" -include $(DEPS) endif endif