Merge 'remotes/trunk'
[0ad.git] / build / android / setup-libs.sh
blobbf8c049402a8999f59d92e124d954d3444e7e575
1 #!/bin/bash
3 set -e
4 set -o nounset
6 ANDROID=$HOME/android
7 NDK=$ANDROID/android-ndk-r8-crystax-1
8 SDK=$ANDROID/android-sdk-linux
9 TOOLCHAIN=$ANDROID/toolchain-0ad
11 build_toolchain=true
13 build_boost=true
14 build_curl=true
15 build_libpng=true
16 build_libjpeg=true
17 build_libxml2=true
18 build_enet=true
19 build_js185=true
21 JOBS=${JOBS:="-j4"}
23 SYSROOT=$TOOLCHAIN/sysroot
24 export PATH=$TOOLCHAIN/bin:$PATH
25 CFLAGS="-mandroid -mthumb -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp"
27 mkdir -p files
28 pushd files
30 if [ ! -e boost_1_45_0.tar.bz2 ]; then
31 wget http://downloads.sourceforge.net/project/boost/boost/1.45.0/boost_1_45_0.tar.bz2
34 if [ ! -e curl-7.33.0.tar.bz2 ]; then
35 wget http://curl.haxx.se/download/curl-7.33.0.tar.bz2
38 if [ ! -e MysticTreeGames-Boost-for-Android-70838fc.tar.gz ]; then
39 wget https://github.com/MysticTreeGames/Boost-for-Android/tarball/70838fcfba930646cac724a77f5c626e930431f6 -O MysticTreeGames-Boost-for-Android-70838fc.tar.gz
42 if [ ! -e enet-1.3.3.tar.gz ]; then
43 wget http://enet.bespin.org/download/enet-1.3.3.tar.gz
46 if [ ! -e js185-1.0.0.tar.gz ]; then
47 cp ../../../libraries/source/spidermonkey/js185-1.0.0.tar.gz .
50 if [ ! -e libjpeg-turbo-1.3.0.tar.gz ]; then
51 wget http://downloads.sourceforge.net/project/libjpeg-turbo/1.3.0/libjpeg-turbo-1.3.0.tar.gz
54 if [ ! -e libpng-1.5.8.tar.xz ]; then
55 wget http://prdownloads.sourceforge.net/libpng/libpng-1.5.8.tar.xz
58 if [ ! -e libxml2-2.7.8.tar.gz ]; then
59 wget ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz
62 popd
65 if [ "$build_toolchain" = "true" ]; then
67 rm -r $TOOLCHAIN || true
68 $NDK/build/tools/make-standalone-toolchain.sh --platform=android-14 --toolchain=arm-linux-androideabi-4.6 --install-dir=$TOOLCHAIN --system=linux-x86_64
70 mkdir -p $SYSROOT/usr/local
72 # Set up some symlinks to make the SpiderMonkey build system happy
73 ln -sfT ../platforms $NDK/build/platforms
74 for f in $TOOLCHAIN/bin/arm-linux-androideabi-*; do
75 ln -sf $f ${f/arm-linux-androideabi-/arm-eabi-}
76 done
78 # Set up some symlinks for the typical autoconf-based build systems
79 for f in $TOOLCHAIN/bin/arm-linux-androideabi-*; do
80 ln -sf $f ${f/arm-linux-androideabi-/arm-linux-eabi-}
81 done
85 mkdir -p temp
87 if [ "$build_boost" = "true" ]; then
88 rm -rf temp/MysticTreeGames-Boost-for-Android-70838fc
89 tar xvf files/MysticTreeGames-Boost-for-Android-70838fc.tar.gz -C temp/
90 cp files/boost_1_45_0.tar.bz2 temp/MysticTreeGames-Boost-for-Android-70838fc/
91 patch temp/MysticTreeGames-Boost-for-Android-70838fc/build-android.sh < boost-android-build.patch
92 pushd temp/MysticTreeGames-Boost-for-Android-70838fc
93 ./build-android.sh $TOOLCHAIN
94 cp -rv build/{include,lib} $SYSROOT/usr/local/
95 popd
98 if [ "$build_curl" = "true" ]; then
99 rm -rf temp/curl-7.33.0
100 tar xvf files/curl-7.33.0.tar.bz2 -C temp/
101 pushd temp/curl-7.33.0
102 ./configure --host=arm-linux-androideabi --with-sysroot=$SYSROOT --prefix=$SYSROOT/usr/local CFLAGS="$CFLAGS" LDFLAGS="-lm" --disable-shared
103 make -j3
104 make install
105 popd
108 if [ "$build_libpng" = "true" ]; then
109 rm -rf temp/libpng-1.5.8
110 tar xvf files/libpng-1.5.8.tar.xz -C temp/
111 pushd temp/libpng-1.5.8
112 ./configure --host=arm-linux-eabi --with-sysroot=$SYSROOT --prefix=$SYSROOT/usr/local CFLAGS="$CFLAGS"
113 make $JOBS
114 make install
115 popd
118 if [ "$build_libjpeg" = "true" ]; then
119 rm -rf temp/libjpeg-turbo-1.3.0
120 tar xvf files/libjpeg-turbo-1.3.0.tar.gz -C temp/
121 pushd temp/libjpeg-turbo-1.3.0
122 ./configure --host=arm-linux-eabi --with-sysroot=$SYSROOT --prefix=$SYSROOT/usr/local CFLAGS="$CFLAGS" LDFLAGS="-lm"
123 make $JOBS
124 make install
125 popd
128 if [ "$build_libxml2" = "true" ]; then
129 rm -rf temp/libxml2-2.7.8
130 tar xvf files/libxml2-2.7.8.tar.gz -C temp/
131 patch temp/libxml2-2.7.8/Makefile.in < libxml2-android-build.patch
132 pushd temp/libxml2-2.7.8
133 ./configure --host=arm-linux-eabi --with-sysroot=$SYSROOT --prefix=$SYSROOT/usr/local CFLAGS="$CFLAGS"
134 make $JOBS
135 make install
136 popd
139 if [ "$build_enet" = "true" ]; then
140 rm -rf temp/enet-1.3.3
141 tar xvf files/enet-1.3.3.tar.gz -C temp/
142 pushd temp/enet-1.3.3
143 ./configure --host=arm-linux-eabi --with-sysroot=$SYSROOT --prefix=$SYSROOT/usr/local CFLAGS="$CFLAGS"
144 make $JOBS
145 make install
146 popd
149 if [ "$build_js185" = "true" ]; then
150 rm -rf temp/js-1.8.5
151 tar xvf files/js185-1.0.0.tar.gz -C temp/
152 patch temp/js-1.8.5/js/src/assembler/wtf/Platform.h < js185-android-build.patch
153 pushd temp/js-1.8.5/js/src
154 CXXFLAGS="-I $TOOLCHAIN/arm-linux-androideabi/include/c++/4.4.3/arm-linux-androideabi" \
155 HOST_CXXFLAGS="-DFORCE_LITTLE_ENDIAN" \
156 ./configure \
157 --prefix=$SYSROOT/usr/local \
158 --target=arm-android-eabi \
159 --with-android-ndk=$NDK \
160 --with-android-sdk=$SDK \
161 --with-android-toolchain=$TOOLCHAIN \
162 --with-android-version=9 \
163 --disable-tests \
164 --disable-shared-js \
165 --with-arm-kuser \
166 CFLAGS="$CFLAGS"
167 make $JOBS JS_DISABLE_SHELL=1
168 make install JS_DISABLE_SHELL=1
169 popd