1 | # |
---|
2 | # build GMP and libjbigi.so using the Android tools directly |
---|
3 | # |
---|
4 | |
---|
5 | # uncomment to skip |
---|
6 | # exit 0 |
---|
7 | |
---|
8 | THISDIR=$(realpath $(dirname $(which $0))) |
---|
9 | cd $THISDIR |
---|
10 | export NDK=$(realpath ../../../android-ndk-r5b/) |
---|
11 | |
---|
12 | # |
---|
13 | # API level, must match that in ../AndroidManifest.xml |
---|
14 | # |
---|
15 | LEVEL=3 |
---|
16 | ARCH=arm |
---|
17 | export SYSROOT=$NDK/platforms/android-$LEVEL/arch-$ARCH/ |
---|
18 | export AABI=arm-linux-androideabi-4.4.3 |
---|
19 | export SYSTEM=linux-x86 |
---|
20 | export BINPREFIX=arm-linux-androideabi- |
---|
21 | export CC="$NDK/toolchains/$AABI/prebuilt/$SYSTEM/bin/${BINPREFIX}gcc --sysroot=$SYSROOT" |
---|
22 | |
---|
23 | #echo "CC is $CC" |
---|
24 | |
---|
25 | JBIGI=$(realpath ../../core/c/jbigi) |
---|
26 | GMPVER=4.3.2 |
---|
27 | GMP=$JBIGI/gmp-$GMPVER |
---|
28 | |
---|
29 | if [ ! -d $GMP ] |
---|
30 | then |
---|
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 |
---|
34 | fi |
---|
35 | |
---|
36 | LIBFILE=$PWD/libjbigi.so |
---|
37 | if [ -f $LIBFILE ] |
---|
38 | then |
---|
39 | echo "$LIBFILE exists, nothing to do here" |
---|
40 | echo "If you wish to force a recompile, delete it" |
---|
41 | exit 0 |
---|
42 | fi |
---|
43 | |
---|
44 | mkdir -p build |
---|
45 | cd 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 |
---|
50 | if [ ! -f config.status ] |
---|
51 | then |
---|
52 | echo "Configuring GMP..." |
---|
53 | $GMP/configure --with-pic --build=x86-none-linux --host=armv5-eabi-linux || exit 1 |
---|
54 | fi |
---|
55 | |
---|
56 | echo "Building GMP..." |
---|
57 | make || exit 1 |
---|
58 | |
---|
59 | export JAVA_HOME=$(dirname $(dirname $(realpath $(which javac)))) |
---|
60 | if [ ! -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 |
---|
64 | fi |
---|
65 | |
---|
66 | COMPILEFLAGS="-fPIC -Wall" |
---|
67 | INCLUDES="-I. -I$JBIGI/jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/linux" |
---|
68 | LINKFLAGS="-shared -Wl,-soname,libjbigi.so,--fix-cortex-a8" |
---|
69 | |
---|
70 | echo "Building jbigi lib that is statically linked to GMP" |
---|
71 | STATICLIBS=".libs/libgmp.a" |
---|
72 | |
---|
73 | echo "Compiling C code..." |
---|
74 | rm -f jbigi.o $LIBFILE |
---|
75 | echo "$CC -c $COMPILEFLAGS $INCLUDES $JBIGI/jbigi/src/jbigi.c" |
---|
76 | $CC -c $COMPILEFLAGS $INCLUDES $JBIGI/jbigi/src/jbigi.c || exit 1 |
---|
77 | echo "$CC $LINKFLAGS $INCLUDES $INCLUDELIBS -o $LIBFILE jbigi.o $STATICLIBS" |
---|
78 | $CC $LINKFLAGS $INCLUDES $INCLUDELIBS -o $LIBFILE jbigi.o $STATICLIBS || exit 1 |
---|
79 | |
---|
80 | ls -l $LIBFILE || exit 1 |
---|
81 | |
---|
82 | |
---|
83 | echo 'Built successfully' |
---|