-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (103 loc) · 3.51 KB
/
Makefile
File metadata and controls
133 lines (103 loc) · 3.51 KB
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
###################################################################
# About the library name and path
###################################################################
# library name, without extension
LIB_NAME ?= libstd
# project root directory, relative to app dir
PROJ_FILES = ../../
# library name, with extension
LIB_FULL_NAME = $(LIB_NAME).a
# SDK helper Makefiles inclusion
-include $(PROJ_FILES)/m_config.mk
-include $(PROJ_FILES)/m_generic.mk
# use an app-specific build dir
APP_BUILD_DIR = $(BUILD_DIR)/libs/$(LIB_NAME)
###################################################################
# About the compilation flags
###################################################################
CFLAGS := $(LIBS_CFLAGS)
# this lib is special: some of its functions are called by the kernel and as such must NOT be
# purged at strip time by the compiler.
# this is specific to libstd, as this lib hold the task entrypoints (do_startisr and do_starttask)
# which whould be overriden by the -Wl,gc -ffunction-sections
# FIXME: test using .init sextion
#CFLAGS += -fno-function-sections
CFLAGS += -I. -Iarch/cores/$(CONFIG_ARCH)
# about local subdirs
# libstd API
CFLAGS += -Iapi/
# libstd sublibs
CFLAGS += -Ialloc/
CFLAGS += -Istream/
CFLAGS += -Istring/
CFLAGS += -Iembed/
CFLAGS += -Iarpa/
CFLAGS += -Isys/
# here we need libecc
CFLAGS += -I$(PROJ_FILES)/externals/libecc/src $(EXTERNAL_CFLAGS) $(LIBSIGN_CFLAGS)
CFLAGS += -Idrbg/
CFLAGS += -MMD -MP -Os
#############################################################
# About library sources
#############################################################
# libstd has arch-specific sources
ARCH_DIR := ./arch/cores/$(ARCH)
ARCH_SRC = $(wildcard $(ARCH_DIR)/*.c)
ARCH_OBJ = $(patsubst %.c,$(APP_BUILD_DIR)/%.o,$(ARCH_SRC))
# ... and C sources
SRC_DIR = .
SRC = $(wildcard $(SRC_DIR)/*.c)
SRC += $(wildcard $(SRC_DIR)/alloc/*.c)
SRC += $(wildcard $(SRC_DIR)/stream/*.c)
SRC += $(wildcard $(SRC_DIR)/string/*.c)
SRC += $(wildcard $(SRC_DIR)/embed/*.c)
SRC += $(wildcard $(SRC_DIR)/arpa/*.c)
SRC += $(wildcard $(SRC_DIR)/sys/*.c)
SRC += $(wildcard $(SRC_DIR)/drbg/*.c)
SRC += $(wildcard $(SRC_DIR)/embed/arch/cores/armv7-m/*.c)
OBJ = $(patsubst %.c,$(APP_BUILD_DIR)/%.o,$(SRC))
DEP = $(OBJ:.o=.d)
ASM_SRC += $(wildcard $(SRC_DIR)/embed/arch/cores/armv7-m/*.s)
ASM_OBJ = $(patsubst %.s,$(APP_BUILD_DIR)/%.o,$(ASM_SRC))
OUT_DIRS = $(dir $(OBJ)) $(dir $(ARCH_OBJ))
# file to (dist)clean
# objects and compilation related
TODEL_CLEAN += $(ARCH_OBJ) $(OBJ)
# targets
TODEL_DISTCLEAN += $(APP_BUILD_DIR)
##########################################################
# generic targets of all libraries makefiles
##########################################################
.PHONY: app doc
default: all
all: $(APP_BUILD_DIR) lib
doc:
$(Q)$(MAKE) BUILDDIR=../$(APP_BUILD_DIR)/doc -C doc html latexpdf
show:
@echo
@echo "\tAPP_BUILD_DIR\t=> " $(APP_BUILD_DIR)
@echo
@echo "C sources files:"
@echo "\tSRC_DIR\t\t=> " $(SRC_DIR)
@echo "\tSRC\t\t=> " $(SRC)
@echo "\tOBJ\t\t=> " $(OBJ)
@echo
@echo "\tARCH_DIR\t=> " $(ARCH_DIR)
@echo "\tARCH_SRC\t=> " $(ARCH_SRC)
@echo "\tARCH_OBJ\t=> " $(ARCH_OBJ)
@echo
lib: $(APP_BUILD_DIR)/$(LIB_FULL_NAME)
$(APP_BUILD_DIR)/%.o: %.c
$(call if_changed,cc_o_c)
$(APP_BUILD_DIR)/%.o: %.s
$(call if_changed,cc_o_c)
# arch C sources files
$(APP_BUILD_DIR)/%.o: $(ARCH_DIR)/%.c
$(call if_changed,cc_o_c)
# lib
$(APP_BUILD_DIR)/$(LIB_FULL_NAME): $(OBJ) $(ASM_OBJ) $(ARCH_OBJ)
$(call if_changed,mklib)
$(call if_changed,ranlib)
$(APP_BUILD_DIR):
$(call cmd,mkdir)
-include $(DEP)