-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuildAndroid
executable file
·40 lines (31 loc) · 1.13 KB
/
buildAndroid
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
#!/bin/bash
# Set local variables
ANDROID_TARGET_PLATFORM=android-9
NDK_HOST_NAME=arm-linux-androideabi
NDK_STANDALONE_DIR=~/ndk-standalone-9
# Create the standalone compiler
rm -r $NDK_STANDALONE_DIR
~/android-ndk-r9d/build/tools/make-standalone-toolchain.sh --platform=$ANDROID_TARGET_PLATFORM --install-dir=$NDK_STANDALONE_DIR --toolchain=arm-linux-androideabi-clang3.4
# Add the compiler path to the path
export PATH=$NDK_STANDALONE_DIR/bin:$PATH
function BuildAndInstallAndroid
{
ARCHI=$1
if [ "$ARCHI" = "armeabi-v7a" ]; then
ARCHI_CFLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16"
ARCHI_LDFLAGS="-march=armv7-a -Wl,--fix-cortex-a8"
fi
# Set compilation flags
unset DEVROOT SDKROOT CFLAGS CC LD CPP CXX AR AS NM CXXCPP RANLIB LDFLAGS CPPFLAGS CXXFLAG
export CC=$NDK_HOST_NAME-clang
export LDFLAGS="$ARCHI_LDFLAGS"
export CFLAGS="$ARCHI_CFLAGS -O3 -std=c99"
# Configure the build
./configure --host=$NDK_HOST_NAME --prefix=/android-$ARCHI --without-zlib --enable-shared
# Perform the build and install it
make clean
make
make install DESTDIR=$(pwd)
}
BuildAndInstallAndroid armeabi
BuildAndInstallAndroid armeabi-v7a