I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit b09071f2 authored by kytv's avatar kytv
Browse files

update of jbigi scripts

- merge mbuild_jbigi.sh into build_jbigi.sh and drop mbuild_jbigi.sh
- make build.sh's tests optional
- try to determine the locations of JAVA_HOME and I2P
parent f5b6d564
No related branches found
No related tags found
No related merge requests found
...@@ -10,9 +10,10 @@ TODO: Document generated folder structure ...@@ -10,9 +10,10 @@ TODO: Document generated folder structure
Linux-specific information: Linux-specific information:
=========================== ===========================
Some linux distributions comes bundled with GMP. Some linux distributions come bundled with GMP.
Try 'locate lib/libgmp.so' to see. Try 'locate lib/libgmp.so' to see.
If so, install the the libgmp3-dev debian package to get the libgmp headers.
In Debian/Ubuntu, install the the libgmp3-dev package to get the libgmp headers.
Then export I2P=/path/to/your/i2p/install. Then export I2P=/path/to/your/i2p/install.
Then do 'build.sh dynamic'. This will do a quick build using your installed libgmp library Then do 'build.sh dynamic'. This will do a quick build using your installed libgmp library
and then test it and the jbigi in your I2P installation to see which is faster. and then test it and the jbigi in your I2P installation to see which is faster.
......
...@@ -17,63 +17,106 @@ ...@@ -17,63 +17,106 @@
# The resulting library is lib/libjbigi.so # The resulting library is lib/libjbigi.so
# #
mkdir -p lib/ rm -rf bin/local
mkdir -p bin/local mkdir -p lib bin/local
# Use 4.3.2 32bit CPUs.
# Use 5.0.2 64bit CPUs.
VER=4.3.2 VER=4.3.2
# If JAVA_HOME isn't set, try to figure it out on our own
[ -z $JAVA_HOME ] && . ./find-java-home
if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
echo "ERROR: Cannot find jni.h! Looked in \"$JAVA_HOME/include/jni.h\"" >&2
echo "Please set JAVA_HOME to a java home that has the JNI" >&2
exit 1
fi
# Abort script on uncaught errors
set -e set -e
if [ "$1" != "dynamic" -a ! -d gmp-$VER ] download_gmp ()
then {
TAR=gmp-$VER.tar.bz2 if [ $(which wget) ]; then
if [ ! -f $TAR ] echo "Downloading ftp://ftp.gmplib.org/pub/gmp-${VER}/${TAR}"
then wget -N --progress=dot ftp://ftp.gmplib.org/pub/gmp-${VER}/${TAR}
echo "Downloading ftp://ftp.gmplib.org/pub/gmp-${VER}/gmp-${VER}.tar.bz2" else
wget ftp://ftp.gmplib.org/pub/gmp-${VER}/gmp-${VER}.tar.bz2 echo "ERROR: Cannot find wget." >&2
fi echo >&2
echo "Please download ftp://ftp.gmplib.org/pub/gmp-${VER}/${TAR}" >&2
echo "manually and rerun this script." >&2
exit 1
fi
}
extract_gmp ()
{
tar -xjf ${TAR} > /dev/null 2>&1|| (rm -f ${TAR} && download_gmp && extract_gmp || exit 1)
}
TAR=gmp-${VER}.tar.bz2
echo "Building the jbigi library with GMP Version $VER" if [ "$1" != "dynamic" -a ! -d gmp-${VER} ]; then
if [ ! -f $TAR ]; then
download_gmp
fi
echo "Extracting GMP..." echo "Building the jbigi library with GMP Version ${VER}"
tar -xjf gmp-$VER.tar.bz2 echo "Extracting GMP..."
extract_gmp
fi fi
cd bin/local cd bin/local
echo "Building..." echo "Building..."
if [ "$1" != "dynamic" ] if [ "$1" != "dynamic" ]; then
then case `uname -sr` in
case `uname -sr` in Darwin*)
Darwin*) # --with-pic is required for static linking
# --with-pic is required for static linking ../../gmp-${VER}/configure --with-pic;;
../../gmp-$VER/configure --with-pic;; *)
*) # and it's required for ASLR
# and it's required for ASLR ../../gmp-${VER}/configure --with-pic;;
../../gmp-$VER/configure --with-pic;; esac
esac make
make sh ../../build_jbigi.sh static
sh ../../build_jbigi.sh static
else else
sh ../../build_jbigi.sh dynamic shift
sh ../../build_jbigi.sh dynamic
fi fi
cp *jbigi???* ../../lib/ cp *jbigi???* ../../lib/
echo 'Library copied to lib/' echo 'Library copied to lib/'
cd ../.. cd ../..
if [ ! -f $I2P/lib/i2p.jar ] if [ "$1" != "notest" ]; then
then if [ -z "$I2P" ]; then
echo "I2P installation not found" if [ -r $HOME/i2p/lib/i2p.jar ]; then
echo "We looked in '$I2P'" I2P="$HOME/i2p"
echo "Not running tests against I2P installation without knowing where it is" elif [ -r /usr/share/i2p/lib/i2p.jar ]; then
echo "Please set the environment variable I2P to the location of your I2P installation (so that \$I2P/lib/i2p.jar works)" I2P="/usr/share/i2p"
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)" else
exit 1 echo "Please set the environment variable \$I2P to run tests." >&2
fi
fi
if [ ! -f $I2P/lib/i2p.jar ]; then
echo "I2P installation not found" >&2
echo "We looked in $I2P" >&2
echo "Not running tests against I2P installation without knowing where it is." >&2
echo >&2
echo "Please set the environment variable I2P to the location of your"
echo "I2P installation (so that \$I2P/lib/i2p.jar works)." >&2
echo "If you do so, this script will run two tests to compare your" >&2
echo "installed jbigi with the one here you just compiled to see if" >&2
echo "there is a marked improvement." >&2
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
echo 'If the second run shows better performance, please use the jbigi that you have compiled so that I2P will work better!'
echo "(You can do that just by copying lib/libjbigi.so over the existing libjbigi.so file in \$I2P)"
fi 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
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)'
#!/bin/sh #!/bin/sh
# When executed in Mingw: Produces an jbigi.dll # When executed in Mingw: Produces a jbigi.dll
# When executed in Linux/FreeBSD: Produces an libjbigi.so # When executed in Linux/FreeBSD: Produces a libjbigi.so
# Darwin produces libjbigi.jnilib, right? # When executed in OSX: Produces a libjbigi.jnilib
CC="gcc" CC="gcc"
case `uname -sr` in # If JAVA_HOME isn't set we'll try to figure it out
[ -z $JAVA_HOME ] && . ./find-java-home
if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
echo "Cannot find jni.h! Looked in '$JAVA_HOME/include/jni.h'"
echo "Please set JAVA_HOME to a java home that has the JNI"
exit 1
fi
case `uname -s` in
MINGW*) MINGW*)
JAVA_HOME="c:/software/j2sdk1.4.2_05" JAVA_HOME="c:/software/j2sdk1.4.2_05"
COMPILEFLAGS="-Wall" COMPILEFLAGS="-Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/" INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
LINKFLAGS="-shared -Wl,--kill-at" LINKFLAGS="-shared -Wl,--kill-at"
LIBFILE="jbigi.dll";; LIBFILE="jbigi.dll";;
CYGWIN*) CYGWIN*)
JAVA_HOME="c:/software/j2sdk1.4.2_05" JAVA_HOME="c:/software/j2sdk1.4.2_05"
COMPILEFLAGS="-Wall -mno-cygwin" COMPILEFLAGS="-Wall -mno-cygwin"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/" INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
LINKFLAGS="-shared -Wl,--kill-at" LINKFLAGS="-shared -Wl,--kill-at"
LIBFILE="jbigi.dll";; LIBFILE="jbigi.dll";;
Darwin*) Darwin*)
JAVA_HOME="/Library/Java/Home" JAVA_HOME=$(/usr/libexec/java_home)
COMPILEFLAGS="-Wall" COMPILEFLAGS="-fPIC -Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include" INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include"
LINKFLAGS="-dynamiclib -framework JavaVM" LINKFLAGS="-dynamiclib -framework JavaVM"
LIBFILE="libjbigi.jnilib";; LIBFILE="libjbigi.jnilib";;
SunOS*) SunOS*|OpenBSD*|NetBSD*|FreeBSD*|Linux*)
UNIXTYPE=$(uname -s | tr "[A-Z]" "[a-z]")
if [ $UNIXTYPE = "sunos" ]; then
UNIXTYPE="solaris"
fi
COMPILEFLAGS="-fPIC -Wall" COMPILEFLAGS="-fPIC -Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/solaris" INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE}"
LINKFLAGS="-shared -Wl,-soname,libjbigi.so" LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
LIBFILE="libjbigi.so";; LIBFILE="libjbigi.so";;
*) *)
COMPILEFLAGS="-fPIC -Wall" echo "Unsupported system type."
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/linux" exit 1;;
LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
LIBFILE="libjbigi.so";;
esac esac
if [ ! -f "$JAVA_HOME/include/jni.h" ]; then if [ "$1" = "dynamic" ] ; then
echo "Cannot find jni.h! Looked in '$JAVA_HOME/include/jni.h'" echo "Building a jbigi lib that is dynamically linked to GMP"
echo "Please set JAVA_HOME to a java home that has the JNI" LIBPATH="-L.libs"
exit 1 INCLUDELIBS="-lgmp"
fi
#To link dynamically to GMP (use libgmp.so or gmp.lib), uncomment the first line below
#To link statically to GMP, uncomment the second line below
# Bug!!! Quote *BOTH* or neither! --Sponge
if test "$1" = "dynamic"
then
echo "Building jbigi lib that is dynamically linked to GMP"
LIBPATH="-L.libs"
INCLUDELIBS="-lgmp"
else else
echo "Building jbigi lib that is statically linked to GMP" echo "Building a jbigi lib that is statically linked to GMP"
STATICLIBS=".libs/libgmp.a" STATICLIBS=".libs/libgmp.a"
fi fi
echo "Compiling C code..." echo "Compiling C code..."
rm -f jbigi.o $LIBFILE rm -f jbigi.o $LIBFILE
$CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c $CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c || exit 1
$CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS $CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS || exit 1
exit 0
UNIXTYPE=$(uname -s | tr "[A-Z]" "[a-z]")
if [ $UNIXTYPE = "freebsd" ]; then
if [ -d /usr/local/openjdk6 ]; then
JAVA_HOME="/usr/local/openjdk6"
elif [ -d /usr/local/openjdk7 ]; then
JAVA_HOME="/usr/local/openjdk7"
fi
elif [ $UNIXTYPE = "openbsd" ]; then
if [ -d /usr/local/jdk-1.7.0 ]; then
JAVA_HOME="/usr/local/jdk-1.7.0"
fi
elif [ $UNIXTYPE = "netbsd" ]; then
if [ -d /usr/pkg/java/openjdk7 ]; then
JAVA_HOME="/usr/pkg/java/openjdk7"
fi
elif [ $UNIXTYPE = "linux" ] && [ -e /etc/debian_version ]; then
if [ -d /usr/lib/jvm/default-java ]; then
JAVA_HOME="/usr/lib/jvm/default-java"
fi
elif [ $UNIXTYPE = "darwin" ]; then
JAVA_HOME=$(/usr/libexec/java_home)
fi
export JAVA_HOME
...@@ -154,7 +154,7 @@ esac ...@@ -154,7 +154,7 @@ esac
make_static () { make_static () {
$ECHO "Attempting .${4} creation for ${3}${5}${2}" $ECHO "Attempting .${4} creation for ${3}${5}${2}"
../../mbuild_jbigi.sh static || return 1 ../../build_jbigi.sh static || return 1
cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}.${4} cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}.${4}
return 0 return 0
} }
......
#!/bin/sh
# When executed in Mingw: Produces a jbigi.dll
# When executed in Linux/FreeBSD: Produces a libjbigi.so
# When executed in OSX: Produces a libjbigi.jnilib
CC="gcc"
case `uname -s` in
MINGW*)
JAVA_HOME="c:/software/j2sdk1.4.2_05"
COMPILEFLAGS="-Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
LINKFLAGS="-shared -Wl,--kill-at"
LIBFILE="jbigi.dll";;
CYGWIN*)
JAVA_HOME="c:/software/j2sdk1.4.2_05"
COMPILEFLAGS="-Wall -mno-cygwin"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
LINKFLAGS="-shared -Wl,--kill-at"
LIBFILE="jbigi.dll";;
Darwin*)
JAVA_HOME=$(/usr/libexec/java_home)
COMPILEFLAGS="-fPIC -Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include"
LINKFLAGS="-dynamiclib -framework JavaVM"
LIBFILE="libjbigi.jnilib";;
SunOS*|OpenBSD*|NetBSD*|FreeBSD*|Linux*)
UNIXTYPE=$(uname -s | tr "[A-Z]" "[a-z]")
if [ $UNIXTYPE = "sunos" ]; then
UNIXTYPE="solaris"
elif [ $UNIXTYPE = "freebsd" ]; then
if [ -d /usr/local/openjdk6 ]; then
JAVA_HOME="/usr/local/openjdk6"
elif [ -d /usr/local/openjdk7 ]; then
JAVA_HOME="/usr/local/openjdk7"
fi
elif [ $UNIXTYPE = "openbsd" ]; then
if [ -d /usr/local/jdk-1.7.0 ]; then
JAVA_HOME="/usr/local/jdk-1.7.0"
fi
elif [ $UNIXTYPE = "netbsd" ]; then
if [ -d /usr/pkg/java/openjdk7 ]; then
JAVA_HOME="/usr/pkg/java/openjdk7"
fi
elif [ $UNIXTYPE = "linux" ] && [ -e /etc/debian_version ]; then
if [ -d /usr/lib/jvm/default-java ]; then
JAVA_HOME="/usr/lib/jvm/default-java"
fi
fi
COMPILEFLAGS="-fPIC -Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE}"
LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
LIBFILE="libjbigi.so";;
*)
echo "Unsupported system type."
exit 1;;
esac
if [ "$1" = "dynamic" ] ; then
echo "Building a jbigi lib that is dynamically linked to GMP"
LIBPATH="-L.libs"
INCLUDELIBS="-lgmp"
else
echo "Building a jbigi lib that is statically linked to GMP"
STATICLIBS=".libs/libgmp.a"
fi
echo "Compiling C code..."
rm -f jbigi.o $LIBFILE
$CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c || exit 1
$CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS || exit 1
exit 0
...@@ -2,18 +2,18 @@ From: Kill Your TV <killyourtv@i2pmail.org> ...@@ -2,18 +2,18 @@ From: Kill Your TV <killyourtv@i2pmail.org>
Date: Wed, 11 May 2011 00:12:04 +0000 Date: Wed, 11 May 2011 00:12:04 +0000
Subject: jbigi soname Subject: jbigi soname
The purpose of this patch is to change the path that mbuild_jbigi.sh The purpose of this patch is to change the path that build_jbigi.sh
expects to find the source files at. At the same time I'm specifying expects to find the source files at. At the same time I'm specifying
a soname to shut lintian up. a soname to shut lintian up.
--- ---
core/c/jbigi/mbuild_jbigi.sh | 6 +++--- core/c/jbigi/build_jbigi.sh | 4 +++---
1 files changed, 3 insertions(+), 3 deletions(-) 1 files changed, 2 insertions(+), 2 deletions(-)
--- a/core/c/jbigi/mbuild_jbigi.sh --- a/core/c/jbigi/build_jbigi.sh
+++ b/core/c/jbigi/mbuild_jbigi.sh +++ b/core/c/jbigi/build_jbigi.sh
@@ -47,7 +47,7 @@ @@ -37,7 +37,7 @@
fi UNIXTYPE="solaris"
fi fi
COMPILEFLAGS="-fPIC -Wall" COMPILEFLAGS="-fPIC -Wall"
- INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE}" - INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE}"
...@@ -21,7 +21,7 @@ a soname to shut lintian up. ...@@ -21,7 +21,7 @@ a soname to shut lintian up.
LINKFLAGS="-shared -Wl,-soname,libjbigi.so" LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
LIBFILE="libjbigi.so";; LIBFILE="libjbigi.so";;
*) *)
@@ -66,7 +66,7 @@ @@ -56,7 +56,7 @@
echo "Compiling C code..." echo "Compiling C code..."
rm -f jbigi.o $LIBFILE rm -f jbigi.o $LIBFILE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment