Ignore:
Timestamp:
Sep 27, 2011 8:25:32 AM (9 years ago)
Author:
kytv <kytv@…>
Branches:
master
Children:
40d3aa9
Parents:
57b30df
Message:

jcpuid build scripts:

  • merge x64 improvements from mbuild.sh into build.sh
  • drop mbuild.sh
  • add logic to determine the location of JAVA_HOME if not defined.
  • update core/c/mbuild to call jcpuid/build.sh
File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/c/jcpuid/build.sh

    r57b30df rb0ce258  
    1 #/bin/sh
     1#!/bin/sh
     2
     3cd `dirname $0`
    24
    35case `uname -sr` in
    4 MINGW*)
    5         echo "Building windows .dll's";;
    6 SunOS*)
    7         echo "Building solaris .so's";;
    8 CYGWIN*)
    9         echo "Building windows .dll's";;
    10 Linux*)
    11         echo "Building linux .so's";;
    12 FreeBSD*)
    13         echo "Building freebsd .so's";;
    14 *kFreeBSD*)
    15         echo "Building kFreebsd .so's";;
    16 *)
    17         echo "Unsupported build environment"
    18         exit;;
     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;;
    1917esac
    2018
    2119rm -rf lib
    22 mkdir lib
    23 mkdir lib/freenet
    24 mkdir lib/freenet/support
    25 mkdir lib/freenet/support/CPUInformation
     20mkdir -p lib/freenet/support/CPUInformation
    2621
    2722CC="gcc"
    2823
    2924case `uname -sr` in
    30 MINGW*)
    31         JAVA_HOME="/c/software/j2sdk1.4.2_05"
    32         COMPILEFLAGS="-Wall"
    33         INCLUDES="-I. -Iinclude -I$JAVA_HOME/include/ -I$JAVA_HOME/include/win32/"
    34         LINKFLAGS="-shared -static -static-libgcc -Wl,--kill-at"
    35         LIBFILE="lib/freenet/support/CPUInformation/jcpuid-x86-windows.dll";;
    36 SunOS*)
     25    MINGW*|CYGWIN*)
     26        JAVA_HOME="/c/software/j2sdk1.4.2_05"
    3727        COMPILEFLAGS="-Wall"
    38         INCLUDES="-I. -Iinclude -I$JAVA_HOME/include/ -I$JAVA_HOME/include/solaris/"
    39         LINKFLAGS="-shared -static -Wl,-soname,libjcpuid-x86-solaris.so"
    40         LIBFILE="lib/freenet/support/CPUInformation/libjcpuid-x86-solaris.so";;
    41 FreeBSD*)
    42         COMPILEFLAGS="-Wall"
    43         INCLUDES="-I. -Iinclude -I$JAVA_HOME/include/ -I$JAVA_HOME/include/freebsd/"
    44         LINKFLAGS="-shared -static -Wl,-soname,libjcpuid-x86-freebsd.so"
    45         LIBFILE="lib/freenet/support/CPUInformation/libjcpuid-x86-freebsd.so";;
    46 *kFreeBSD*|Linux*)
    47         COMPILEFLAGS="-fPIC -Wall"
    48         INCLUDES="-I. -Iinclude -I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
    49         LINKFLAGS="-shared -Wl,-soname,libjcpuid-x86-linux.so"
    50         LIBFILE="lib/freenet/support/CPUInformation/libjcpuid-x86-linux.so";;
     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
     45        # If JAVA_HOME is set elsewhere, obey it. Otherwise we'll try to
     46        # deduce its location ourselves.
     47        if [ -z "${JAVA_HOME}" ]; then
     48            if [ ${UNIXTYPE} = "freebsd" ]; then
     49                if [ -d /usr/local/openjdk6 ]; then
     50                    JAVA_HOME="/usr/local/openjdk6"
     51                elif [ -d /usr/local/openjdk7 ]; then
     52                    JAVA_HOME="/usr/local/openjdk7"
     53                fi
     54            elif [ ${UNIXTYPE} = "openbsd" ]; then # The default in 4.9
     55                if [ -d /usr/local/jdk-1.7.0 ]; then
     56                    JAVA_HOME="/usr/local/jdk-1.7.0"
     57                fi
     58            elif [ ${UNIXTYPE} = "netbsd" ]; then
     59                if [ -d /usr/pkg/java/openjdk7 ]; then
     60                    JAVA_HOME="/usr/pkg/java/openjdk7"
     61                fi
     62            elif [ ${UNIXTYPE} = "linux" -a -e /etc/debian_version ]; then
     63                if [ -d /usr/lib/jvm/default-java ]; then
     64                    JAVA_HOME="/usr/lib/jvm/default-java"
     65                fi
     66            fi
     67        fi
     68        case `uname -m` in
     69            x86_64*|amd64)
     70                ARCH="x86_64";;
     71            ia64*)
     72                ARCH="ia64";;
     73            i?86*)
     74                ARCH="x86";;
     75            *)
     76                echo "Unsupported build environment. jcpuid is only used on x86 systems."
     77                exit 1;;
     78        esac
     79
     80        # JAVA_HOME being set doesn't guarantee that it's usable
     81        if [ ! -r ${JAVA_HOME}/include/jni.h ]; then
     82            echo "Please ensure you have a Java SDK installed"
     83            echo "and/or set JAVA_HOME then re-run this script."
     84            exit 1
     85        fi
     86        LINKFLAGS="-shared -Wl,-soname,libjcpuid-${ARCH}-${UNIXTYPE}.so"
     87        LIBFILE="lib/freenet/support/CPUInformation/libjcpuid-${ARCH}-${UNIXTYPE}.so"
     88        COMPILEFLAGS="-fPIC -Wall"
     89        INCLUDES="-I. -Iinclude -I${JAVA_HOME}/include -I${JAVA_HOME}/include/${UNIXTYPE}";;
    5190esac
    5291
    5392echo "Compiling C code..."
    54 rm -f $LIBFILE
    55 $CC $COMPILEFLAGS $LINKFLAGS $INCLUDES src/*.c -o $LIBFILE
    56 strip $LIBFILE
    57 echo Built $LIBFILE
    58 
    59 #g++ -shared -static -static-libgcc -Iinclude -I$JAVA_HOME/include \
    60 #    -I$JAVA_HOME/include/linux src/*.cpp \
    61 #    -o lib/freenet/support/CPUInformation/libjcpuid-x86-linux.so
     93rm -f ${LIBFILE}
     94${CC} ${COMPILEFLAGS} ${LINKFLAGS} ${INCLUDES} src/*.c -o ${LIBFILE} || (echo "Failed to compile ${LIBFILE}"; exit 1)
     95strip ${LIBFILE} || (echo "Failed to strip ${LIBFILE}" ; exit 1)
     96echo Built `dirname $0`/${LIBFILE}
Note: See TracChangeset for help on using the changeset viewer.