2016-07-29 06:37:13 +00:00
|
|
|
include config/make/rules.mk
|
2016-07-28 19:02:54 +00:00
|
|
|
|
|
|
|
OS_NAME = kosmos
|
|
|
|
|
2016-08-01 12:05:39 +00:00
|
|
|
# version numbering deployed by ci deploy script - no necessary for local build
|
2016-08-01 12:12:17 +00:00
|
|
|
ifdef SW_KERNEL
|
2016-08-01 12:57:32 +00:00
|
|
|
VERSION := -$(SW_KERNEL).$(SW_MAJOR).$(SW_MINOR)
|
2016-08-01 12:05:39 +00:00
|
|
|
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
|
2016-07-28 19:02:54 +00:00
|
|
|
|
2016-08-02 12:10:11 +00:00
|
|
|
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)
|
|
|
|
|
2016-07-28 19:02:54 +00:00
|
|
|
INCLUDES += $(SRC_DIR)
|
|
|
|
|
|
|
|
SUB_FOLDER :=
|
|
|
|
CHECK_FOLDER :=
|
|
|
|
SOURCES := $(wildcard $(SRC_DIR)/*.c)
|
|
|
|
ASM_SOURCES := $(wildcard $(SRC_DIR)/*.s)
|
|
|
|
|
2016-07-29 06:37:13 +00:00
|
|
|
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)
|
2016-07-28 19:02:54 +00:00
|
|
|
|
|
|
|
#include subfolders
|
2016-07-29 06:37:13 +00:00
|
|
|
include source/firmware/firmware.mk
|
2016-08-02 12:10:11 +00:00
|
|
|
ifdef TEST_APP
|
|
|
|
include source/test/test.mk
|
|
|
|
CFLAGS += -DTEST_APP
|
|
|
|
endif
|
2016-07-28 19:02:54 +00:00
|
|
|
|
2016-07-29 06:37:13 +00:00
|
|
|
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))
|
2016-07-28 19:02:54 +00:00
|
|
|
|
|
|
|
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/
|
2016-08-01 12:05:39 +00:00
|
|
|
tar cvJf $(DEPLOY_PACKET) -C $(EXE_DIR) .
|
2016-07-28 19:02:54 +00:00
|
|
|
|
|
|
|
check:
|
|
|
|
$(CPPCHECK) $(CPPCHECK_FLAGS) $(CHECKSOURCES)
|
|
|
|
|
|
|
|
|
|
|
|
$(MAINFILE): $(OBJECTS) $(ASM_OBJECTS)
|
|
|
|
@$(MKDIR) $(EXE_DIR)
|
|
|
|
$(AR) rcs $(MAINFILE) $(OBJECTS) $(ASM_OBJECTS)
|
|
|
|
|
2016-07-29 06:37:13 +00:00
|
|
|
$(OBJ_DIR)/%.o: $(ROOT_DIR)/%.c
|
2016-07-28 19:02:54 +00:00
|
|
|
@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 $@
|
|
|
|
|
2016-07-29 06:37:13 +00:00
|
|
|
$(OBJ_DIR)/%.o: $(ROOT_DIR)/%.s
|
2016-07-28 19:02:54 +00:00
|
|
|
@$(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 \
|
2016-07-29 06:37:13 +00:00
|
|
|
$(EXE_DIR)/include/* \
|
2016-07-28 19:02:54 +00:00
|
|
|
$(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 -
|
|
|
|
|
2016-08-08 09:19:08 +00:00
|
|
|
test: $(OBJECTS) $(ASM_OBJECTS)
|
2016-08-02 12:10:11 +00:00
|
|
|
@$(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)
|
|
|
|
|
2016-07-28 19:02:54 +00:00
|
|
|
ifneq "$(MAKECMDGOALS)" "clean"
|
|
|
|
-include $(DEPS)
|
|
|
|
else
|
|
|
|
ifneq "$(MAKECMDGOALS)" "distclean"
|
|
|
|
-include $(DEPS)
|
|
|
|
endif
|
|
|
|
endif
|