engine_control/Makefile

66 lines
1.7 KiB
Makefile
Raw Normal View History

2016-07-29 07:42:06 +00:00
include config/make/rules.mk
2016-07-23 05:59:54 +00:00
2016-08-21 11:22:24 +00:00
APP ?= engine_control
2016-07-23 05:59:54 +00:00
MAINFILE = $(EXE_DIR)/$(APP)$(ELF_EXT)
BINFILE = $(EXE_DIR)/$(APP)$(BIN_EXT)
HEXFILE = $(EXE_DIR)/$(APP)$(HEX_EXT)
SIZEFILE = $(SIZE_DIR)/$(APP)$(SIZE_EXT)
2016-08-21 11:12:03 +00:00
MAP_FILE = $(MAP_DIR)/$(APP)$(MAP_EXT)
2016-07-23 05:59:54 +00:00
INCLUDES += $(SRC_DIR)
SOURCES := $(wildcard $(SRC_DIR)/*.c)
2016-07-29 07:42:06 +00:00
OBJECTS = $(SOURCES:$(ROOT_DIR)/%.c=$(OBJ_DIR)/%.o)
DEPS = $(SOURCES:$(ROOT_DIR)/%.c=$(OBJ_DIR)/%.d)
2016-07-23 05:59:54 +00:00
#include subfolders
2016-07-29 07:42:06 +00:00
include source/application/application.mk
2016-07-23 05:59:54 +00:00
2016-07-29 07:42:06 +00:00
SOURCES += $(foreach folder, $(SUB_FOLDER), $(wildcard $(ROOT_DIR)/$(folder)/*.c))
2016-07-23 05:59:54 +00:00
2016-08-21 11:12:03 +00:00
all: $(MAINFILE)
2016-07-23 09:09:27 +00:00
2016-08-21 11:12:03 +00:00
$(MAINFILE): $(OBJECTS)
2016-07-23 05:59:54 +00:00
@$(MKDIR) $(EXE_DIR)
@$(MKDIR) $(MAP_DIR)
@$(MKDIR) $(SIZE_DIR)
2016-08-21 11:12:03 +00:00
$(CXX) $(GEN_FLAGS) $(L_FLAGS) -L$(LIB_DIR) -Wl,-Map,"$(MAP_FILE)" -o "$(MAINFILE)" $(OBJECTS) $(addprefix -l, $(LIBS))
2016-07-23 05:59:54 +00:00
$(OBJCOPY) $(MAINFILE) -O binary $(BINFILE)
$(OBJCOPY) $(MAINFILE) -O ihex $(HEXFILE)
$(NM) --size-sort --print-size $(MAINFILE) > $(SIZEFILE)
@echo
@$(SIZE) --format=berkeley -x $(MAINFILE)
@echo
2016-07-29 07:42:06 +00:00
$(OBJ_DIR)/%.o: $(ROOT_DIR)/%.c
2016-07-23 05:59:54 +00:00
@$(MKDIR) $(OBJ_DIR)
@$(foreach folder, $(SUB_FOLDER), $(shell mkdir -p $(OBJ_DIR)/$(folder)))
2016-08-21 11:12:03 +00:00
$(call makedep,$<,$@,$(subst .o,.d,$@),$(GEN_FLAGS) $(C_FLAGS))
$(CC) $(GEN_FLAGS) $(C_FLAGS) -c -o "$@" "$<"
2016-07-23 05:59:54 +00:00
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
2016-07-26 21:14:14 +00:00
install: all
2016-07-23 05:59:54 +00:00
$(PRE_PROGRAM)
$(PROGRAM)
ifneq "$(MAKECMDGOALS)" "clean"
-include $(DEPS)
else
ifneq "$(MAKECMDGOALS)" "distclean"
-include $(DEPS)
endif
endif