-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
202 lines (155 loc) · 4.93 KB
/
Makefile
File metadata and controls
202 lines (155 loc) · 4.93 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
MAJOR_VERSION=0
MINOR_VERSION=1
PATCH_VERSION=3
HOST_OS=$(shell uname)
BUILD?=build.$(HOST_OS)
export STAGING=staging.$(HOST_OS)
BSPS_DIR?=$(STAGING)/bsps
ifeq ($(V),1)
quiet_=
Q=
else
quiet_=quiet_
Q=@
endif
# Do not:
# o use make's built-in rules and variables
# (this increases performance and avoids hard-to-debug behaviour);
# o print "Entering directory ...";
MAKEFLAGS += -rR --no-print-directory
all : _all
build_dir:
@mkdir -p $(BUILD)
$(BSPS_DIR)/.fetched:
@echo "Fetching BSPs"
@git clone https://github.com/ebirger/tinkerpal_bsps.git $(BSPS_DIR)
@touch $(BSPS_DIR)/.fetched
FETCH_BSPS:=$(BSPS_DIR)/.fetched
ifeq ($(wildcard $(BUILD)/auto.conf),)
# auto.conf is not ready. Create it and recursively call make once auto.conf is created
_all: build_dir $(BUILD)/auto.conf $(BSPS_DIR)/.fetched
@make BUILD=$(BUILD)
else
# auto.conf is ready. actually build the target
include $(BUILD)/auto.conf
include scripts/defaults.mk
include scripts/Makefile.toolchain
include scripts/text_to_c.mk
d=.
MK_SUBDIRS=apps main platform mem util boards
MK_SUBDIRS+=$(if $(CONFIG_JS),js)
MK_SUBDIRS+=$(if $(CONFIG_NET),net)
MK_SUBDIRS+=$(if $(CONFIG_USB),usb)
MK_SUBDIRS+=$(if $(CONFIG_GRAPHICS),graphics)
MK_SUBDIRS+=drivers
# vfs must be last since builtin fs aggregates files from other drivers
MK_SUBDIRS+=$(if $(CONFIG_VFS),fs)
include scripts/Rules.mk
include scripts/footer.mk
# Pull in calculated dependencied from previous build
$(call include_deps)
TARGET=$(BUILD)/$(TARGET_NAME)
IMAGE=$(addprefix $(BUILD)/,$(IMAGE_NAME))
COVERAGE_INFO=$(BUILD)/cov.info
_all: $(BSPS_DIR)/.fetched $(IMAGE) $(BUILD)/auto.conf
clean:
$(Q)rm -f $(TARGET) $(IMAGE) $(OBJS) $(AUTO_GEN_FILES) $(OBJS:.o=.d) \
$(COVERAGE_INFO)
endif
include scripts/Makefile.config
ifneq ($(wildcard $(BUILD)),)
distclean:
rm -rf $(BUILD)
endif
docs:
@make BUILD=$(BUILD) -f doc/Makefile
gen_cov_info:
@lcov --capture --directory $(BUILD) --output-file $(COVERAGE_INFO)
coverage: gen_cov_info
@genhtml $(COVERAGE_INFO) --output-directory $(BUILD)/coverage
# Build rules
# do not discard intermediate targets
.SECONDARY:
quiet_compile= CC $@
quiet_asm= AS $@
quiet_link= LD $@
quiet_gen_image= GEN $(IMAGE)
$(BUILD)/version_data.h :
@echo "GEN $@"
@echo "/* Automatically generated version file, DO NOT MANUALLY EDIT */" > $@
@echo "#ifndef __TINKERPAL_VERSION_DATA_H___" >> $@
@echo "#define __TINKERPAL_VERSION_DATA_H___" >> $@
@echo "#define TINKERPAL_VERSION \"$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION)\"" >> $@
@echo "#define TINKERPAL_MAJOR_VERSION $(MAJOR_VERSION)" >> $@
@echo "#define TINKERPAL_MINOR_VERSION $(MINOR_VERSION)" >> $@
@echo "#define TINKERPAL_PATCH_VERSION $(PATCH_VERSION)" >> $@
@echo "#endif" >> $@
$(BUILD)/jsapi.h: $(JSAPIS) $(BUILD)/autoconf.h
@echo "GEN $@"
@echo "/* Automatically generated file, DO NOT MANUALLY EDIT */" > $@
@cat $(JSAPIS) >> $@
AUTO_GEN_FILES+=$(BUILD)/jsapi.h
ALL_DEPS:=$(BUILD)/autoconf.h $(BUILD)/version_data.h \
$(if $(CONFIG_JS),$(BUILD)/jsapi.h)
$(BUILD)/%.o : %.c $(ALL_DEPS)
@echo $($(quiet_)compile)
@$(call compile)
@$(call calc_deps)
$(BUILD)/%.o : $(BUILD)/%.c $(ALL_DEPS)
@echo $($(quiet_)compile)
@$(call compile)
@$(call calc_deps)
$(BUILD)/%.o : %.s $(ALL_DEPS)
@echo $($(quiet_)asm)
@$(call asm)
$(TARGET) : $(OBJS) $(LINK_DEPS)
$(call target_link)
# Use .INTERMEDIATE target as a trick for supporting
# an atomic generation of multiple IMAGE files
$(IMAGE) : $(TARGET).interm
.INTERMEDIATE: $(TARGET).interm
$(TARGET).interm : $(TARGET)
@echo $($(quiet_)gen_image)
@$(call gen_image)
help:
@echo 'Cleaning targets:'
@echo ' clean - Remove most generated files but keep the config'
@echo ' distclean - Remove build directory'
@echo ''
@echo 'Configuration targets:'
@echo ' config - Update current config utilising a line-oriented program'
@echo ' menuconfig - Update current config utilising a menu based program'
@echo ''
@echo 'Documentation targets:'
@echo ' docs - Generate API documentation'
@echo ''
@echo 'Execution targets:'
@echo ' burn - Burn image to target platform'
@echo ' simulate - Execute emulator for current target'
@echo ''
@echo 'Generic options:'
@echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
@echo ''
@echo 'Target Boards:'
@$(foreach b,$(shell ls boards/configs), \
printf " %-24s\\n" $(b);)
define note
@printf *********************************************************\\n
@printf $1\\n
@printf *********************************************************\\n
endef
burn : $(BURNER)
ifneq ($(BURN_CMD),)
$(if $(BURN_NOTE),$(call note,$(BURN_NOTE)))
@sudo $(BURN_CMD)
else
$(error burn command not available)
endif
simulate : $(SIMULATOR)
ifneq ($(SIMULATE_CMD),)
$(if $(SIMULATE_NOTE),$(call note,$(SIMULATE_NOTE)))
@$(SIMULATE_CMD)
else
$(error simulate command not available)
endif
.PHONY: build_dir _all docs burn help gen_cov_info coverage