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