-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
GNUmakefile
376 lines (314 loc) · 12.2 KB
/
GNUmakefile
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
all: build test
# Build directory structure:
#
# ${BUILDROOT}: the default build location, optimised
# build/debug: debug symbols, optimisation off
#
# build32, build64: so you can build "the other" word size version
# if your platform can build it, to check code is portable
#
#
# default build
#
VERSION := $(shell python3 showversion.py)
DISTDIR ?= ./build/dist
PREFIX ?= /usr/local
EXECPREFIX ?= ${PREFIX}/bin
INSTALLROOT ?= ${PREFIX}/lib/felix
INSTALLDIR ?= ${INSTALLROOT}/felix-$(VERSION)
FBUILDROOT ?= build
BUILDROOT ?= ${FBUILDROOT}/release
BUILDBIN = ${BUILDROOT}/host/bin
DEBUGBUILDROOT ?= ${FBUILDROOT}/debug
PYTHON ?= python3
# If running as root skip sudo
ifeq ($(USER),root)
SUDO=
else
SUDO=sudo
endif
ifeq ($(FLX_BUILD_TOOLCHAIN_FAMILY),gcc)
FBUILD_PARAMS = --build-cc=gcc --build-cxx=g++
endif
ifeq ($(FLX_BUILD_TOOLCHAIN_FAMILY),clang)
FBUILD_PARAMS = --build-cc=clang --build-cxx=clang++
endif
# Choose one: Linux or OSX
# LPATH = LD_LIBRARY_PATH or, LPATH = DYLD_LIBRARY_PATH
platform := $(shell uname -s)
ifeq ($(platform), Linux)
LPATH = LD_LIBRARY_PATH
ifeq ($(FLX_BUILD_TOOLCHAIN_FAMILY),clang)
TOOLCHAIN=toolchain_clang_linux
else
TOOLCHAIN=toolchain_gcc_linux
endif
else
ifeq ($(platform), Darwin)
LPATH = DYLD_LIBRARY_PATH
ifeq ($(FLX_BUILD_TOOLCHAIN_FAMILY),gcc)
TOOLCHAIN=toolchain_gcc_macosx
else
TOOLCHAIN=toolchain_clang_macosx
endif
endif
endif
ifndef LPATH
$(warning Unrecognized kernel name -- Unable to detect setting for LPATH)
LPATH = LD_LIBRARY_PATH
TOOLCHAIN=toolchain_gcc_linux
endif
help:
# Makefile help
# FELIX VERSION ${VERSION}
# DISTDIR ${DISTDIR}
# BUILDROOT ${BUILDROOT}
#
# Make Targets, USERS:
# build: primary build default release target ${BUILDROOT}
# test: run regression test suite
# install: install release to install point
# default install point: /usr/local/lib/felix/felix-version
#
# Make Targets, DEVELOPERS:
# gendoc: generate docs (developers only)
#
# Params:
# FBUILDROOT: directory to build into, default build
# FBUILD_PARAMS: parameters to fbuild, default none
# fbuild/fbuild-light --help for options
showversion:
echo Felix Version ${VERSION}
build: extract showversion configure bootstrap bootstrap-tools rebuild uproot
bootstrap: fbuild
cp ${BUILDBIN}/bootflx ${BUILDBIN}/flx
${BUILDROOT}/host/bin/flx --felix=build.fpc -c -od ${BUILDROOT}/host/lib/rtl ${BUILDROOT}/share/lib/plugins/flx_plugin
clean:
rm -rf build trial
git clean -fd
#
# Core integrated build
#
configure: extract
#
# ============================================================
#
# CONFIGURING FELIX
#
# See ${BUILDROOT}/fbuild.log for full transcript
#
# ============================================================
#
$(PYTHON) fbuild/fbuild-light configure --buildroot=${FBUILDROOT} $(FBUILD_PARAMS)
do-fbuild:
#
# ============================================================
#
# BOOTSTRAPPING FELIX
#
# See ${BUILDROOT}/fbuild.log for full transcript
#
# ============================================================
#
$(PYTHON) fbuild/fbuild-light build --buildroot=${FBUILDROOT} $(FBUILD_PARAMS)
clean-fbuild:
rm -rf ${BUILDROOT}/exe*
rm -rf ${BUILDROOT}/temp*
rm -rf ${BUILDROOT}/obj*
rm -rf ${BUILDROOT}/lib*
rm -rf ${BUILDROOT}/__init__.py
rm -rf ${BUILDROOT}/tut
rm -rf ${BUILDROOT}/tutopt
rm -rf ${BUILDROOT}/pyconfig
rm -rf ${BUILDROOT}/cache
fbuild: do-fbuild clean-fbuild
packages:
# =========================================================
# generates source code from "src/packages" to various places
# around the repo
# =========================================================
python3 src/tools/flx_iscr.py -q -d "src/packages" ${BUILDROOT}
extras:
for file in extras/*.fdoc; do python3 src/tools/flx_iscr.py $$file ${BUILDROOT}; done
grammar:
src/tools/flx_find_grammar_files.py ${BUILDROOT}
extract: packages grammar
fextract:
flx_iscr ${PWD}/src/packages "--regex=.*\\.fdoc" build/release
flx_find_grammar_files
bootstrap-tools:
# =========================================================
# build tools required for rebuild.
# This is to be done right after building the bootstrap.
# The tools are placed in the host.
# =========================================================
${BUILDBIN}/flx --felix=build.fpc --static -c -od ${BUILDBIN} src/tools/flx_build_flxg.flx
${BUILDBIN}/flx --felix=build.fpc --static -c -od ${BUILDBIN} src/tools/flx_build_prep.flx
${BUILDBIN}/flx --felix=build.fpc --static -c -od ${BUILDBIN} src/tools/flx_build_rtl.flx
${BUILDBIN}/flx --felix=build.fpc --static -c -od ${BUILDBIN} src/tools/flx_build_boot.flx
flxg:
# =========================================================
# building flxg
# =========================================================
${BUILDBIN}/flx_build_flxg
cp build/flxg-tmp/flxg ${BUILDBIN}
gcc_macosx:
# =========================================================
# prepare for gcc build on macosx
# =========================================================
${BUILDBIN}/flx_build_prep --target-dir=${BUILDROOT} \
--target-bin=gcc_macosx --source-dir=${BUILDROOT} \
--source-bin=host --clean-target-bin-dir --copy-compiler\
--configure --compiler=gcc --os=macosx --bits=64 \
--cxx-compiler=g++ --debug
# =========================================================
# build gcc rtl on macosx
# =========================================================
${LPATH}=${BUILDROOT}/host/lib/rtl flx_build_rtl --target-dir=${BUILDROOT} --target-bin=gcc_macosx
# =========================================================
# build Felix with gcc rtl on macosx
# =========================================================
${LPATH}=${BUILDROOT}/host/lib/rtl flx_build_boot --target-dir=${BUILDROOT} --target-bin=gcc_macosx --build-all
prep:
# =========================================================
# prepare for host build
# =========================================================
${BUILDBIN}/flx_build_prep --target-dir=${BUILDROOT} \
--target-bin=trial --source-dir=${BUILDROOT} --source-bin=host\
--clean-target-bin-dir --copy-compiler --copy-pkg-db \
--copy-config-headers --toolchain=${TOOLCHAIN} --debug
rtlbase:
# =========================================================
# rebuild rtl
# =========================================================
${LPATH}=${BUILDROOT}/host/lib/rtl ${BUILDBIN}/flx_build_rtl --target-dir=${BUILDROOT} --target-bin=trial
rtl: extract prep rtlbase
target: prep flxg rtlbase boot
boot:
# =========================================================
# rebuild flx build tools and plugins
# =========================================================
${LPATH}=${BUILDROOT}/host/lib/rtl ${BUILDBIN}/flx_build_boot --target-dir=${BUILDROOT} --target-bin=trial --build-all
rebuild: extract target uproot
uproot:
rm -rf ${BUILDROOT}/host
mv ${BUILDROOT}/trial ${BUILDROOT}/host
src:
rm -rf ${BUILDROOT}/share/src
mkdir -p ${BUILDROOT}/share/src
cp -r src ${BUILDROOT}/share
rm -rf ${BUILDROOT}/share/test
mkdir -p ${BUILDROOT}/share/test
cp -r src/test ${BUILDROOT}/share/test
rm -rf ${BUILDROOT}/test
iphonesimulator:
# prepare directory
${BUILDBIN}/flx_build_prep --target-dir=${BUILDROOT} --target-bin=iphonesimulator --source-dir=${BUILDROOT} \
--source-bin=host --clean-target-bin-dir --copy-compiler --copy-pkg-db \
--copy-config-headers --toolchain=toolchain_iphonesimulator --debug
rm -rf build/rtl-tmp
# build rtl
DYLD_LIBRARY_PATH=${BUILDROOT}/host/lib/rtl ${BUILDBIN}/flx_build_rtl \
--target-dir=${BUILDROOT} --target-bin=iphonesimulator --static --noexes
iphoneos:
# prepare directory
${BUILDBIN}/flx_build_prep --target-dir=${BUILDROOT} --target-bin=iphoneos --source-dir=${BUILDROOT} \
--source-bin=host --clean-target-bin-dir --copy-compiler --copy-pkg-db \
--copy-config-headers --toolchain=toolchain_iphoneos --debug
rm -rf build/rtl-tmp
# build rtl
DYLD_LIBRARY_PATH=${BUILDROOT}/host/lib/rtl ${BUILDBIN}/flx_build_rtl \
--target-dir=${BUILDROOT} --target-bin=iphoneos --static --noexes
#
# regression test on release image
#
test-dir:
mkdir -p ${BUILDROOT}/test
${BUILDBIN}/flx_tangle --indir=${BUILDROOT}/share/src/test --outdir=${BUILDROOT}/test
for file in src/test/regress/rt/*.fdoc; do ${BUILDBIN}/flx_iscr $$file ${BUILDROOT}/test; done
unit-dir:
mkdir -p ${BUILDROOT}/test/unit/projection
${BUILDBIN}/flx_tangle --indir=${BUILDROOT}/share/src/test/unit/projection \
--outdir=${BUILDROOT}/test/unit/projection
perf-dir:
mkdir -p ${BUILDROOT}/test/perf
${BUILDBIN}/flx_tangle --indir=${BUILDROOT}/share/src/test/perf \
--outdir=${BUILDROOT}/test/perf
tutopt-dir:
mkdir -p ${BUILDROOT}/tutopt
${BUILDBIN}/flx_tangle --indir=${BUILDROOT}/share/src/web/tutopt --outdir=${BUILDROOT}/test/tutopt
for file in src/web/tutopt/*.fdoc; do [ -e "$file" ] || break; ${BUILDBIN}/flx_iscr $$file ${BUILDROOT}/test/tutopt; done
tut-dir:
mkdir -p ${BUILDROOT}/tut
${BUILDBIN}/flx_tangle --linenos --indir=src/web/tut --outdir=${BUILDROOT}/test/tut
for file in src/web/tut/*.fdoc; do ${BUILDBIN}/flx_iscr $$file ${BUILDROOT}/test/tut; done
extras-check:
-${BUILDBIN}/flx --felix=build.fpc --usage=prototype --expect --nonstop --indir=${BUILDROOT}/test/extras --regex='.*\.flx' ${BUILDROOT}/test
regress-check: test-dir
# ============================================================
#
# RUNNING REGRESSION TESTS
#
# ============================================================
-${BUILDBIN}/flx --felix=build.fpc --usage=prototype --expect --nonstop --indir=${BUILDROOT}/test/regress/rt --regex='.*\.flx' ${BUILDROOT}/test
unit-check: unit-dir
# ============================================================
#
# RUNNING UNIT TESTS
#
# ============================================================
-${BUILDBIN}/flx --felix=build.fpc --usage=prototype --expect --input \
--nonstop --indir=${BUILDROOT}/test/unit/projection --regex='.*\.flx' ${BUILDROOT}/test/unit/projection
perf-check: perf-dir
# ============================================================
#
# RUNNING PERFORMANCE TESTS
#
# ============================================================
-${BUILDBIN}/flx --felix=build.fpc --usage=prototype --expect --input \
--nonstop --indir=${BUILDROOT}/test/perf --regex='.*\.flx' ${BUILDROOT}/test/perf
tut-check: tut-dir
# ============================================================
#
# CHECKING CORRECTNESS OF TUTORIAL EXAMPLES
#
# ============================================================
-${BUILDBIN}/flx --felix=build.fpc --usage=prototype --expect --input --nonstop --indir=${BUILDROOT}/test/tut --regex='.*\.flx' ${BUILDROOT}/test/tut
tutopt-check: tutopt-dir
#
# ============================================================
#
# TESTING OPTIONAL COMPONENTS
#
# Tests are expected to fail if the relevant third party
# support is not available or Felix is not properly configured
# to use it.
# ============================================================
#
-FLX_INSTALL_DIR=${BUILDROOT} ${BUILDBIN}/flx --felix=build.fpc \
--usage=prototype --expect --input --nonstop \
--indir=${BUILDROOT}/test/tutopt --regex='.*\.flx' ${BUILDROOT}/test/tutopt
test: unit-check regress-check tut-check perf-check tutopt-check extras-check
fresh-test: src test
install:
mkdir -p ${PREFIX}'/bin'
mkdir -p ${PREFIX}'/host'
mkdir -p ${PREFIX}'/lib'
mkdir -p ${PREFIX}'/share'
rm -rf ${INSTALLDIR}
${BUILDBIN}/flx_cp ${BUILDROOT}/host '(.*)' ${INSTALLDIR}'/host/$${1}'
${BUILDBIN}/flx_cp ${BUILDROOT}/share '(.*)' ${INSTALLDIR}'/share/$${1}'
${BUILDBIN}/flx_cp ${BUILDROOT} '(VERSION)' ${INSTALLDIR}'/$${1}'
${BUILDBIN}/flx_cp ${BUILDBIN} '(flx)' ${EXECPREFIX}'/$${1}'
${BUILDBIN}/flx_cp speed/ '(.*)' ${INSTALLDIR}'/speed/$${1}'
rm -f ${INSTALLROOT}/felix-latest
ln -s felix-${VERSION} ${INSTALLROOT}/felix-latest
ln -sfn ${INSTALLROOT}/felix-latest/host/* ${PREFIX}/host/
ln -sfn ${INSTALLROOT}/felix-latest/share/* ${PREFIX}/share/
macosxfpcs:
build/release/host/bin/flx_build_prep --debug --target-dir=build/release --target-bin=host --configure --compiler=clang --os=macosx --bits=64
.PHONY : test extras bootstrap configure packages grammar
.PHONY : doc install websites-linux release install-bin
.PHONY : copy-doc gen-doc gendoc fbuild speed tarball
.PHONY : weblink flx tools web-plugins toolchain-plugins rtl copy lib
.PHONY : sdltest src do-fbuild clean-fbuild uproot