-
Notifications
You must be signed in to change notification settings - Fork 212
/
build_android.sh
executable file
·80 lines (70 loc) · 1.81 KB
/
build_android.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
#!/bin/sh
# Compiles ffts for Android
# Make sure you have NDK_ROOT defined in .bashrc or .bash_profile
# Modify INSTALL_DIR to suit your situation
INSTALL_DIR="`pwd`/java/android/bin"
PLATFORM=android-8
TOOL="4.6"
case $(uname -s) in
Darwin)
CONFBUILD=i386-apple-darwin`uname -r`
HOSTPLAT=darwin-x86
;;
Linux)
CONFBUILD=x86-unknown-linux
HOSTPLAT=linux-`uname -m`
;;
*) echo $0: Unknown platform; exit
esac
case arm in
arm)
TARGPLAT=arm-linux-androideabi
ARCH=arm
CONFTARG=arm-eabi
;;
x86)
TARGPLAT=x86
ARCH=x86
CONFTARG=x86
;;
mips)
## probably wrong
TARGPLAT=mipsel-linux-android
ARCH=mips
CONFTARG=mips
;;
*) echo $0: Unknown target; exit
esac
: ${NDK_ROOT:?}
echo "Using: $NDK_ROOT/toolchains/${TARGPLAT}-${TOOL}/prebuilt/${HOSTPLAT}/bin"
export PATH="$NDK_ROOT/toolchains/${TARGPLAT}-${TOOL}/prebuilt/${HOSTPLAT}/bin/:$PATH"
export SYS_ROOT="$NDK_ROOT/platforms/${PLATFORM}/arch-${ARCH}/"
export CC="${TARGPLAT}-gcc --sysroot=$SYS_ROOT"
export LD="${TARGPLAT}-ld"
export AR="${TARGPLAT}-ar"
export RANLIB="${TARGPLAT}-ranlib"
export STRIP="${TARGPLAT}-strip"
export CFLAGS="-Os"
mkdir -p $INSTALL_DIR
./configure --enable-neon --build=${CONFBUILD} --host=${CONFTARG} --prefix=$INSTALL_DIR LIBS="-lc -lgcc"
make clean
make
make install
if [ -z "$ANDROID_HOME" ] ; then
echo ""
echo " No ANDROID_HOME defined"
echo " Android JNI interfaces will not be built"
echo
else
echo
echo "Using android_home ${ANDROID_HOME}"
echo
( cd java/android ; ${ANDROID_HOME}/tools/android update lib-project -p . ) || exit 1
( cd java/android/jni ; ${NDK_ROOT}/ndk-build V=1 ) || exit 1
( cd java/android ; ant release ) || exit 1
echo
echo "Android library project location:"
echo " `pwd`/java/android"
echo
fi
exit 0