source: core/c/jbigi/build_jbigi.sh @ f816324

Last change on this file since f816324 was f816324, checked in by zzz <zzz@…>, 6 years ago

NBI test improvements:

  • Try to prevent not-coprime errors
  • Minor cleanups
  • Javadoc fix

Fix build script typo

  • Property mode set to 100755
File size: 2.8 KB
Line 
1#!/bin/sh
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
5[ -z "$CC" ] && CC="gcc"
6
7# If JAVA_HOME isn't set we'll try to figure it out
8[ -z $JAVA_HOME ] && . `dirname $0`/../find-java-home
9if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
10    echo "Cannot find jni.h! Looked in '$JAVA_HOME/include/jni.h'"
11    echo "Please set JAVA_HOME to a java home that has the JNI"
12    exit 1
13fi
14
15
16# Allow TARGET to be overridden (e.g. for use with cross compilers)
17[ -z $TARGET ] && TARGET=$(uname -s | tr "[A-Z]" "[a-z]")
18
19# Note, this line does not support windows (and needs to generate a win32/win64 string for that to work)
20BUILD_OS=$(uname -s | tr "[A-Z]" "[a-z]")
21echo "TARGET=$TARGET"
22
23case "$TARGET" in
24mingw*|windows*)
25        COMPILEFLAGS="-Wall"
26        INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/$BUILD_OS -I/usr/local/include"
27        LINKFLAGS="-shared -Wl,--kill-at"
28        LIBFILE="jbigi.dll";;
29cygwin*)
30        COMPILEFLAGS="-Wall -mno-cygwin"
31        INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/$BUILD_OS/ -I$JAVA_HOME/include/"
32        LINKFLAGS="-shared -Wl,--kill-at"
33        LIBFILE="jbigi.dll";;
34darwin*|osx)
35        COMPILEFLAGS="-fPIC -Wall"
36        INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/$BUILD_OS -I/usr/local/include"
37        LINKFLAGS="-dynamiclib -framework JavaVM"
38        LIBFILE="libjbigi.jnilib";;
39sunos*|openbsd*|netbsd*|*freebsd*|linux*)
40        if [ $BUILD_OS = "sunos" ]; then
41            BUILD_OS="solaris"
42        elif [ $BUILD_OS = "gnu/kfreebsd" ]; then
43            BUILD_OS="linux"
44        fi
45        COMPILEFLAGS="-fPIC -Wall $CFLAGS"
46        INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/$BUILD_OS -I/usr/local/include"
47        LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
48        LIBFILE="libjbigi.so";;
49*)
50        echo "Unsupported system type."
51        exit 1;;
52esac
53
54if [ "$1" = "dynamic" ] ; then
55        echo "Building a jbigi lib that is dynamically linked to GMP"
56        LIBPATH="-L.libs -L/usr/local/lib"
57        INCLUDELIBS="-lgmp"
58else
59        echo "Building a jbigi lib that is statically linked to GMP"
60        STATICLIBS=".libs/libgmp.a"
61fi
62
63[ $BITS -eq 32 ] && COMPILEFLAGS="-m32 $COMPILEFLAGS" && LINKFLAGS="-m32 $LINKFLAGS"
64[ $BITS -eq 64 ] && COMPILEFLAGS="-m64 $COMPILEFLAGS" && LINKFLAGS="-m64 $LINKFLAGS"
65
66echo "Compiling C code..."
67echo "Compile: \"$CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c\""
68$CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c || exit 1
69echo "Link: \"$CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS $LIBPATH\""
70$CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS $LIBPATH || exit 1
71
72exit 0
Note: See TracBrowser for help on using the repository browser.