source: android/jni/build.sh @ af629d2

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

Android:

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