-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild
88 lines (69 loc) · 2.57 KB
/
build
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
#!/bin/bash
# Bomb out on any errors
set -e
# Setup the environment
export HOME=/home/admin
export PATH=$PATH:$HOME/droid/bin
export ANDROID_NDK=~/droid/android-ndk
export TARGET=/target
# Download the latest version of bash
if [ ! -f ~/bash-4.3.tar.gz ]; then
wget -O ~/bash-4.3.tar.gz http://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
fi
for ARCH_NAME in mips arm x86; do
for BIN_TYPE in nopie pie; do
# Create the output directory
mkdir -p $TARGET/$ARCH_NAME/$BIN_TYPE;
# Start each build with a fresh source copy
cd ~
rm -rf ~/bash-4.3
tar xvzf bash-4.3.tar.gz
cd bash-4.3
# Apply the Android patch
patch -p0 <~/bash-android.patch
# Apply all official patches
for PATCH in $HOME/official_patches/bash43-*; do
patch -p0 < $PATCH
done;
case "$ARCH_NAME" in
x86)
echo "Compiling for x86"
HOST=i686-linux-android
TOOLCHAIN=${ANDROID_NDK}/default-x86-toolchain
COMPILER=${TOOLCHAIN}/bin/i686-linux-android-gcc
STRIP=${TOOLCHAIN}/bin/i686-linux-android-strip
SYSROOT=${ANDROID_NDK}/platforms/android-19/arch-x86
;;
arm)
echo "Compiling for ARM"
HOST=arm-linux
TOOLCHAIN=${ANDROID_NDK}/default-arm-toolchain
COMPILER=${TOOLCHAIN}/bin/arm-linux-androideabi-gcc
STRIP=${TOOLCHAIN}/bin/arm-linux-androideabi-strip
SYSROOT=${ANDROID_NDK}/platforms/android-19/arch-arm
;;
mips)
echo "Compiling for MIPS"
HOST=mipsel-linux-android
TOOLCHAIN=${ANDROID_NDK}/default-mips-toolchain
COMPILER=${TOOLCHAIN}/bin/mipsel-linux-android-gcc
STRIP=${TOOLCHAIN}/bin/mipsel-linux-android-strip
SYSROOT=${ANDROID_NDK}/platforms/android-19/arch-mips
;;
esac
export CC="$COMPILER --sysroot=$SYSROOT"
if [ $BIN_TYPE == "pie" ]; then
export CFLAGS="-g -O2 -pie -fPIE"
# Use the default platform target for pie binaries
unset GOOGLE_PLATFORM
else
export CFLAGS="-g -O2"
export GOOGLE_PLATFORM=9
fi
./configure --host=$HOST --without-bash-malloc --disable-rpath --disable-nls
echo "#undef HAVE_GETPWENT" >> config.h
make
$STRIP bash
cp bash $TARGET/$ARCH_NAME/$BIN_TYPE/bash
done
done