source: core/c/jbigi/build_jbigi.sh @ 4fd0261

Last change on this file since 4fd0261 was 4fd0261, checked in by dev <dev@…>, 5 years ago

jcpuid/build_jbigi: Default BITS to 64 if unset.

To make sure that our debian build scripts work,
set BITS to 64 if unassigned.

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