-
Notifications
You must be signed in to change notification settings - Fork 52
/
Makefile
269 lines (217 loc) · 6.87 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
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# User variables. type make to get some help
# Parallelism used when building the runtimes
JOBS=0
# Whether to create symlinks or just copy files when generating the rts
LINK=
# Build with Debug ?
DEBUG=
# The target to build
TARGET=
# Whether to just build BSPs
BSPS=
# Sources of GNAT and GCC
GNAT=$(SRC_DIR)/../gnat
GCC=$(SRC_DIR)/../gcc
GNAT_SOURCES=$(GNAT)
GCC_SOURCES=$(GCC)
RTS_SRCS=
###################
# Other variables #
###################
SRC_DIR:=$(shell pwd)
#########################
# TARGET Configurations #
#########################
TARGETS=none
ifeq ($(TARGET),$(filter $(TARGET),powerpc-elf ppc-elf ppc))
TGT=powerpc-elf
TARGETS=mpc8641
endif
ifeq ($(TARGET),$(filter $(TARGET),powerpc-eabispe p55-elf p55))
TGT=powerpc-eabispe
TARGETS=p2020 p5566
endif
ifeq ($(TARGET),$(filter $(TARGET),aarch64-elf aarch64))
TGT=aarch64-elf
TARGETS=rpi3 rpi3mc zynqmp
endif
ifeq ($(TARGET),$(filter $(TARGET),arm-eabi arm-elf arm))
TGT=arm-eabi
TARGETS=zynq7000 rpi2 rpi2mc sam4s samg55 samrh71 smartfusion2 openmv2 stm32f4 \
stm32f429disco stm32f469disco stm32f746disco stm32756geval \
stm32f769disco tms570 tms570_sci tms570lc lm3s cortex-m0 cortex-m0p \
cortex-m1 cortex-m3 cortex-m4 cortex-m4f cortex-m7f cortex-m7df
endif
ifeq ($(TARGET),$(filter $(TARGET),leon-elf leon2-elf leon leon2))
TGT=leon-elf
TARGETS=leon3 leon3-smp leon4 leon4-smp
endif
ifeq ($(TARGET),$(filter $(TARGET),leon3-elf leon3))
TGT=leon3-elf
TARGETS=leon3 leon3-smp
endif
ifeq ($(TARGET),$(filter $(TARGET),visium-elf visium))
TGT=visium-elf
TARGETS=mcm
endif
ifeq ($(TARGET),$(filter $(TARGET),riscv-elf riscv))
TGT=riscv-elf
TARGETS=spike
endif
ifeq ($(TARGET),$(filter $(TARGET),i686-pc-linux-gnu x86-linux))
TGT=i686-pc-linux-gnu
TARGETS=x86-linux
endif
ifeq ($(TARGET),$(filter $(TARGET),i686-pc-mingw32 x86-windows))
TGT=i686-pc-mingw32
TARGETS=x86-windows
endif
ifeq ($(TARGET),$(filter $(TARGET),x86_64-pc-linux-gnu x86_64-linux))
TGT=x86_64-pc-linux-gnu
TARGETS=x86_64-linux
endif
ifeq ($(TARGET),$(filter $(TARGET),x86_64-pc-mingw32 x86_64-windows))
TGT=x86_64-pc-mingw32
TARGETS=x86_64-windows
endif
ifeq ($(TARGET),$(filter $(TARGET),x86_64-w64-mingw32 x86_64-windows64))
TGT=x86_64-w64-mingw32
TARGETS=x86_64-windows64
endif
ifeq ($(TARGET),$(filter $(TARGET),aarch64-pikeos5))
TGT=aarch64-sysgo-pikeos5
TARGETS=aarch64-pikeos5
endif
ifeq ($(TARGET),$(filter $(TARGET),arm-sysgo-pikeos arm-pikeos))
TGT=arm-sysgo-pikeos
TARGETS=arm-pikeos
endif
ifeq ($(TARGET),$(filter $(TARGET),arm-sysgo-pikeos4 arm-pikeos4.2))
TGT=arm-sysgo-pikeos4
TARGETS=arm-pikeos4.2
endif
ifeq ($(TARGET),$(filter $(TARGET),arm-sysgo-pikeos4 arm-pikeos5))
TGT=arm-sysgo-pikeos5
TARGETS=arm-pikeos5
endif
ifeq ($(TARGET),$(filter $(TARGET),ppc-pikeos5))
TGT=powerpc-sysgo-pikeos5
TARGETS=ppc-pikeos5
endif
ifeq ($(TARGET),$(filter $(TARGET),ppc-lynx178))
TGT=powerpc-xcoff-lynxos178
TARGETS=ppc-lynx178
endif
ifeq ($(TARGETS), none)
ifeq ($(TARGET),)
$(error Error: TARGET is not defined)
else
$(error Error: unknown TARGET: '$(TARGET)')
endif
endif
#########
# Tools #
#########
GCC_PREFIX:=$(abspath $(dir $(shell which $(TGT)-gcc))/..)
ifneq ($(PREFIX),)
GCC_PREFIX:=$(PREFIX)
endif
BUILD_RTS_FLAGS=
GEN_RTS_FLAGS=
GPRBUILD_FLAGS:=-j$(JOBS) -v -s
ifneq ($(DEBUG),)
GPRBUILD_FLAGS:=$(GPRBUILD_FLAGS) -XBUILD=Debug
endif
ifneq ($(LINK),)
BUILD_RTS_FLAGS:=$(BUILD_RTS_FLAGS) --link
GEN_RTS_FLAGS:=$(GEN_RTS_FLAGS) --link
endif
ifeq ($(BSPS),)
RTS_SRCS=obj/rts-sources
BUILD_RTS_FLAGS:=$(BUILD_RTS_FLAGS) --rts-src-descriptor=obj/rts.json
endif
GPRBUILD:=GPR_PROJECT_PATH=obj/$(TGT)/lib/gnat gprbuild $(GPRBUILD_FLAGS)
GPRINSTALL:=GPR_PROJECT_PATH=obj/$(TGT)/lib/gnat gprinstall \
--prefix=$(GCC_PREFIX) -f -p
BUILD_RTS:=./build_rts.py $(BUILD_RTS_FLAGS)
GEN_RTS:=./gen_rts_sources.py $(GEN_RTS_FLAGS)
default:
@echo "This makefile builds&install recompilable runtimes"
@echo "Here is the list of variables:"
@echo
@echo " TARGET specifify the target (mandatory)"
@echo " JOBS set number of jobs"
@echo " GNAT_SOURCES location of GNAT sources"
@echo " default is $(GNAT_SOURCES)"
@echo " GCC_SOURCES location of GCC sources"
@echo " default is $(GCC_SOURCES)"
@echo " PREFIX overrides the default prefix (gcc dir)"
@echo
@echo "The makefile accepts the following targets:"
@echo
@echo " make all Build all runtimes for a given target"
@echo " make install Install all runtimes for a given target"
@echo " make srcs Build runtime sources in ./obj"
@echo " make <board>.build"
@echo " Build the runtimes for the board"
@echo " make <board>.embeddedbuild"
@echo " Build the embedded runtime for the board"
@echo " make <board>.taskingbuild"
@echo " Build the light-tasking runtime for the board"
@echo " make <board>.lightbuild"
@echo " Build the light runtime for the board"
@echo " make <board>.install"
@echo " Install the board's rts in gcc"
@echo " make <board>.fullinstall"
@echo " Install the board's embedded rts in gcc"
@echo " make <board>.sfpinstall"
@echo " Install the board's light-tasking rts in gcc"
@echo " make <board>.zfpinstall"
@echo " Install the board's light rts in gcc"
obj/rts-sources:
$(GEN_RTS) \
--output-descriptor=obj/rts.json \
--output-sources=$@ \
--gnat-dir=$(GNAT_SOURCES) --gcc-dir=$(GCC_SOURCES) \
--rts-profile=embedded
srcs: $(RTS_SRCS)
$(BUILD_RTS) --force \
--output=obj $(TARGETS)
all: $(RTS_SRCS)
$(BUILD_RTS) --force --build \
--output=obj $(TARGETS)
install: $(RTS_SRCS)
$(BUILD_RTS) --force --build $(TARGETS)
%.build: obj/$(TGT)
for f in obj/$(TGT)/BSPs/*_$*.gpr; do \
$(GPRBUILD) -P $$f; \
done
%.embeddedbuild: obj/$(TGT)
if [ ! -f obj/$(TGT)/BSPs/embedded_$*.gpr ]; then \
echo "no Embedded runtime for $*"; \
exit 1; \
fi
$(GPRBUILD) -P obj/$(TGT)/BSPs/embedded_$*.gpr
%.taskingbuild: obj/$(TGT)
if [ ! -f obj/$(TGT)/BSPs/light_tasking_$*.gpr ]; then \
echo "no Light-Tasking runtime for $*"; \
exit 1; \
fi
$(GPRBUILD) -P obj/$(TGT)/BSPs/ravenscar_sfp_$*.gpr
%.lightbuild: obj/$(TGT)
if [ ! -f obj/$(TGT)/BSPs/light_$*.gpr ]; then \
echo "no Light runtime for $*"; \
exit 1; \
fi
$(GPRBUILD) -P obj/$(TGT)/BSPs/zfp_$*.gpr
%.install: %.build
for f in obj/$(TGT)/BSPs/*_$*.gpr; do \
$(GPRINSTALL) --uninstall -P $$f; \
$(GPRINSTALL) -p -f -P $$f; \
done
%.fullinstall: %.embeddedbuild
$(GPRINSTALL) -P obj/$(TGT)/BSPs/embedded_$*.gpr
%.sfpinstall: %.taskingbuild
$(GPRINSTALL) -P obj/$(TGT)/BSPs/light_tasking_$*.gpr
%.zfpinstall: %.lightbuild
$(GPRINSTALL) -P obj/$(TGT)/BSPs/light_$*.gpr