source: core/c/jbigi/build.sh @ 73228a1

Last change on this file since 73228a1 was 73228a1, checked in by dev <dev@…>, 6 years ago

Revamped downloading of gmp files.
Revamped cross-compilation support.

  • Property mode set to 100755
File size: 2.9 KB
Line 
1#!/bin/bash
2#
3#  Build the jbigi library for i2p
4#
5#  To build a static library:
6#     Set $I2P to point to your I2P installation
7#     Set $JAVA_HOME to point to your Java SDK
8#     build.sh
9#       This script downloads gmp-4.3.2.tar.bz2 to this directory
10#       (if a different version, change the GMP_VER= line below)
11#
12#  To build a dynamic library (you must have a libgmp.so somewhere in your system)
13#     Set $I2P to point to your I2P installation
14#     Set $JAVA_HOME to point to your Java SDK
15#     build.sh dynamic
16#
17#  The resulting library is lib/libjbigi.so
18#
19
20rm -rf bin/local
21mkdir -p lib bin/local
22
23# Import gmp version variables and download gmp.
24source ./download_gmp.sh
25
26
27# If JAVA_HOME isn't set, try to figure it out on our own
28[ -z $JAVA_HOME ] && . ../find-java-home
29if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
30    echo "ERROR: Cannot find jni.h! Looked in \"$JAVA_HOME/include/jni.h\"" >&2
31    echo "Please set JAVA_HOME to a java home that has the JNI" >&2
32    exit 1
33fi
34
35# Abort script on uncaught errors
36set -e
37
38cd bin/local
39
40echo "Building..."
41if [ "$1" != "dynamic" ]; then
42    case `uname -sr` in
43        Darwin*)
44            # --with-pic is required for static linking
45            ../../gmp-${GMP_VER}/configure --with-pic;;
46        *)
47            # and it's required for ASLR
48            ../../gmp-${GMP_VER}/configure --with-pic;;
49    esac
50    make
51    sh ../../build_jbigi.sh static
52else
53    shift
54    sh ../../build_jbigi.sh dynamic
55fi
56
57cp *jbigi???* ../../lib/
58echo 'Library copied to lib/'
59cd ../..
60
61if [ "$1" != "notest" ]; then
62    if [ -z "$I2P" ]; then
63        if [ -r $HOME/i2p/lib/i2p.jar ]; then
64            I2P="$HOME/i2p"
65        elif [ -r /usr/share/i2p/lib/i2p.jar ]; then
66            I2P="/usr/share/i2p"
67        else
68            echo "Please set the environment variable \$I2P to run tests." >&2
69        fi
70    fi
71
72    if [ ! -f $I2P/lib/i2p.jar ]; then
73        echo "I2P installation not found" >&2
74        echo "We looked in $I2P" >&2
75        echo "Not running tests against I2P installation without knowing where it is." >&2
76        echo >&2
77        echo "Please set the environment variable I2P to the location of your"
78        echo "I2P installation (so that \$I2P/lib/i2p.jar works)." >&2
79        echo "If you do so, this script will run two tests to compare your" >&2
80        echo "installed jbigi with the one here you just compiled to see if" >&2
81        echo "there is a marked improvement." >&2
82        exit 1
83    fi
84    echo 'Running test with standard I2P installation...'
85    java -cp $I2P/lib/i2p.jar:$I2P/lib/jbigi.jar net.i2p.util.NativeBigInteger
86    echo
87    echo 'Running test with new libjbigi...'
88    java -Djava.library.path=lib/ -cp $I2P/lib/i2p.jar:$I2P/lib/jbigi.jar net.i2p.util.NativeBigInteger
89    echo 'If the second run shows better performance, please use the jbigi that you have compiled so that I2P will work better!'
90    echo "(You can do that just by copying lib/libjbigi.so over the existing libjbigi.so file in \$I2P)"
91fi
Note: See TracBrowser for help on using the repository browser.