forked from wirepas/wm-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile_app.mk
76 lines (53 loc) · 1.66 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
include makefile_common.mk
.DEFAULT_GOAL := all
# Linker script
LDSCRIPT = mcu/$(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
# 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)
# Include board init part
-include board/makefile
# Include app specific makefile
-include $(APP_SRCS_PATH)makefile
# 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
#
# Sources & includes paths
#
SRCS += $(APP_SRCS_PATH)app.c $(MCU_COMMON_SRCS_PATH)start.c
ASM_SRCS += $(MCU_COMMON_SRCS_PATH)entrypoint.s
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_))
# Files to be cleaned
CLEAN := $(OBJS) $(APP_ELF) $(APP_HEX)
$(BUILDPREFIX_APP)%.o : %.c
$(MKDIR) $(@D)
$(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
$(BUILDPREFIX_APP)%.o : %.s
$(MKDIR) $(@D)
$(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
$(APP_ELF): $(OBJS) $(LIBS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ \
-Wl,-Map=$(BUILDPREFIX_APP)$(APP_NAME).map \
-Wl,-T,$(LDSCRIPT) $(LIBS)
$(APP_HEX): $(APP_ELF)
@echo "Generating $(APP_HEX)"
$(OBJCOPY) $< -O ihex $@
.PHONY: all
all: $(APP_HEX)
clean:
$(RM) -rf $(CLEAN)