-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
155 lines (112 loc) · 4.12 KB
/
Makefile
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
###################################################################
# About the application name and path
###################################################################
# Application name, can be suffixed by the SDK
APP_NAME ?= storage
# application build directory name
DIR_NAME = storage
# project root directory, relative to app dir
PROJ_FILES = ../../
# binary, hex and elf file names
BIN_NAME = $(APP_NAME).bin
HEX_NAME = $(APP_NAME).hex
ELF_NAME = $(APP_NAME).elf
# SDK helper Makefiles inclusion
-include $(PROJ_FILES)/m_config.mk
-include $(PROJ_FILES)/m_generic.mk
# application build directory, relative to the SDK BUILD_DIR environment
# variable.
APP_BUILD_DIR = $(BUILD_DIR)/apps/$(DIR_NAME)
###################################################################
# About the compilation flags
###################################################################
# SDK Cflags
CFLAGS := $(APPS_CFLAGS)
# Application CFLAGS...
CFLAGS += -Isrc/ -MMD -MP
###################################################################
# About the link step
###################################################################
# linker options to add the layout file
LDFLAGS += $(EXTRA_LDFLAGS) -L$(APP_BUILD_DIR)
# project's library you whish to use...
LD_LIBS += -Wl,--start-group -Wl,-lstd -Wl,-lhmac -Wl,-lsign -Wl,-lsd -Wl,-lsdio -Wl,-lu2f2 -Wl,-lfidostorage -Wl,-laes -Wl,-lcryp -Wl,--end-group
###################################################################
# okay let's list our source files and generated files now
###################################################################
CSRC_DIR = src
SRC = $(wildcard $(CSRC_DIR)/*.c)
OBJ = $(patsubst %.c,$(APP_BUILD_DIR)/%.o,$(SRC))
DEP = $(OBJ:.o=.d)
# the output directories, that will be deleted by the distclean target
OUT_DIRS = $(dir $(OBJ))
# the ldcript file generated by the SDK
LDSCRIPT_NAME = $(APP_BUILD_DIR)/$(APP_NAME).ld
# file to (dist)clean
# objects and compilation related
TODEL_CLEAN += $(OBJ) $(DEP) $(LDSCRIPT_NAME)
# targets
TODEL_DISTCLEAN += $(APP_BUILD_DIR)
.PHONY: app
############################################################
# explicit dependency on the application libs and drivers
# compiling the application requires the compilation of its
# dependencies
############################################################
## library dependencies
LIBDEP := $(BUILD_DIR)/libs/libstd/libstd.a \
$(BUILD_DIR)/libs/libsd/libsd.a \
$(BUILD_DIR)/libs/libfidostorage/libfidostorage.a \
$(BUILD_DIR)/libs/libaes/libaes.a \
$(BUILD_DIR)/libs/libhmac/libhmac.a \
$(BUILD_DIR)/libs/libsd/libu2f2.a
libdep: $(LIBDEP)
$(LIBDEP):
$(Q)$(MAKE) -C $(PROJ_FILES)libs/$(patsubst lib%.a,%,$(notdir $@))
# drivers dependencies
SOCDRVDEP := $(BUILD_DIR)/drivers/libsdio/libsdio.a \
$(BUILD_DIR)/drivers/libcryp/libcryp.a
socdrvdep: $(SOCDRVDEP)
$(SOCDRVDEP):
$(Q)$(MAKE) -C $(PROJ_FILES)drivers/socs/$(SOC)/$(patsubst lib%.a,%,$(notdir $@))
# board drivers dependencies
BRDDRVDEP :=
brddrvdep: $(BRDDRVDEP)
$(BRDDRVDEP):
$(Q)$(MAKE) -C $(PROJ_FILES)drivers/boards/$(BOARD)/$(patsubst lib%.a,%,$(notdir $@))
# external dependencies
EXTDEP :=
extdep: $(EXTDEP)
$(EXTDEP):
$(Q)$(MAKE) -C $(PROJ_FILES)externals
alldeps: libdep socdrvdep brddrvdep extdep
##########################################################
# generic targets of all applications makefiles
##########################################################
show:
@echo
@echo "\t\tAPP_BUILD_DIR\t=> " $(APP_BUILD_DIR)
@echo
@echo "C sources files:"
@echo "\t\tSRC\t=> " $(SRC)
@echo "\t\tOBJ\t=> " $(OBJ)
@echo "\t\tDEP\t=> " $(DEP)
@echo
@echo "\t\tCFG\t=> " $(CFLAGS)
# all (default) build the app
all: $(APP_BUILD_DIR) alldeps app
app: $(APP_BUILD_DIR)/$(ELF_NAME) $(APP_BUILD_DIR)/$(HEX_NAME)
$(APP_BUILD_DIR)/%.o: %.c
$(call if_changed,cc_o_c)
# ELF
$(APP_BUILD_DIR)/$(ELF_NAME): $(OBJ)
$(call if_changed,link_o_target)
# HEX
$(APP_BUILD_DIR)/$(HEX_NAME): $(APP_BUILD_DIR)/$(ELF_NAME)
$(call if_changed,objcopy_ihex)
# BIN
$(APP_BUILD_DIR)/$(BIN_NAME): $(APP_BUILD_DIR)/$(ELF_NAME)
$(call if_changed,objcopy_bin)
$(APP_BUILD_DIR):
$(call cmd,mkdir)
-include $(DEP)