2016-07-23 05:59:54 +00:00
|
|
|
##############################################################
|
|
|
|
#
|
|
|
|
##############################################################
|
|
|
|
|
|
|
|
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 :=
|
2016-07-23 09:09:27 +00:00
|
|
|
CHECK_FOLDER :=
|
2016-07-23 05:59:54 +00:00
|
|
|
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))
|
2016-07-23 09:09:27 +00:00
|
|
|
CHECKSOURCES += $(foreach folder, $(CHECK_FOLDER), $(wildcard $(SRC_DIR)/$(folder)/*.c))
|
2016-07-23 05:59:54 +00:00
|
|
|
ASMSOURCES += $(foreach folder, $(SUB_FOLDER), $(wildcard $(SRC_DIR)/$(folder)/*.s))
|
|
|
|
|
2016-07-23 09:19:32 +00:00
|
|
|
all: check $(MAINFILE)
|
2016-07-23 05:59:54 +00:00
|
|
|
|
2016-07-23 09:09:27 +00:00
|
|
|
check:
|
|
|
|
$(CPPCHECK) $(CPPCHECK_FLAGS) $(CHECKSOURCES)
|
|
|
|
|
|
|
|
|
2016-07-23 05:59:54 +00:00
|
|
|
$(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
|
|
|
|
|
2016-07-26 21:14:14 +00:00
|
|
|
install: all
|
2016-07-23 05:59:54 +00:00
|
|
|
$(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
|