-
Notifications
You must be signed in to change notification settings - Fork 3
/
xbuild
executable file
·59 lines (54 loc) · 956 Bytes
/
xbuild
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
#! /bin/bash
set -e
declare -a TARGETS=(
x86_64-linux-musl
aarch64-linux-musl
arm-linux-musleabi
arm-linux-musleabihf
i386-linux-musl
mips-linux-musl
mipsel-linux-musl
#mips64-linux-musl
#mips64el-linux-musl
powerpc-linux-musl
#powerpc64-linux-musl
#powerpc64le-linux-musl
#riscv32-linux-musl
#riscv64-linux-musl
)
declare -a CFLAGS=(
-Os
-flto
-fPIE
-D_FORTIFY_SOURCE=2
-pipe
-fstack-protector-strong
-fno-plt
)
declare -a LDFLAGS=(
-O1
-s
-flto
-fPIE
-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now,--icf=safe,--gc-sections
)
V=$(jq -r .version package.json)
for T in "${TARGETS[@]}"
do
O="dmon-$V-${T%-musl}"
echo "===== $O ===="
if [[ -x $O ]] ; then
echo ' -> Already built'
continue
fi
make -s clean
make -sj$(nproc) \
AR='llvm-ar' \
CC="zig cc -target $T" \
CFLAGS="${CFLAGS[*]}" \
CPPFLAGS="${CPPFLAGS[*]}"
mv dmon "$O"
llvm-strip -x --strip-unneeded "$O"
echo ' -> Done'
done
make -s clean