-
Notifications
You must be signed in to change notification settings - Fork 72
/
build.sh
executable file
·90 lines (74 loc) · 3.2 KB
/
build.sh
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
#!/bin/sh
fail() { echo "Compilation failed!" ; exit 1; }
#ARCH_LIST="arm64-v8a x86_64"
ARCH_LIST="`arch`"
for ARCH in $ARCH_LIST; do
[ "$ARCH" = aarch64 ] && ARCH=arm64-v8a
echo "Building for arch $ARCH"
export ARCH=$ARCH
mkdir -p dist-$ARCH
# Debian library
false && [ -e dist-$ARCH/libandroid-shmem-disableselinux.so ] || {
gcc -ffunction-sections -fdata-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wformat -Werror=format-security -Os -DNDEBUG -fPIC \
-Iandroid-shmem -Iandroid-shmem/libancillary -D_LINUX_IPC_H -DNDEBUG \
--shared -Wl,--version-script=disableselinux/exports.txt \
android-shmem/*.c disableselinux/*.c \
-Wl,--gc-sections -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now \
-lpthread \
-o dist-$ARCH/libandroid-shmem-disableselinux.so &&
strip dist-$ARCH/libandroid-shmem-disableselinux.so \
|| fail
} || fail
continue
# Android native library
[ -e dist-$ARCH/libandroid-shmem-disableselinux.so ] || {
env ARCH=$ARCH ./setCrossEnvironment-$ARCH.sh sh -c ' \
$CC $CFLAGS -Iandroid-shmem -Iandroid-shmem/libancillary -D_LINUX_IPC_H -DNDEBUG \
android-shmem/*.c disableselinux/*.c \
--shared $LDFLAGS -Wl,--version-script=disableselinux/exports.txt \
-o dist-$ARCH/libandroid-shmem-disableselinux.so &&
$STRIP dist-$ARCH/libandroid-shmem-disableselinux.so \
' || fail
} || fail
continue # Do not bother with this crap, grab precompiled proot from https://bintray.com/termux/termux-packages-24/proot
[ -e dist-$ARCH/libdisableselinux.so ] || {
gcc -fPIC -shared disableselinux/*.c $CFLAGS $LDFLAGS -o dist-$ARCH/libdisableselinux.so && \
strip dist-$ARCH/libdisableselinux.so || fail
} || fail
[ -e dist-$ARCH/libandroid-shmem.so ] || {
cd android-shmem
make || fail
cp -f libandroid-shmem-$ARCH.so ../dist-$ARCH/libandroid-shmem.so
cd ..
} || fail
[ -e talloc-2.3.0.tar.gz ] || wget https://www.samba.org/ftp/talloc/talloc-2.3.0.tar.gz || fail
[ -e libtalloc-$ARCH.a ] || {
[ -e talloc-2.3.0 ] || tar xvzf talloc-2.3.0.tar.gz || fail
cd talloc-2.3.0
make clean
../setCrossEnvironment-$ARCH.sh \
./configure build --cross-compile --cross-answers=`pwd`/../talloc-cross-answers.txt \
--without-gettext --disable-python || fail
#env CC=arm-linux-gnueabihf-gcc CFLAGS="-flto -fpic" LD=arm-linux-gnueabihf-gcc LDFLAGS="-flto" ./configure build --cross-compile --cross-execute='qemu-arm-static /usr/arm-linux-gnueabihf/lib/ld-linux.so.3 --library-path /usr/arm-linux-gnueabihf/lib' || fail
ar rcs ../libtalloc-$ARCH.a bin/default/talloc*.o
cd ..
} || fail
[ -e dist/proot ] || {
cd proot-src
git clean -f -d -x
git checkout -f
patch -p1 < ../proot-android.patch || fail
cd src
ln -sf `which arm-linux-gnueabihf-strip` strip
ln -sf `which arm-linux-gnueabihf-objcopy` objcopy
ln -sf `which arm-linux-gnueabihf-objdump` objdump
env PATH=`pwd`:$PATH CC=arm-linux-gnueabihf-gcc \
CFLAGS="-I../../talloc-2.1.0 -Wall -Wextra -O2 -flto -fpic" \
LDFLAGS="-L../.. -ltalloc -static -flto" \
V=1 make -e || fail
rm -f strip objcopy objdump
cp proot ../../dist/
cd ../..
arm-linux-gnueabihf-strip dist/proot
} || fail
done