source: core/c/jcpuid/build.sh @ e574b5e

Last change on this file since e574b5e was e574b5e, checked in by kytv <kytv@…>, 9 years ago

minor updates to jbigi/jcpuid scripts

  • use my find-java-home stub script when building jcupid
  • move find-java-home to core/c
  • add support for ArchLinux? to find-java-home
  • Property mode set to 100755
File size: 2.6 KB
Line 
1#!/bin/sh
2
3cd `dirname $0`
4
5case `uname -s` in
6    MINGW*|CYGWIN*)
7        echo "Building windows .dlls";;
8    SunOS*)
9        echo "Building solaris .sos";;
10    Darwin*)
11        echo "Building Darwin jnilibs";;
12    Linux*|NetBSD*|OpenBSD*|*FreeBSD*)
13        echo "Building `uname -s |tr [A-Z] [a-z]` .sos";;
14    *)
15        echo "Unsupported build environment"
16        exit;;
17esac
18
19rm -rf lib
20mkdir -p lib/freenet/support/CPUInformation
21
22CC="gcc"
23
24case `uname -s` in
25    MINGW*|CYGWIN*)
26        JAVA_HOME="/c/software/j2sdk1.4.2_05"
27        COMPILEFLAGS="-Wall"
28        INCLUDES="-I. -Iinclude -I${JAVA_HOME}/include/ -I${JAVA_HOME}/include/win32/"
29        LINKFLAGS="-shared -static -static-libgcc -Wl,--kill-at"
30        LIBFILE="lib/freenet/support/CPUInformation/jcpuid-x86-windows.dll";;
31    Darwin*)
32        JAVA_HOME=$(/usr/libexec/java_home)
33        COMPILEFLAGS="-fPIC -Wall -arch x86_64 -arch i386"
34        INCLUDES="-I. -Iinclude -I${JAVA_HOME}/include/"
35        LINKFLAGS="-dynamiclib -framework JavaVM"
36        LIBFILE="lib/freenet/support/CPUInformation/libjcpuid-x86-darwin.jnilib";;
37    Linux*|OpenBSD*|NetBSD*|*FreeBSD*|SunOS*)
38        UNIXTYPE="`uname -s | tr [A-Z] [a-z]`"
39        if [ ${UNIXTYPE} = "sunos" ]; then
40            UNIXTYPE="solaris"
41        elif [ ${UNIXTYPE} = "kfreebsd" ]; then
42            UNIXTYPE="linux"
43        fi
44        # If JAVA_HOME isn't set, try to figure it out on our own
45        [ -z $JAVA_HOME ] && . ../find-java-home
46        # JAVA_HOME being set doesn't guarantee that it's usable
47        if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
48            echo "Please ensure you have a Java SDK installed" >&2
49            echo "and/or set JAVA_HOME then re-run this script." >&2
50            exit 1
51        fi
52
53        # Abort script on uncaught errors
54        set -e
55
56        case `uname -m` in
57            x86_64*|amd64)
58                ARCH="x86_64";;
59            ia64*)
60                ARCH="ia64";;
61            i?86*)
62                ARCH="x86";;
63            *)
64                echo "Unsupported build environment. jcpuid is only used on x86 systems."
65                exit 1;;
66        esac
67
68        LINKFLAGS="-shared -Wl,-soname,libjcpuid-${ARCH}-${UNIXTYPE}.so"
69        LIBFILE="lib/freenet/support/CPUInformation/libjcpuid-${ARCH}-${UNIXTYPE}.so"
70        COMPILEFLAGS="-fPIC -Wall"
71        INCLUDES="-I. -Iinclude -I${JAVA_HOME}/include -I${JAVA_HOME}/include/${UNIXTYPE}";;
72esac
73
74echo "Compiling C code..."
75rm -f ${LIBFILE}
76${CC} ${COMPILEFLAGS} ${LINKFLAGS} ${INCLUDES} src/*.c -o ${LIBFILE} || (echo "Failed to compile ${LIBFILE}"; exit 1)
77strip ${LIBFILE} || (echo "Failed to strip ${LIBFILE}" ; exit 1)
78echo Built `dirname $0`/${LIBFILE}
Note: See TracBrowser for help on using the repository browser.