source: android/jni/build.sh @ e232a64

Last change on this file since e232a64 was e232a64, checked in by zzz <zzz@…>, 9 years ago

android: fix gmp configure args

  • Property mode set to 100755
File size: 2.2 KB
RevLine 
[173343e]1#
2# build GMP and libjbigi.so using the Android tools directly
3#
[e232a64]4
5# uncomment to skip
6# exit 0
7
[173343e]8THISDIR=$(realpath $(dirname $(which $0)))
9cd $THISDIR
10export NDK=$(realpath ../../../android-ndk-r5b/)
11
[e232a64]12#
13# API level, must match that in ../AndroidManifest.xml
14#
[173343e]15LEVEL=3
16ARCH=arm
17export SYSROOT=$NDK/platforms/android-$LEVEL/arch-$ARCH/
18export AABI=arm-linux-androideabi-4.4.3
19export SYSTEM=linux-x86
20export BINPREFIX=arm-linux-androideabi-
21export CC="$NDK/toolchains/$AABI/prebuilt/$SYSTEM/bin/${BINPREFIX}gcc --sysroot=$SYSROOT"
22
23#echo "CC is $CC"
24
25JBIGI=$(realpath ../../core/c/jbigi)
[e232a64]26GMPVER=4.3.2
[173343e]27GMP=$JBIGI/gmp-$GMPVER
28
29if [ ! -d $GMP ]
30then
31        echo "Source dir for GMP version $GMPVER not found in $GMP"
32        echo "Install it there or change GMPVER and/or GMP in this script"
33        exit 1
34fi
35
36LIBFILE=$PWD/libjbigi.so
37if [ -f $LIBFILE ]
38then
39        echo "$LIBFILE exists, nothing to do here"
40        echo "If you wish to force a recompile, delete it"
41        exit 0
42fi
43
44mkdir -p build
45cd build
46
47# we must set both build and host, so that the configure
48# script will set cross_compile=yes, so that it
49# won't attempt to run the a.out files
50if [ ! -f config.status ]
51then
52        echo "Configuring GMP..."
[e232a64]53        $GMP/configure --with-pic --build=x86-none-linux --host=armv5-eabi-linux || exit 1
[173343e]54fi
55
56echo "Building GMP..."
57make || exit 1
58
59export JAVA_HOME=$(dirname $(dirname $(realpath $(which javac))))
60if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
61    echo "Cannot find jni.h! Looked in '$JAVA_HOME/include/jni.h'"
62    echo "Please set JAVA_HOME to a java home that has the JNI"
63    exit 1
64fi
65
66COMPILEFLAGS="-fPIC -Wall"
67INCLUDES="-I. -I$JBIGI/jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
68LINKFLAGS="-shared -Wl,-soname,libjbigi.so,--fix-cortex-a8"
69
70echo "Building jbigi lib that is statically linked to GMP"
71STATICLIBS=".libs/libgmp.a"
72
73echo "Compiling C code..."
74rm -f jbigi.o $LIBFILE
75echo "$CC -c $COMPILEFLAGS $INCLUDES $JBIGI/jbigi/src/jbigi.c"
76$CC -c $COMPILEFLAGS $INCLUDES $JBIGI/jbigi/src/jbigi.c || exit 1
77echo "$CC $LINKFLAGS $INCLUDES $INCLUDELIBS -o $LIBFILE jbigi.o $STATICLIBS"
78$CC $LINKFLAGS $INCLUDES $INCLUDELIBS -o $LIBFILE jbigi.o $STATICLIBS || exit 1
79
80ls -l $LIBFILE || exit 1
81
82
83echo 'Built successfully'
Note: See TracBrowser for help on using the repository browser.