109 lines
3.1 KiB
Makefile
Executable File
109 lines
3.1 KiB
Makefile
Executable File
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
|
|
|
|
TEST_FILE = $(EXE_DIR)/$(TEST_APP)$(ELF_EXT)
|
|
BIN_FILE = $(EXE_DIR)/$(TEST_APP)$(BIN_EXT)
|
|
HEX_FILE = $(EXE_DIR)/$(TEST_APP)$(HEX_EXT)
|
|
SIZE_FILE = $(SIZE_DIR)/$(TEST_APP)$(SIZE_EXT)
|
|
|
|
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
|
|
ifdef TEST_APP
|
|
include source/test/test.mk
|
|
CFLAGS += -DTEST_APP
|
|
endif
|
|
|
|
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) .
|
|
|
|
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 -
|
|
|
|
test: $(OBJECTS) $(ASM_OBJECTS)
|
|
@$(MKDIR) $(EXE_DIR)
|
|
@$(MKDIR) $(MAP_DIR)
|
|
@$(MKDIR) $(SIZE_DIR)
|
|
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(ASM_OBJECTS) -o $(TEST_FILE)
|
|
$(OBJCOPY) $(TEST_FILE) -O binary $(BIN_FILE)
|
|
$(OBJCOPY) $(TEST_FILE) -O ihex $(HEX_FILE)
|
|
$(NM) --size-sort --print-size $(TEST_FILE) > $(SIZE_FILE)
|
|
@echo
|
|
@$(SIZE) --format=berkeley -x $(TEST_FILE)
|
|
@echo
|
|
|
|
install: test
|
|
$(PRE_PROGRAM)
|
|
$(PROGRAM)
|
|
|
|
ifneq "$(MAKECMDGOALS)" "clean"
|
|
-include $(DEPS)
|
|
else
|
|
ifneq "$(MAKECMDGOALS)" "distclean"
|
|
-include $(DEPS)
|
|
endif
|
|
endif
|