-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake.sh
More file actions
executable file
·622 lines (586 loc) · 22.8 KB
/
Copy pathmake.sh
File metadata and controls
executable file
·622 lines (586 loc) · 22.8 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
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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
#!/bin/bash
set -e;
set -u;
set +m;
if [ "$#" -lt 1 ]; then
echo "Usage: $0 target component [component ...]" >&2;
echo " $0 [dist]clean" >&2;
echo 'Fetch/build SDK components for target.' >&2;
echo '' >&2;
echo 'Supported targets:' >&2;
echo ' all-linux-gnu' >&2;
echo ' armel-linux-gnu' >&2;
echo ' armhf-linux-gnu' >&2;
echo ' arm64-linux-gnu' >&2;
echo ' x86-linux-gnu' >&2;
echo ' x86_64-linux-gnu' >&2;
echo '' >&2;
echo ' all-linux-musl' >&2;
echo ' armel-linux-musl' >&2;
echo ' arm64-linux-musl' >&2;
echo ' x86-linux-musl' >&2;
echo ' x86_64-linux-musl' >&2;
echo '' >&2;
echo ' all-windows' >&2;
echo ' armhf-windows' >&2;
echo ' arm64-windows' >&2;
echo ' x86-windows' >&2;
echo ' x86_64-windows' >&2;
echo '' >&2;
echo 'Supported components:' >&2;
echo ' all' >&2;
echo ' libc' >&2;
echo ' libc++' >&2;
echo ' ncurses' >&2;
exit 1;
fi;
self="./$(basename "$0")";
cd "$(dirname "$0")";
root="$(pwd)";
target="$1";
shift;
arch='none';
mode='unknown';
case "$target" in
clean)
if [ -d aux ]; then
find aux -depth 2 -type d -print0 | xargs -0 -n 1 make clean -C;
fi;
if [ -e build ]; then
echo 'rm -rf build';
rm -rf build;
fi;
exit 0;
;;
distclean)
if [ -e aux ]; then
echo 'rm -rf aux';
rm -rf aux;
fi;
if [ -e build ]; then
echo 'rm -rf build';
rm -rf build;
fi;
if [ -e cache ]; then
echo 'rm -rf cache';
rm -rf cache;
fi;
exit 0;
;;
all-linux-gnu)
for arch in armel armhf arm64 x86 x86_64; do
"$self" "$arch-linux-gnu" "$@";
done;
exit 0;
;;
*-linux-gnu)
if ! hash curl &>/dev/null; then
echo 'Need curl.' >&2;
exit 1;
fi;
mode='deb';
arch="${target%-linux-gnu}";
;;
all-linux-musl)
for arch in armel arm64 x86 x86_64; do
"$self" "$arch-linux-musl" "$@";
done;
exit 0;
;;
*-linux-musl)
mode='build-linux';
arch="${target%-linux-musl}";
;;
all-windows)
for arch in armhf arm64 x86 x86_64; do
"$self" "$arch-windows" "$@";
done;
exit 0;
;;
*-windows)
mode='build-windows';
arch="${target%-windows}";
;;
# Undocumented
all-linux-gnu-dev)
for arch in arm64 x86_64; do
"$self" "$arch-linux-gnu-dev" "$@";
done;
exit 0;
;;
*-linux-gnu-dev)
if ! hash curl &>/dev/null; then
echo 'Need curl.' >&2;
exit 1;
fi;
mode='deb';
arch="${target%-linux-gnu-dev}-dev";
;;
*)
echo "Unsupported target: $target" >&2;
exit 1;
;;
esac;
if [ "$#" -lt 1 ]; then
echo "No components given." >&2;
exit 1;
fi;
if [ -z "${NUM_JOBS+x}" ]; then
NUM_JOBS='';
fi;
install_kernel_headers()
{
pushd "$1" >/dev/null;
find . -name '*.h' | while read -r; do
f="$2/$REPLY";
mkdir -p "$(dirname "$f")";
sed -E 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g;s/__attribute_const__([ \t]|$)/\1/g;s@^#include <linux/compiler.h>@@;s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g;s/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g;s@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' "$REPLY" | unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ -o "$f" || if [ "$?" -eq 2 ]; then exit 1; fi;
done;
popd >/dev/null;
}
prefix="build/$target";
case "$mode" in
build-linux)
if ! [ -z "${LLVM_CONFIG+x}" ]; then
bindir="$("$LLVM_CONFIG" --bindir)";
if [ -z "${CLANG+x}" ]; then
CLANG="$bindir/clang";
fi;
if [ -z "${CLANGXX+x}" ]; then
CLANGXX="$bindir/clang++";
fi;
if [ -z "${LLD+x}" ]; then
LLD="$bindir/ld.lld";
fi;
if [ -z "${AR+x}" ]; then
AR="$bindir/llvm-ar";
fi;
if [ -z "${RANLIB+x}" ]; then
RANLIB="$bindir/llvm-ranlib";
fi;
else
LLVM_CONFIG='llvm-config';
fi;
if [ -z "${CLANG+x}" ]; then
CLANG='clang';
fi;
if [ -z "${CLANGXX+x}" ]; then
CLANGXX='clang++';
fi;
if [ -z "${LLD+x}" ]; then
LLD="lld";
fi;
if [ -z "${AR+x}" ]; then
AR='llvm-ar';
fi;
if [ -z "${RANLIB+x}" ]; then
RANLIB='llvm-ranlib';
fi;
ARCH_FLAGS=();
case "$arch" in
armel)
triplet='armv6-linux-musleabi';
abi_triplet='arm-linux-musleabi';
;;
arm64)
triplet='aarch64-linux-musl';
abi_triplet="$triplet";
;;
x86)
triplet='i386-linux-musl';
abi_triplet="$triplet";
ARCH_FLAGS+=('-march=i486');
;;
x86_64)
triplet='x86_64-linux-musl';
abi_triplet="$triplet";
;;
*)
echo "Unsupported architecture: $arch" >&2;
exit 1;
;;
esac;
CC_FLAGS=('-O3' "--target=$triplet");
LD_FLAGS=("-fuse-ld=$LLD");
CFG_FLAGS=("--host=$triplet" "--prefix=$root/$prefix");
# Must be after --target
if [ "${#ARCH_FLAGS}" -gt 0 ]; then
CC_FLAGS+=("${ARCH_FLAGS[@]}");
fi;
# Must be after target and arch
CC_FLAGS+=('-flto' "--sysroot=$root/$prefix");
CXX_FLAGS=("${CC_FLAGS[@]}");
if ! [ -z "${CFLAGS+x}" ]; then
CC_FLAGS+=($CFLAGS); # no quotes
fi;
if ! [ -z "${CXXFLAGS+x}" ]; then
CXX_FLAGS+=($CXXFLAGS); # no quotes
fi;
if ! [ -z "${LDFLAGS+x}" ]; then
LD_FLAGS+=($LDFLAGS); # no quotes
fi;
CRT_FLAGS=('--rtlib=compiler-rt' "-resource-dir=$root/$prefix/lib/clang");
components=("$@");
if [ "${#components[@]}" -eq 1 ] && [ "${components[0]}" = 'all' ]; then
components=('libc' 'libc++' 'ncurses');
fi;
for component in "${components[@]}"; do
case "$component" in
libc)
# Kernel headers
echo 'Installing kernel headers...';
install_kernel_headers 'src/linux/include/uapi' "../../../../$prefix/include";
case "$arch" in
armel)
folder='arm';
;;
arm64)
folder='arm64';
;;
x86|x86_64)
folder='x86';
;;
esac;
install_kernel_headers "src/linux/arch/$folder/include/uapi" "../../../../../../$prefix/include/$abi_triplet";
# Fix up symlinks
pushd "$prefix/include" >/dev/null;
ln -sf "$abi_triplet/asm" 'asm';
cd "$abi_triplet/asm";
find '../../asm-generic' -name '*.h' | while read -r; do
if [ "${REPLY:0:18}" != '../../asm-generic/' ]; then
echo "Error: 'find' output starts with invalid prefix." >&2;
exit 1;
fi;
f="${REPLY:18}";
if ! [ -e "$f" ]; then
ln -s "$REPLY" "$f";
fi;
done;
popd >/dev/null;
# Musl
mkdir -p "aux/$target/musl";
pushd "aux/$target/musl" >/dev/null;
../../../src/musl/configure --enable-static --disable-shared "${CFG_FLAGS[@]}" CC="$CLANG" CFLAGS="${CC_FLAGS[*]}" AR="$AR" RANLIB="$RANLIB";
make "-j$NUM_JOBS";
make install;
popd >/dev/null;
# Compiler-rt
mkdir -p "aux/$target/compiler-rt";
pushd "aux/$target/compiler-rt" >/dev/null;
cmake ../../../src/llvm/compiler-rt \
-DCMAKE_INSTALL_PREFIX:PATH="$root/$prefix/lib/clang" \
-DCMAKE_TRY_COMPILE_TARGET_TYPE:STRING=STATIC_LIBRARY \
-DCMAKE_SYSTEM_NAME:STRING='Linux' \
-DCMAKE_C_COMPILER:STRING="$CLANG" \
-DCMAKE_C_COMPILER_TARGET:STRING="$abi_triplet" \
-DCMAKE_C_FLAGS:STRING="${CC_FLAGS[*]}" \
-DCMAKE_ASM_COMPILER:STRING="$CLANG" \
-DCMAKE_ASM_COMPILER_TARGET:STRING="$abi_triplet" \
-DCMAKE_ASM_FLAGS:STRING="${CC_FLAGS[*]}" \
-DCMAKE_EXE_LINKER_FLAGS:STRING="${LD_FLAGS[*]}" \
-DCMAKE_AR:STRING="$AR" \
-DCMAKE_RANLIB:STRING="$RANLIB" \
-DLLVM_CONFIG_PATH:STRING="$LLVM_CONFIG" \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY:BOOL='ON' \
-DCOMPILER_RT_BUILD_BUILTINS:BOOL='ON' \
-DCOMPILER_RT_BUILD_CRT:BOOL='ON' \
-DCOMPILER_RT_BUILD_SANITIZERS:BOOL='OFF' \
-DCOMPILER_RT_BUILD_CTX_PROFILE:BOOL='OFF' \
-DCOMPILER_RT_BUILD_XRAY:BOOL='OFF' \
-DCOMPILER_RT_BUILD_LIBFUZZER:BOOL='OFF' \
-DCOMPILER_RT_BUILD_PROFILE:BOOL='OFF' \
-DCOMPILER_RT_BUILD_MEMPROF:BOOL='OFF' \
-DCOMPILER_RT_BUILD_ORC:BOOL='OFF' \
-DCOMPILER_RT_BUILD_GWP_ASAN:BOOL='OFF' \
-DCOMPILER_RT_ENABLE_CET:BOOL='OFF' \
;
make "-j$NUM_JOBS";
make install;
popd >/dev/null;
;;
libc++)
mkdir -p "aux/$target/libcxx";
pushd "aux/$target/libcxx" >/dev/null;
cmake ../../../src/llvm/runtimes \
-DCMAKE_INSTALL_PREFIX:PATH="$root/$prefix" \
-DCMAKE_TRY_COMPILE_TARGET_TYPE:STRING=STATIC_LIBRARY \
-DCMAKE_SYSTEM_NAME:STRING='Linux' \
-DCMAKE_C_COMPILER:STRING="$CLANG" \
-DCMAKE_C_COMPILER_TARGET:STRING="$abi_triplet" \
-DCMAKE_C_FLAGS:STRING="${CC_FLAGS[*]}" \
-DCMAKE_CXX_COMPILER:STRING="$CLANGXX" \
-DCMAKE_CXX_COMPILER_TARGET:STRING="$abi_triplet" \
-DCMAKE_CXX_FLAGS:STRING="${CXX_FLAGS[*]}" \
-DCMAKE_ASM_COMPILER:STRING="$CLANG" \
-DCMAKE_ASM_COMPILER_TARGET:STRING="$abi_triplet" \
-DCMAKE_ASM_FLAGS:STRING="${CC_FLAGS[*]}" \
-DCMAKE_EXE_LINKER_FLAGS:STRING="${LD_FLAGS[*]}" \
-DCMAKE_AR:STRING="$AR" \
-DCMAKE_RANLIB:STRING="$RANLIB" \
-DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;libcxx" \
-DLIBUNWIND_ENABLE_SHARED:BOOL='OFF' \
-DLIBUNWIND_ENABLE_STATIC:BOOL='ON' \
-DLIBUNWIND_USE_COMPILER_RT:BOOL='ON' \
-DLIBCXXABI_ENABLE_SHARED:BOOL='OFF' \
-DLIBCXXABI_ENABLE_STATIC:BOOL='ON' \
-DLIBCXXABI_USE_COMPILER_RT:BOOL='ON' \
-DLIBCXXABI_USE_LLVM_UNWINDER:BOOL='ON' \
-DLIBCXXABI_ENABLE_STATIC_UNWINDER:BOOL='ON' \
-DLIBCXX_ENABLE_SHARED:BOOL='OFF' \
-DLIBCXX_ENABLE_STATIC:BOOL='ON' \
-DLIBCXX_USE_COMPILER_RT:BOOL='ON' \
-DLIBCXX_HAS_MUSL_LIBC:BOOL='ON' \
-DLIBCXX_INCLUDE_BENCHMARKS:BOOL='OFF' \
-DLIBCXX_HARDENING_MODE:STRING='fast' \
;
make "-j$NUM_JOBS";
make install;
popd >/dev/null;
;;
ncurses)
mkdir -p "aux/$target/ncurses";
pushd "aux/$target/ncurses" >/dev/null;
../../../src/ncurses/configure --without-shared --without-debug --with-normal --enable-overwrite --without-ada --without-cxx --without-cxx-binding --disable-db-install --without-manpages --without-progs --without-tack --without-tests --disable-pc-files "${CFG_FLAGS[@]}" CC="$CLANG" CFLAGS="${CC_FLAGS[*]}" CPPFLAGS="${CC_FLAGS[*]}" LDFLAGS="${LD_FLAGS[*]} ${CRT_FLAGS[*]}" AR="$AR" RANLIB="$RANLIB";
make "-j$NUM_JOBS";
make install;
popd >/dev/null;
;;
*)
echo "Unsupported component: $component" >&2;
exit 1;
;;
esac;
done;
;;
build-windows)
if ! [ -z "${LLVM_CONFIG+x}" ]; then
bindir="$("$LLVM_CONFIG" --bindir)";
if [ -z "${CLANG+x}" ]; then
CLANG="$bindir/clang";
fi;
if [ -z "${CLANGXX+x}" ]; then
CLANGXX="$bindir/clang++";
fi;
if [ -z "${LLD+x}" ]; then
LLD="$bindir/ld.lld";
fi;
if [ -z "${AS+x}" ]; then
AS="$bindir/as";
fi;
if [ -z "${AR+x}" ]; then
AR="$bindir/llvm-ar";
fi;
if [ -z "${RANLIB+x}" ]; then
RANLIB="$bindir/llvm-ranlib";
fi;
if [ -z "${STRIP+x}" ]; then
STRIP="$bindir/llvm-strip";
fi;
if [ -z "${DLLTOOL+x}" ]; then
DLLTOOL="$bindir/llvm-dlltool";
fi;
if [ -z "${RC+x}" ]; then
RC="$bindir/llvm-windres";
fi;
else
LLVM_CONFIG='llvm-config';
fi;
if [ -z "${CLANG+x}" ]; then
CLANG='clang';
fi;
if [ -z "${CLANGXX+x}" ]; then
CLANGXX='clang++';
fi;
if [ -z "${LLD+x}" ]; then
LLD="lld";
fi;
if [ -z "${AS+x}" ]; then
AS='llvm-as';
fi;
if [ -z "${AR+x}" ]; then
AR='llvm-ar';
fi;
if [ -z "${RANLIB+x}" ]; then
RANLIB='llvm-ranlib';
fi;
if [ -z "${STRIP+x}" ]; then
STRIP='llvm-strip';
fi;
if [ -z "${DLLTOOL+x}" ]; then
DLLTOOL='llvm-dlltool';
fi;
if [ -z "${RC+x}" ]; then
RC='llvm-windres';
fi;
ARCH_FLAGS=();
case "$arch" in
armhf)
triplet='armv7-w64-mingw32';
abi_triplet='arm-w64-mingw32';
;;
arm64)
triplet='aarch64-w64-mingw32';
abi_triplet="$triplet";
;;
x86)
triplet='i686-w64-mingw32';
abi_triplet="$triplet";
;;
x86_64)
triplet='x86_64-w64-mingw32';
abi_triplet="$triplet";
;;
*)
echo "Unsupported architecture: $arch" >&2;
exit 1;
;;
esac;
CC_FLAGS=('-O3' "--target=$triplet");
LD_FLAGS=("-fuse-ld='$LLD'");
CFG_FLAGS=("--host=$triplet" "--prefix=$root/$prefix");
# Must be after --target
if [ "${#ARCH_FLAGS}" -gt 0 ]; then
CC_FLAGS+=("${ARCH_FLAGS[@]}");
fi;
# Must be after target and arch
CC_FLAGS+=('-flto' "--sysroot=$root/$prefix");
CXX_FLAGS=("${CC_FLAGS[@]}");
if ! [ -z "${CFLAGS+x}" ]; then
CC_FLAGS+=($CFLAGS); # no quotes
fi;
if ! [ -z "${CXXFLAGS+x}" ]; then
CXX_FLAGS+=($CXXFLAGS); # no quotes
fi;
if ! [ -z "${LDFLAGS+x}" ]; then
LD_FLAGS+=($LDFLAGS); # no quotes
fi;
CRT_FLAGS=('--rtlib=compiler-rt' "-resource-dir=$root/$prefix/lib/clang" "-I$("$CLANG" -print-resource-dir)/include");
components=("$@");
if [ "${#components[@]}" -eq 1 ] && [ "${components[0]}" = 'all' ]; then
components=('libc'); # TODO: libc++ ncurses
fi;
for component in "${components[@]}"; do
case "$component" in
libc)
# MinGW
mkdir -p "aux/$target/mingw-hdr";
pushd "aux/$target/mingw-hdr" >/dev/null;
../../../src/mingw/configure --with-headers --without-crt "${CFG_FLAGS[@]}" CC="$CLANG" CFLAGS="${CC_FLAGS[*]}" CXX="$CLANGXX" CXXFLAGS="${CXX_FLAGS[*]}" AS="$AS" AR="$AR" RANLIB="$RANLIB" STRIP="$STRIP" DLLTOOL="$DLLTOOL" RC="$RC" RCFLAGS="--target=$abi_triplet --include-dir=$root/$prefix/include";
make "-j$NUM_JOBS";
make install;
popd >/dev/null;
mkdir -p "aux/$target/mingw-crt";
pushd "aux/$target/mingw-crt" >/dev/null;
../../../src/mingw/configure --without-headers --with-crt --with-libraries=winpthreads --enable-static --disable-shared "${CFG_FLAGS[@]}" CC="$CLANG" CFLAGS="${CC_FLAGS[*]}" CXX="$CLANGXX" CXXFLAGS="${CXX_FLAGS[*]}" AS="$AS" AR="$AR" RANLIB="$RANLIB" STRIP="$STRIP" DLLTOOL="$DLLTOOL" RC="$RC" RCFLAGS="--target=$abi_triplet --include-dir=$root/$prefix/include";
make "-j$NUM_JOBS";
make install;
popd >/dev/null;
# Compiler-rt
mkdir -p "aux/$target/compiler-rt";
pushd "aux/$target/compiler-rt" >/dev/null;
cmake ../../../src/llvm/compiler-rt \
-DCMAKE_INSTALL_PREFIX:PATH="$root/$prefix/lib/clang" \
-DCMAKE_TRY_COMPILE_TARGET_TYPE:STRING=STATIC_LIBRARY \
-DCMAKE_SYSTEM_NAME:STRING='Windows' \
-DCMAKE_STATIC_LIBRARY_PREFIX_C:STRING='lib' \
-DCMAKE_STATIC_LIBRARY_PREFIX_CXX:STRING='lib' \
-DCMAKE_STATIC_LIBRARY_SUFFIX_C:STRING='.a' \
-DCMAKE_STATIC_LIBRARY_SUFFIX_CXX:STRING='.a' \
-DCMAKE_C_COMPILER:STRING="$CLANG" \
-DCMAKE_C_COMPILER_TARGET:STRING="$abi_triplet" \
-DCMAKE_C_FLAGS:STRING="${CC_FLAGS[*]}" \
-DCMAKE_ASM_COMPILER:STRING="$CLANG" \
-DCMAKE_ASM_COMPILER_TARGET:STRING="$abi_triplet" \
-DCMAKE_ASM_FLAGS:STRING="${CC_FLAGS[*]}" \
-DCMAKE_EXE_LINKER_FLAGS:STRING="${LD_FLAGS[*]}" \
-DCMAKE_AR:STRING="$AR" \
-DCMAKE_RANLIB:STRING="$RANLIB" \
-DLLVM_CONFIG_PATH:STRING="$LLVM_CONFIG" \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY:BOOL='ON' \
-DCOMPILER_RT_BUILD_BUILTINS:BOOL='ON' \
-DCOMPILER_RT_BUILD_CRT:BOOL='ON' \
-DCOMPILER_RT_BUILD_SANITIZERS:BOOL='OFF' \
-DCOMPILER_RT_BUILD_CTX_PROFILE:BOOL='OFF' \
-DCOMPILER_RT_BUILD_XRAY:BOOL='OFF' \
-DCOMPILER_RT_BUILD_LIBFUZZER:BOOL='OFF' \
-DCOMPILER_RT_BUILD_PROFILE:BOOL='OFF' \
-DCOMPILER_RT_BUILD_MEMPROF:BOOL='OFF' \
-DCOMPILER_RT_BUILD_ORC:BOOL='OFF' \
-DCOMPILER_RT_BUILD_GWP_ASAN:BOOL='OFF' \
-DCOMPILER_RT_ENABLE_CET:BOOL='OFF' \
-DCOMPILER_RT_BUILTINS_ENABLE_PIC:BOOL='OFF' \
;
make "-j$NUM_JOBS";
make install;
popd >/dev/null;
;;
*)
echo "Unsupported component: $component" >&2;
exit 1;
;;
esac;
done;
;;
deb)
mkdir -p "$prefix";
mkdir -p "cache";
components=("$@");
if [ "${#components[@]}" -eq 1 ] && [ "${components[0]}" = 'all' ]; then
lists=("res/packages-"*"-$arch.txt");
else
lists=("${components[@]/#/res/packages-}");
lists=("${lists[@]/%/-$arch.txt}");
fi;
for list in "${lists[@]}"; do
# http://archive.debian.org/debian-archive/debian/dists/jessie/main/
# http://archive.debian.org/debian-archive/debian/dists/bullseye/main/
if ! [ -e "$list" ]; then
echo "Error: package list $list doesn't exist." >&2;
exit 1;
fi;
debs=();
while read -r; do
url="$REPLY";
deb="$(basename "$url")";
echo "$deb";
deb="cache/$deb";
if ! [ -e "$deb" ]; then
curl -s -S -f -L --connect-timeout 3 --speed-time 30 --speed-limit 131072 -o "$deb" "$url" &
fi;
debs+=("$deb");
done <"$list";
wait;
for deb in "${debs[@]}"; do
data="$(ar t "$deb" | egrep '^data.tar.\w+$')";
if [ "$(wc -l <<<"$data")" -ne 1 ]; then
echo "Error: deb $deb does not contain exactly one data.tar.* file." >&2;
exit 1;
fi;
flag='';
case "${data#data.tar.}" in
bz2)
flag='-j';
;;
gz)
flag='-z';
;;
lzma)
flag='--lzma';
;;
xz)
flag='-J';
;;
*)
echo "Error: unknown compression format in $data";
;;
esac;
ar p "$deb" "$data" | tar -x "$flag" -f - -C "$prefix";
done;
done;
tools/rewrite-symlinks.sh "$prefix" >/dev/null;
;;
*)
echo "Bug: unknown mode $mode" >&2;
exit 1;
;;
esac;