Wirepas SDK
makefile_app.mk
Go to the documentation of this file.
1 include makefile_common.mk
2 
3 .DEFAULT_GOAL := all
4 
5 # Linker script
6 ifndef MCU_RAM_VAR
7 LDSCRIPT = $(MCU_PATH)$(MCU_FAMILY)/$(MCU)/linker/gcc_app_$(MCU)$(MCU_SUB)$(MCU_MEM_VAR).ld
8 else
9 LDSCRIPT = $(MCU_PATH)$(MCU_FAMILY)/$(MCU)/linker/gcc_app_$(MCU)$(MCU_SUB)$(MCU_MEM_VAR)_$(MCU_RAM_VAR).ld
10 endif
11 
12 LIBS :=
13 
14 ifeq ($(filter $(TARGET_BOARDS),$(target_board)),)
15  $(error Board $(target_board) is not in supported board list: ($(TARGET_BOARDS)))
16 endif
17 
18 # File to store app version
19 VERSION_FILE := $(BUILDPREFIX_APP)version.txt
20 
21 # App different formats
22 APP_ELF := $(BUILDPREFIX_APP)$(APP_NAME).elf
23 
24 # For backward compatibility as app makefile except SRCS_PATH variable
25 SRCS_PATH := $(APP_SRCS_PATH)
26 
27 # Convert default network settings to CFLAGS to be used in code
28 ifneq ($(default_network_address),)
29 CFLAGS += -DNETWORK_ADDRESS=$(default_network_address)
30 endif
31 ifneq ($(default_network_channel),)
32 CFLAGS += -DNETWORK_CHANNEL=$(default_network_channel)
33 endif
34 ifneq ($(default_network_cipher_key),)
35 CFLAGS += -DNET_CIPHER_KEY=$(default_network_cipher_key)
36 endif
37 ifneq ($(default_network_authen_key),)
38 CFLAGS += -DNET_AUTHEN_KEY=$(default_network_authen_key)
39 endif
40 # And version numbers
41 CFLAGS += -DVER_MAJOR=$(app_major) -DVER_MINOR=$(app_minor) -DVER_MAINT=$(app_maintenance) -DVER_DEV=$(app_development)
42 
43 # Mac profile
44 ifeq ("$(mac_profile)","ism_24_ghz")
45  CFLAGS += -DMAC_PROFILE_ISM24
46 endif
47 
48 # Include board init part
49 -include board/makefile
50 
51 # Include app specific makefile
52 -include $(APP_SRCS_PATH)makefile
53 
54 
55 # Include Libraries config first (dependencies)
56 -include $(WP_LIB_PATH)config.mk
57 
58 # Generic util functions are needed for all apps (api.c)
59 -include $(UTIL_PATH)makefile
60 
61 # Include libraries code
62 -include $(WP_LIB_PATH)makefile
63 INCLUDES += -I$(WP_LIB_PATH)
64 
65 # Include MCU config first
66 -include $(MCU_PATH)config.mk
67 
68 # Include MCU HAL drivers code
69 -include $(HAL_API_PATH)makefile
70 
71 # Include common MCU sources
72 include $(MCU_PATH)common/makefile
73 
74 #
75 # Sources & includes paths
76 #
77 SRCS += $(APP_SRCS_PATH)app.c
78 INCLUDES += -I$(API_PATH) -I$(APP_SRCS_PATH)include -I$(UTIL_PATH)
79 
80 # Objects list
81 OBJS_ = $(SRCS:.c=.o) $(ASM_SRCS:.s=.o)
82 OBJS = $(addprefix $(BUILDPREFIX_APP), $(OBJS_))
83 
84 # Dependent list
85 DEPS_ = $(SRCS:.c=.d)
86 DEPS = $(addprefix $(BUILDPREFIX_APP), $(DEPS_))
87 
88 
89 # Files to be cleaned
90 CLEAN := $(OBJS) $(APP_ELF) $(APP_HEX) $(DEPS)
91 
92 $(BUILDPREFIX_APP)%.o : %.c $(APP_SRCS_PATH)makefile $(APP_CONFIG) $(BOARD_CONFIG) $(MCU_CONFIG)
93  $(DD)$(MKDIR) $(@D)
94  @echo "$(COLOR_CC)CC$(COLOR_END) $<"
95  $(D)$(CC) $(INCLUDES) $(CFLAGS) -MMD -MP -c $< -o $@
96 
97 $(BUILDPREFIX_APP)%.o : %.s
98  $(DD)$(MKDIR) $(@D)
99  @echo "$(COLOR_CC)CC$(COLOR_END) $<"
100  $(D)$(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
101 
102 
103 $(APP_ELF): $(OBJS) $(LIBS)
104  @echo "$(COLOR_LINK)Linking$(COLOR_END) $@"
105  $(D)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ \
106  -Wl,-Map=$(BUILDPREFIX_APP)$(APP_NAME).map \
107  -Wl,-T,$(LDSCRIPT),--print-memory-usage $(LIBS)
108 
109 
110 $(APP_HEX): $(APP_ELF)
111  @echo "$(COLOR_DETAILS)CFLAGS are:\n $(CFLAGS)$(COLOR_END)"
112  @echo "$(COLOR_DETAILS)LDFLAGS are:\n $(LDFLAGS)$(COLOR_END)"
113  @echo "$(COLOR_INFO)Generating:$(COLOR_END) $@"
114  $(D)@$(OBJCOPY) $< -O ihex $@
115 
116 .PHONY: $(VERSION_FILE)
117 $(VERSION_FILE):
118  @echo "app_version=$(app_major).$(app_minor).$(app_maintenance).$(app_development)" > $(@)
119  @echo "sha1=$(shell git log -1 --pretty=format:"%h")" >> $(@)
120 
121 .PHONY: all
122 all: $(APP_HEX) $(VERSION_FILE)
123 
124 clean:
125  $(D)$(RM) -rf $(CLEAN)
126 
127 -include $(DEPS)