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

Last change on this file since ecb28eb was c1da7f7, checked in by kytv <kytv@…>, 8 years ago

improvements to jbigi scripts

support for Solaris (tested with Solaris 11 x86)

mbuild-all.sh:

  • output correctly formatted file names (tested in Solaris x86, FreeBSD (x86 and x64) and Linux (x86 & x64))
  • switch from echo -e to the more portable printf
  • more error checking, comments

debian/patches: refreshed based on changes to core/c/*
libjcpuid-x86_64-solaris.so: built in solaris 11 x86 with

java 1.7.0_07 and gcc 4.5.2, stripped

  • Property mode set to 100755
File size: 3.1 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
22[ -z $CC ] && CC="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        KFREEBSD=0
39        UNIXTYPE="`uname -s | tr [A-Z] [a-z]`"
40        if [ ${UNIXTYPE} = "sunos" ]; then
41            UNIXTYPE="solaris"
42        elif [ ${UNIXTYPE} = "gnu/kfreebsd" ]; then
43            UNIXTYPE="linux"
44            KFREEBSD=1
45        fi
46        # If JAVA_HOME isn't set, try to figure it out on our own
47        [ -z $JAVA_HOME ] && . ../find-java-home
48        # JAVA_HOME being set doesn't guarantee that it's usable
49        if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
50            echo "Please ensure you have a Java SDK installed" >&2
51            echo "and/or set JAVA_HOME then re-run this script." >&2
52            exit 1
53        fi
54
55        # Abort script on uncaught errors
56        set -e
57
58        case `uname -m` in
59            x86_64*|amd64)
60                ARCH="x86_64";;
61            ia64*)
62                ARCH="ia64";;
63            i?86*)
64                ARCH="x86";;
65            # Solaris x86
66            i86pc)
67                if $(echo $CC | grep -q '\-m64') ; then
68                    ARCH="x86_64"
69                else
70                    ARCH="x86"
71                fi
72                ;;
73            *)
74                echo "Unsupported build environment. jcpuid is only used on x86 systems."
75                exit 0;;
76        esac
77
78        LINKFLAGS="-shared -Wl,-soname,libjcpuid-${ARCH}-${UNIXTYPE}.so"
79        if [ $KFREEBSD -eq 1 ]; then
80            LIBFILE="lib/freenet/support/CPUInformation/libjcpuid-${ARCH}-kfreebsd.so"
81        else
82            LIBFILE="lib/freenet/support/CPUInformation/libjcpuid-${ARCH}-${UNIXTYPE}.so"
83        fi
84        COMPILEFLAGS="-fPIC -Wall"
85        INCLUDES="-I. -Iinclude -I${JAVA_HOME}/include -I${JAVA_HOME}/include/${UNIXTYPE}";;
86esac
87
88echo "Compiling C code..."
89rm -f ${LIBFILE}
90${CC} ${COMPILEFLAGS} ${LINKFLAGS} ${INCLUDES} src/*.c -o ${LIBFILE} || (echo "Failed to compile ${LIBFILE}"; exit 1)
91strip ${LIBFILE} || (echo "Failed to strip ${LIBFILE}" ; exit 1)
92echo Built `dirname $0`/${LIBFILE}
Note: See TracBrowser for help on using the repository browser.