include config/make/rules.mk OS_NAME = kosmos # version numbering deployed by ci deploy script - no necessary for local build ifdef SW_KERNEL VERSION := -$(SW_KERNEL).$(SW_MAJOR).$(SW_MINOR)- else VERSION := endif MAINFILE = $(EXE_DIR)/lib$(OS_NAME)-$(ARCH)-$(BOARD)$(VERSION)$(DBG_EXT)$(LIB_EXT) DEPLOY_PACKET = lib$(OS_NAME)-$(ARCH)-$(BOARD)$(VERSION)$(DBG_EXT).tar.xz INCLUDES += $(SRC_DIR) SUB_FOLDER := CHECK_FOLDER := SOURCES := $(wildcard $(SRC_DIR)/*.c) ASM_SOURCES := $(wildcard $(SRC_DIR)/*.s) OBJECTS = $(SOURCES:$(ROOT_DIR)/%.c=$(OBJ_DIR)/%.o) ASM_OBJECTS = $(ASMSOURCES:$(ROOT_DIR)/%.s=$(OBJ_DIR)/%.o) DEPS = $(SOURCES:$(ROOT_DIR)/%.c=$(OBJ_DIR)/%.d) #include subfolders include source/firmware/firmware.mk SOURCES += $(foreach folder, $(SUB_FOLDER), $(wildcard $(ROOT_DIR)/$(folder)/*.c)) CHECKSOURCES += $(foreach folder, $(CHECK_FOLDER), $(wildcard $(ROOT_DIR)/$(folder)/*.c)) ASMSOURCES += $(foreach folder, $(SUB_FOLDER), $(wildcard $(ROOT_DIR)/$(folder)/*.s)) all: check $(MAINFILE) deploy: all @$(MKDIR) $(EXE_DIR)/include $(SRC_DIR)/scripts/board_interface.py -b "$(SRC_DIR)/firmware/arch/$(CPU)/board/$(BOARD)/include/$(BOARD).h" -o "$(EXE_DIR)/include/board_devices.h" $(SRC_DIR)/scripts/stack_interface.py -i "$(SRC_DIR)/firmware/arch/$(CPU)/include/$(CPU)_stack.h" -o "$(EXE_DIR)/include/stack.h" cp $(SRC_DIR)/firmware/kernel/interface/*.* $(EXE_DIR)/include/ tar cvJf $(DEPLOY_PACKET) -C $(EXE_DIR) . echo $(DEPLOY_PACKET) check: $(CPPCHECK) $(CPPCHECK_FLAGS) $(CHECKSOURCES) $(MAINFILE): $(OBJECTS) $(ASM_OBJECTS) @$(MKDIR) $(EXE_DIR) $(AR) rcs $(MAINFILE) $(OBJECTS) $(ASM_OBJECTS) $(OBJ_DIR)/%.o: $(ROOT_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: $(ROOT_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 \ $(EXE_DIR)/include/* \ $(OBJ_DIR)/*.d \ $(MAINFILE) distclean: -rm -rf $(ROOT_DIR)/release 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