kosmos/Makefile

84 lines
2.5 KiB
Makefile
Raw Normal View History

2016-08-16 12:28:08 +00:00
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
MAIN_FILE = $(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)
MAP_FILE = $(MAP_DIR)/$(TEST_APP)$(MAP_EXT)
2016-08-15 14:11:00 +00:00
2016-08-16 12:28:08 +00:00
#include subfolders
2016-07-29 06:37:13 +00:00
include source/firmware/firmware.mk
2016-08-16 12:28:08 +00:00
ifdef TEST_APP
include source/test/test.mk
C_FLAGS += -DTEST_APP
endif
2016-08-15 14:11:00 +00:00
C_SOURCES := $(foreach folder, $(SRC_DIR), $(wildcard $(folder)/*.c))
C_OBJECTS := $(C_SOURCES:%.c=$(OBJ_DIR)/%.o)
2016-08-16 12:28:08 +00:00
C_DEPS := $(SOURCES:%.c=$(OBJ_DIR)/%.d)
all: $(MAIN_FILE)
deploy: all
@$(MKDIR) $(EXE_DIR)/include
$(ROOT_DIR)/source/scripts/board_interface.py -b "$(ROOT_DIR)/source/firmware/arch/$(CPU)/board/$(BOARD)/include/$(BOARD).h" -o "$(EXE_DIR)/include/board_devices.h"
$(ROOT_DIR)/source/scripts/stack_interface.py -i "$(ROOT_DIR)/source/firmware/arch/$(CPU)/include/$(CPU)_stack.h" -o "$(EXE_DIR)/include/stack.h"
cp $(ROOT_DIR)/source/firmware/kernel/interface/*.* $(EXE_DIR)/include/
tar cvJf $(DEPLOY_PACKET) -C $(EXE_DIR) .
$(MAIN_FILE): $(C_OBJECTS)
@$(MKDIR) $(EXE_DIR)
$(AR) $(AR_FLAGS) $(MAIN_FILE) $(C_OBJECTS)
2016-08-15 14:11:00 +00:00
$(OBJ_DIR)/%.o: %.c
@mkdir -p $(OBJ_DIR)
@$(foreach folder, $(SRC_DIR), $(shell mkdir -p $(OBJ_DIR)/$(folder)))
2016-08-16 12:28:08 +00:00
$(call makedep,$<,$@,$(subst .o,.d,$@),$(GEN_FLAGS) $(C_FLAGS))
$(CC) $(GEN_FLAGS) $(C_FLAGS) -c -o "$@" "$<"
test: $(C_OBJECTS)
@$(MKDIR) $(EXE_DIR)
@$(MKDIR) $(MAP_DIR)
@$(MKDIR) $(SIZE_DIR)
$(CXX) $(GEN_FLAGS) $(L_FLAGS) -Wl,-Map,"$(MAP_FILE)" -o "$(TEST_FILE)" $(C_OBJECTS)
$(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
2016-07-28 19:02:54 +00:00
clean:
2016-08-15 14:11:00 +00:00
$(foreach folder, $(SRC_DIR), $(shell rm -f $(OBJ_DIR)/$(folder)/*.o))
$(foreach folder, $(SRC_DIR), $(shell rm -f $(OBJ_DIR)/$(folder)/*.d))
2016-07-28 19:02:54 +00:00
-rm -f $(OBJ_DIR)/*.o \
$(OBJ_DIR)/*.d \
2016-08-15 14:11:00 +00:00
$(MAIN_FILE) \
$(BIN_FILE)
2016-08-02 12:10:11 +00:00
2016-08-16 12:28:08 +00:00
distclean:
-rm -rf $(ROOT_DIR)/release
2016-08-15 14:11:00 +00:00
install: all
2016-08-16 12:28:08 +00:00
$(PRE_PROGRAM)
$(PROGRAM)
ifneq "$(MAKECMDGOALS)" "clean"
-include $(C_DEPS)
else
ifneq "$(MAKECMDGOALS)" "distclean"
-include $(C_DEPS)
endif
endif