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

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

Build: Fix Debian build on ARM (ticket #1801)

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