Changeset b09071f


Ignore:
Timestamp:
Jan 8, 2012 11:23:00 PM (9 years ago)
Author:
kytv <kytv@…>
Branches:
master
Children:
0f62383
Parents:
f5b6d56
Message:

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
Files:
1 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • core/c/jbigi/README

    rf5b6d56 rb09071f  
    1111Linux-specific information:
    1212===========================
    13 Some linux distributions comes bundled with GMP.
     13Some linux distributions come bundled with GMP.
    1414Try 'locate lib/libgmp.so' to see.
    15 If so, install the the libgmp3-dev debian package to get the libgmp headers.
     15
     16In Debian/Ubuntu, install the the libgmp3-dev package to get the libgmp headers.
    1617Then export I2P=/path/to/your/i2p/install.
    1718Then do 'build.sh dynamic'. This will do a quick build using your installed libgmp library
  • core/c/jbigi/build.sh

    rf5b6d56 rb09071f  
    1818#
    1919
    20 mkdir -p lib/
    21 mkdir -p bin/local
     20rm -rf bin/local
     21mkdir -p lib bin/local
     22
     23# Use 4.3.2 32bit CPUs.
     24# Use 5.0.2 64bit CPUs.
    2225VER=4.3.2
    2326
     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
    2436set -e
    2537
    26 if [ "$1" != "dynamic" -a ! -d gmp-$VER ]
    27 then
    28         TAR=gmp-$VER.tar.bz2
    29         if [ ! -f $TAR ]
    30         then
    31             echo "Downloading ftp://ftp.gmplib.org/pub/gmp-${VER}/gmp-${VER}.tar.bz2"
    32             wget ftp://ftp.gmplib.org/pub/gmp-${VER}/gmp-${VER}.tar.bz2
    33         fi
     38download_gmp ()
     39{
     40if [ $(which wget) ]; then
     41    echo "Downloading ftp://ftp.gmplib.org/pub/gmp-${VER}/${TAR}"
     42    wget -N --progress=dot ftp://ftp.gmplib.org/pub/gmp-${VER}/${TAR}
     43else
     44    echo "ERROR: Cannot find wget." >&2
     45    echo >&2
     46    echo "Please download ftp://ftp.gmplib.org/pub/gmp-${VER}/${TAR}" >&2
     47    echo "manually and rerun this script." >&2
     48    exit 1
     49fi
     50}
    3451
    35         echo "Building the jbigi library with GMP Version $VER"
     52extract_gmp ()
     53{
     54tar -xjf ${TAR} > /dev/null 2>&1|| (rm -f ${TAR} && download_gmp && extract_gmp || exit 1)
     55}
    3656
    37         echo "Extracting GMP..."
    38         tar -xjf gmp-$VER.tar.bz2
     57TAR=gmp-${VER}.tar.bz2
     58
     59if [ "$1" != "dynamic" -a ! -d gmp-${VER} ]; then
     60    if [ ! -f $TAR ]; then
     61        download_gmp
     62    fi
     63
     64    echo "Building the jbigi library with GMP Version ${VER}"
     65    echo "Extracting GMP..."
     66    extract_gmp
    3967fi
    4068
     
    4270
    4371echo "Building..."
    44 if [ "$1" != "dynamic" ]
    45 then
    46         case `uname -sr` in
    47                 Darwin*)
    48                         # --with-pic is required for static linking
    49                         ../../gmp-$VER/configure --with-pic;;
    50                 *)
    51                         # and it's required for ASLR
    52                         ../../gmp-$VER/configure --with-pic;;
    53         esac
    54         make
    55         sh ../../build_jbigi.sh static
     72if [ "$1" != "dynamic" ]; then
     73    case `uname -sr` in
     74        Darwin*)
     75            # --with-pic is required for static linking
     76            ../../gmp-${VER}/configure --with-pic;;
     77        *)
     78            # and it's required for ASLR
     79            ../../gmp-${VER}/configure --with-pic;;
     80    esac
     81    make
     82    sh ../../build_jbigi.sh static
    5683else
    57         sh ../../build_jbigi.sh dynamic
     84    shift
     85    sh ../../build_jbigi.sh dynamic
    5886fi
    5987
     
    6290cd ../..
    6391
    64 if [ ! -f $I2P/lib/i2p.jar ]
    65 then
    66         echo "I2P installation not found"
    67     echo "We looked in '$I2P'"
    68     echo "Not running tests against I2P installation without knowing where it is"
    69     echo "Please set the environment variable I2P to the location of your I2P installation (so that \$I2P/lib/i2p.jar works)"
    70     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)"
    71         exit 1
     92if [ "$1" != "notest" ]; then
     93    if [ -z "$I2P" ]; then
     94        if [ -r $HOME/i2p/lib/i2p.jar ]; then
     95            I2P="$HOME/i2p"
     96        elif [ -r /usr/share/i2p/lib/i2p.jar ]; then
     97            I2P="/usr/share/i2p"
     98        else
     99            echo "Please set the environment variable \$I2P to run tests." >&2
     100        fi
     101    fi
     102
     103    if [ ! -f $I2P/lib/i2p.jar ]; then
     104        echo "I2P installation not found" >&2
     105        echo "We looked in $I2P" >&2
     106        echo "Not running tests against I2P installation without knowing where it is." >&2
     107        echo >&2
     108        echo "Please set the environment variable I2P to the location of your"
     109        echo "I2P installation (so that \$I2P/lib/i2p.jar works)." >&2
     110        echo "If you do so, this script will run two tests to compare your" >&2
     111        echo "installed jbigi with the one here you just compiled to see if" >&2
     112        echo "there is a marked improvement." >&2
     113        exit 1
     114    fi
     115    echo 'Running test with standard I2P installation...'
     116    java -cp $I2P/lib/i2p.jar:$I2P/lib/jbigi.jar net.i2p.util.NativeBigInteger
     117    echo
     118    echo 'Running test with new libjbigi...'
     119    java -Djava.library.path=lib/ -cp $I2P/lib/i2p.jar:$I2P/lib/jbigi.jar net.i2p.util.NativeBigInteger
     120    echo 'If the second run shows better performance, please use the jbigi that you have compiled so that I2P will work better!'
     121    echo "(You can do that just by copying lib/libjbigi.so over the existing libjbigi.so file in \$I2P)"
    72122fi
    73 echo 'Running test with standard I2P installation...'
    74 java -cp $I2P/lib/i2p.jar:$I2P/lib/jbigi.jar net.i2p.util.NativeBigInteger
    75 echo
    76 echo 'Running test with new libjbigi...'
    77 java -Djava.library.path=lib/ -cp $I2P/lib/i2p.jar:$I2P/lib/jbigi.jar net.i2p.util.NativeBigInteger
    78 echo 'If the second is better performance, please use the jbigi you have compiled i2p will work better!'
    79 echo '(You can do that just by copying lib/libjbigi.so over the existing libjbigi.so file in $I2P)'
  • core/c/jbigi/build_jbigi.sh

    rf5b6d56 rb09071f  
    11#!/bin/sh
    2 # When executed in Mingw: Produces an jbigi.dll
    3 # When executed in Linux/FreeBSD: Produces an libjbigi.so
    4 # Darwin produces libjbigi.jnilib, right?
    5 
     2# When executed in Mingw: Produces a jbigi.dll
     3# When executed in Linux/FreeBSD: Produces a libjbigi.so
     4# When executed in OSX: Produces a libjbigi.jnilib
    65CC="gcc"
    76
    8 case `uname -sr` in
    9 MINGW*)
    10         JAVA_HOME="c:/software/j2sdk1.4.2_05"
    11         COMPILEFLAGS="-Wall"
    12         INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
    13         LINKFLAGS="-shared -Wl,--kill-at"
    14         LIBFILE="jbigi.dll";;
    15 CYGWIN*)
    16         JAVA_HOME="c:/software/j2sdk1.4.2_05"
    17         COMPILEFLAGS="-Wall -mno-cygwin"
    18         INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
    19         LINKFLAGS="-shared -Wl,--kill-at"
    20         LIBFILE="jbigi.dll";;
    21 Darwin*)
    22         JAVA_HOME="/Library/Java/Home"
    23         COMPILEFLAGS="-Wall"
    24         INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include"
    25         LINKFLAGS="-dynamiclib -framework JavaVM"
    26         LIBFILE="libjbigi.jnilib";;
    27 SunOS*)
    28         COMPILEFLAGS="-fPIC -Wall"
    29         INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/solaris"
    30         LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
    31         LIBFILE="libjbigi.so";;
    32 *)
    33         COMPILEFLAGS="-fPIC -Wall"
    34         INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
    35         LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
    36         LIBFILE="libjbigi.so";;
    37 esac
    38 
     7# If JAVA_HOME isn't set we'll try to figure it out
     8[ -z $JAVA_HOME ] && . ./find-java-home
    399if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
    4010    echo "Cannot find jni.h! Looked in '$JAVA_HOME/include/jni.h'"
     
    4313fi
    4414
    45 #To link dynamically to GMP (use libgmp.so or gmp.lib), uncomment the first line below
    46 #To link statically to GMP, uncomment the second line below
    47 # Bug!!! Quote *BOTH* or neither! --Sponge
    48 if test "$1" = "dynamic"
    49 then
    50         echo "Building jbigi lib that is dynamically linked to GMP"
    51         LIBPATH="-L.libs"
    52         INCLUDELIBS="-lgmp"
     15case `uname -s` in
     16MINGW*)
     17        JAVA_HOME="c:/software/j2sdk1.4.2_05"
     18        COMPILEFLAGS="-Wall"
     19        INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
     20        LINKFLAGS="-shared -Wl,--kill-at"
     21        LIBFILE="jbigi.dll";;
     22CYGWIN*)
     23        JAVA_HOME="c:/software/j2sdk1.4.2_05"
     24        COMPILEFLAGS="-Wall -mno-cygwin"
     25        INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
     26        LINKFLAGS="-shared -Wl,--kill-at"
     27        LIBFILE="jbigi.dll";;
     28Darwin*)
     29        JAVA_HOME=$(/usr/libexec/java_home)
     30        COMPILEFLAGS="-fPIC -Wall"
     31        INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include"
     32        LINKFLAGS="-dynamiclib -framework JavaVM"
     33        LIBFILE="libjbigi.jnilib";;
     34SunOS*|OpenBSD*|NetBSD*|FreeBSD*|Linux*)
     35        UNIXTYPE=$(uname -s | tr "[A-Z]" "[a-z]")
     36        if [ $UNIXTYPE = "sunos" ]; then
     37            UNIXTYPE="solaris"
     38        fi
     39        COMPILEFLAGS="-fPIC -Wall"
     40        INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE}"
     41        LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
     42        LIBFILE="libjbigi.so";;
     43*)
     44        echo "Unsupported system type."
     45        exit 1;;
     46esac
     47
     48if [ "$1" = "dynamic" ] ; then
     49        echo "Building a jbigi lib that is dynamically linked to GMP"
     50        LIBPATH="-L.libs"
     51        INCLUDELIBS="-lgmp"
    5352else
    54         echo "Building jbigi lib that is statically linked to GMP"
    55         STATICLIBS=".libs/libgmp.a"
     53        echo "Building a jbigi lib that is statically linked to GMP"
     54        STATICLIBS=".libs/libgmp.a"
    5655fi
    5756
    5857echo "Compiling C code..."
    5958rm -f jbigi.o $LIBFILE
    60 $CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c
    61 $CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS
     59$CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c || exit 1
     60$CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS || exit 1
     61
     62exit 0
  • core/c/jbigi/mbuild-all.sh

    rf5b6d56 rb09071f  
    155155make_static () {
    156156        $ECHO "Attempting .${4} creation for ${3}${5}${2}"
    157         ../../mbuild_jbigi.sh static || return 1
     157        ../../build_jbigi.sh static || return 1
    158158        cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}.${4}
    159159        return 0
  • debian/patches/0002-jbigi-soname.patch

    rf5b6d56 rb09071f  
    33Subject: jbigi soname
    44
    5 The purpose of this patch is to change the path that mbuild_jbigi.sh
     5The purpose of this patch is to change the path that build_jbigi.sh
    66expects to find the source files at. At the same time I'm specifying
    77a soname to shut lintian up.
    88
    99---
    10  core/c/jbigi/mbuild_jbigi.sh |    6 +++---
    11  1 files changed, 3 insertions(+), 3 deletions(-)
     10 core/c/jbigi/build_jbigi.sh |    4 +++---
     11 1 files changed, 2 insertions(+), 2 deletions(-)
    1212
    13 --- a/core/c/jbigi/mbuild_jbigi.sh
    14 +++ b/core/c/jbigi/mbuild_jbigi.sh
    15 @@ -47,7 +47,7 @@
    16                  fi
     13--- a/core/c/jbigi/build_jbigi.sh
     14+++ b/core/c/jbigi/build_jbigi.sh
     15@@ -37,7 +37,7 @@
     16             UNIXTYPE="solaris"
    1717         fi
    1818         COMPILEFLAGS="-fPIC -Wall"
     
    2222         LIBFILE="libjbigi.so";;
    2323 *)
    24 @@ -66,7 +66,7 @@
     24@@ -56,7 +56,7 @@
    2525 
    2626 echo "Compiling C code..."
Note: See TracChangeset for help on using the changeset viewer.