2004-08-21 07:56:53 +00:00
#/bin/sh
2008-05-12 13:47:15 +00:00
#
# Build the jbigi library for i2p
#
# To build a static library:
2011-05-21 17:09:30 +00:00
# Set $I2P to point to your I2P installation
# Set $JAVA_HOME to point to your Java SDK
2008-05-12 13:47:15 +00:00
# build.sh
2011-05-21 17:09:30 +00:00
# This script downloads gmp-4.3.2.tar.bz2 to this directory
# (if a different version, change the VER= line below)
2008-05-12 13:47:15 +00:00
#
# To build a dynamic library (you must have a libgmp.so somewhere in your system)
2011-05-21 17:09:30 +00:00
# Set $I2P to point to your I2P installation
# Set $JAVA_HOME to point to your Java SDK
2008-05-12 13:47:15 +00:00
# build.sh dynamic
#
# The resulting library is lib/libjbigi.so
#
2004-08-21 07:56:53 +00:00
2004-12-10 13:12:07 +00:00
mkdir -p lib/
mkdir -p bin/local
2011-05-21 17:09:30 +00:00
VER = 4.3.2
2008-05-12 13:47:15 +00:00
2010-06-03 03:35:46 +00:00
set -e
2008-05-12 13:47:15 +00:00
if [ " $1 " != "dynamic" -a ! -d gmp-$VER ]
then
2011-05-21 17:09:30 +00:00
TAR = gmp-$VER .tar.bz2
2008-05-12 13:47:15 +00:00
if [ ! -f $TAR ]
then
2011-05-21 17:09:30 +00:00
echo " Downloading ftp://ftp.gmplib.org/pub/gmp- ${ VER } /gmp- ${ VER } .tar.bz2 "
wget ftp://ftp.gmplib.org/pub/gmp-${ VER } /gmp-${ VER } .tar.bz2
2008-05-12 13:47:15 +00:00
fi
echo " Building the jbigi library with GMP Version $VER "
echo "Extracting GMP..."
2011-05-21 17:09:30 +00:00
tar -xjf gmp-$VER .tar.bz2
2008-05-12 13:47:15 +00:00
fi
2004-08-21 07:56:53 +00:00
cd bin/local
2008-05-12 13:47:15 +00:00
echo "Building..."
if [ " $1 " != "dynamic" ]
then
case ` uname -sr` in
Darwin*)
# --with-pic is required for static linking
../../gmp-$VER /configure --with-pic; ;
*)
2011-05-21 17:09:30 +00:00
# and it's required for ASLR
2009-09-07 17:33:29 +00:00
../../gmp-$VER /configure --with-pic; ;
2008-05-12 13:47:15 +00:00
esac
make
sh ../../build_jbigi.sh static
else
sh ../../build_jbigi.sh dynamic
fi
2004-12-10 13:12:07 +00:00
cp *jbigi???* ../../lib/
2008-05-12 13:47:15 +00:00
echo 'Library copied to lib/'
2004-12-10 13:12:07 +00:00
cd ../..
2008-05-12 13:47:15 +00:00
if [ ! -f $I2P /lib/i2p.jar ]
then
2010-06-03 03:35:46 +00:00
echo "I2P installation not found"
echo " We looked in ' $I2P ' "
echo "Not running tests against I2P installation without knowing where it is"
echo "Please set the environment variable I2P to the location of your I2P installation (so that \$I2P/lib/i2p.jar works)"
echo "If you do so, this script will run two tests to compare your installed jbigi with the one here you just compiled (to see if there is a marked improvement)"
2008-05-12 13:47:15 +00:00
exit 1
fi
echo 'Running test with standard I2P installation...'
java -cp $I2P /lib/i2p.jar:$I2P /lib/jbigi.jar net.i2p.util.NativeBigInteger
echo
echo 'Running test with new libjbigi...'
java -Djava.library.path= lib/ -cp $I2P /lib/i2p.jar:$I2P /lib/jbigi.jar net.i2p.util.NativeBigInteger
2010-06-03 03:35:46 +00:00
echo 'If the second is better performance, please use the jbigi you have compiled i2p will work better!'
echo '(You can do that just by copying lib/libjbigi.so over the existing libjbigi.so file in $I2P)'