78 lines
2.2 KiB
Makefile
78 lines
2.2 KiB
Makefile
|
##############################################################
|
||
|
#
|
||
|
##############################################################
|
||
|
|
||
|
include ../config/make/rules.mk
|
||
|
|
||
|
OS_NAME = kosmos
|
||
|
|
||
|
MAINFILE = $(EXE_DIR)/lib$(OS_NAME)-$(ARCH)-$(BOARD)$(DBG_EXT)$(LIB_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 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: 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/
|
||
|
|
||
|
check:
|
||
|
$(CPPCHECK) $(CPPCHECK_FLAGS) $(CHECKSOURCES)
|
||
|
|
||
|
|
||
|
$(MAINFILE): $(OBJECTS) $(ASM_OBJECTS)
|
||
|
@$(MKDIR) $(EXE_DIR)
|
||
|
$(AR) rcs $(MAINFILE) $(OBJECTS) $(ASM_OBJECTS)
|
||
|
|
||
|
$(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)
|
||
|
|
||
|
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
|