Changeset c1da7f7 for core/c


Ignore:
Timestamp:
May 12, 2013 12:08:52 AM (7 years ago)
Author:
kytv <kytv@…>
Branches:
master
Children:
b096834
Parents:
dca5e98
Message:

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

Location:
core/c
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • core/c/find-java-home

    rdca5e98 rc1da7f7  
    55    elif [ -d /usr/local/openjdk7 ]; then
    66        JAVA_HOME="/usr/local/openjdk7"
     7    fi
     8elif [ $UNIXTYPE = "sunos" ]; then
     9    UNIXTYPE="solaris"
     10    if [ -d /usr/jdk/latest/ ]; then
     11        JAVA_HOME="/usr/jdk/latest"
     12    elif [ -d /usr/jdk/instances/jdk1.7.0/ ]; then
     13        JAVA_HOME="/usr/jdk/instances/jdk1.7.0"
     14    elif [ -d /usr/jdk/instances/jdk1.6.0 ]; then
     15        JAVA_HOME="/usr/jdk/instances/jdk1.6.0"
    716    fi
    817elif [ $UNIXTYPE = "openbsd" ]; then
     
    2736    JAVA_HOME=$(/usr/libexec/java_home)
    2837elif [ $UNIXTYPE = "gnu/kfreebsd" ]; then
     38    UNIXTYPE="linux"
    2939    if [ -d /usr/lib/jvm/java-gcj ]; then
    3040        JAVA_HOME="/usr/lib/jvm/java-gcj"
     
    3242fi
    3343
    34 export JAVA_HOME
     44export JAVA_HOME UNIXTYPE
  • core/c/jbigi/build_jbigi.sh

    rdca5e98 rc1da7f7  
    33# When executed in Linux/FreeBSD: Produces a libjbigi.so
    44# When executed in OSX: Produces a libjbigi.jnilib
    5 CC="gcc"
     5[ -z "$CC" ] && CC="gcc"
    66
    77# If JAVA_HOME isn't set we'll try to figure it out
     
    3939            UNIXTYPE="linux"
    4040        fi
    41         COMPILEFLAGS="-fPIC -Wall"
     41        COMPILEFLAGS="-fPIC -Wall $CFLAGS"
    4242        INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE}"
    4343        LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
  • core/c/jbigi/mbuild-all.sh

    rdca5e98 rc1da7f7  
    11#!/bin/sh
    22
    3 # If JAVA_HOME isn't set we'll try to figure it out
    4 [ -z $JAVA_HOME ] && . ../find-java-home
    5 if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
    6     echo "Cannot find jni.h! Looked in '$JAVA_HOME/include/jni.h'"
    7     echo "Please set JAVA_HOME to a java home that has the JNI"
    8     exit 1
    9 fi
    10 
    11 #FIXME What platforms for MacOS?
     3# ON Solaris 11 (at least) this variable must be set.
     4# Linux and *BSD will do the right thing.
     5#
     6#BITS=32
     7
     8# FIXME Is this all?
     9DARWIN_PLATFORMS="core2 corei"
    1210MISC_DARWIN_PLATFORMS="powerpc powerpc64 powerpc64le powerpcle"
    1311
     
    4543# Note! these are 32bit _ONLY_
    4644X86_PLATFORMS="pentium pentiummmx pentium2 pentium3 pentiumm k6 k62 k63 athlon geode viac3 viac32 ${X86_64_PLATFORMS}"
    47 
    48 
    49 #
    50 # You should not need to edit anything below this comment.
    51 #
    52 
    53 # The built-in echo in /bin/sh (the real bourne shell) on BSD systems supports -e.
    54 # The built-in echo in dash (the default /bin/sh on Debian) does not support -e
    55 # but /bin/echo always supports -e in Linux; therefore, let's set echo to /bin/echo
    56 # whenever we're on Linux and use the shell's built-in "echo" on everything else.
    57 
    58 if [ $(uname -s |tr "[A-Z]" "[a-z]") = "linux" ]; then
    59         ECHO="/bin/echo"
    60 elif [ $(uname -s |tr "[A-Z]" "[a-z]") = "gnu/kfreebsd" ]; then
    61         ECHO="/bin/echo"
    62 else
    63         ECHO="echo"
    64 fi
    6545
    6646MINGW_PLATFORMS="${X86_PLATFORMS} ${MISC_MINGW_PLATFORMS}"
     
    7151OPENBSD_PLATFORM="${X86_PLATFORMS} ${MISC_OPENBSD_PLATFORMS}"
    7252
    73 # FIXME Is this all?
    74 DARWIN_PLATFORMS="core2 corei"
     53#
     54# You should not need to edit anything below this comment.
     55#
     56
     57# If JAVA_HOME isn't set we'll try to figure it out
     58[ -z $JAVA_HOME ] && . ../find-java-home
     59if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
     60    echo "Cannot find jni.h! Looked in '$JAVA_HOME/include/jni.h'" >&2
     61    echo "Please set JAVA_HOME to a java home that has the JNI" >&2
     62    exit 1
     63fi
     64
     65if [ ! $(which m4)  ]; then
     66    printf "\aWARNING: \`m4\` not found. If this process fails to complete, install m4 " >&2
     67    printf "and re-run this script.\n\n\n\a" >&2
     68    sleep 10
     69fi
     70
     71
     72# Allow TARGET to be overridden (e.g. for use with cross compilers)
     73[ -z $TARGET ] && TARGET=$(uname -s |tr "[A-Z]" "[a-z]")
     74
    7575
    7676# Set the version to 5.0.2 for OSX because AFAIK there are only 64bit capable CPUs for the Intel Macs
    77 if [ `uname -s |grep Darwin` ]; then
     77# FIXME do this without sed (and tail) (= portably)
     78if [ `echo $TARGET|grep darwin` ]; then
    7879        VER=5.0.2
     80elif [ `echo $TARGET|grep sunos` ]; then
     81        VER=$(echo gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | /usr/xpg4/bin/tail -n 1)
    7982else
    80         VER=$($ECHO gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | tail -n 1)
     83        VER=$(echo gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | tail -n 1)
    8184fi
    8285
    8386if [ "$VER" = "" ] ; then
    84         $ECHO "ERROR! Can't find gmp source tarball."
     87        echo "ERROR! Can't find gmp source tarball."
    8588        exit 1
    8689fi
    8790
    88 
    89 case `uname -s` in
    90 MINGW*)
     91# If the BITS variable isn't set above we'll proceed without setting the *FLAGS
     92# variables ourselves.
     93[ -z $BITS ] && BITS=0
     94
     95if [ $BITS -eq 32 ]; then
     96    export CC="gcc -m32"
     97    export CFLAGS="-m32"
     98    export LDFLAGS="-m32"
     99    SUFFIX=
     100elif [ $BITS -eq 64 ]; then
     101    export CC="gcc -m64"
     102    export CFLAGS="-m64"
     103fi
     104
     105case "$TARGET" in
     106mingw*)
    91107        PLATFORM_LIST="${MINGW_PLATFORMS}"
    92108        NAME="jbigi"
    93109        TYPE="dll"
    94110        TARGET="windows"
    95         $ECHO "Building windows .dlls for all architectures";;
    96 Darwin*)
     111        echo "Building windows .dlls for all architectures";;
     112darwin*)
    97113        PLATFORM_LIST="${DARWIN_PLATFORMS}"
    98114        NAME="libjbigi"
    99115        TYPE="jnilib"
    100116        TARGET="osx"
    101         $ECHO "Building ${TARGET} .jnilibs for all architectures";;
    102 Linux*|*kFreeBSD)
     117        echo "Building ${TARGET} .jnilibs for all architectures";;
     118sunos*)
     119        PLATFORM_LIST="${X86_64_PLATFORMS}"
     120        NAME="libjbigi"
     121        TYPE="so"
     122        UNIXTYPE="solaris"
     123        TARGET="${UNIXTYPE}"
     124        if $(echo "$CFLAGS" | grep -q "\-m64") ; then
     125            [ -z $SUFFIX ] && SUFFIX="_64"
     126            PLATFORM_LIST="${X86_64_PLATFORMS}"
     127        else
     128            PLATFORM_LIST="${X86_PLATFORMS}"
     129        fi
     130        echo "Building ${TARGET} .sos for all architectures";;
     131linux*|*kfreebsd)
    103132        NAME="libjbigi"
    104133        TYPE="so"
    105134        PLATFORM_LIST=""
    106         if [ $(uname -s | tr "[A-Z]" "[a-z]") = "gnu/kfreebsd" ]; then
     135        case "$TARGET" in
     136            *kfreebsd)
    107137                TARGET="kfreebsd"
    108         else
     138                ;;
     139            *)
    109140                TARGET="linux"
    110         fi
     141                ;;
     142        esac
    111143        arch=$(uname -m | cut -f1 -d" ")
    112144        case ${arch} in
     
    117149                x86_64 | amd64)
    118150                        PLATFORM_LIST="${X86_64_PLATFORMS}"
    119                         TARGET="$TARGET-X86_64";;
    120                 ia64)
    121                         PLATFORM_LIST="${X86_64_PLATFORMS}"
    122                         TARGET="$TARGET-ia64";;
     151                        if [ $BITS -ne 32 ]; then
     152                            [ -z $SUFFIX ] && SUFFIX="_64"
     153                        fi
     154                        ;;
     155                #ia64)
     156                #        PLATFORM_LIST="${X86_64_PLATFORMS}"
     157                #        TARGET="$TARGET-ia64";;
    123158                x86)
    124                         PLATFORM_LIST="${X86_PLATFORMS}"
    125                         TARGET="$TARGET-x86";;
     159                        PLATFORM_LIST="${X86_PLATFORMS}";;
    126160                *)
    127161                        PLATFORM_LIST="${LINUX_PLATFORMS}";;
    128162        esac
    129         $ECHO "Building ${TARGET} .sos for ${arch}";;
    130 NetBSD*|FreeBSD*|OpenBSD*)
     163        echo "Building ${TARGET} .sos for ${arch}";;
     164netbsd*|freebsd*|openbsd*)
    131165        NAME="libjbigi"
    132166        TYPE="so"
    133         PLATFORM_LIST=""
    134         BSDTYPE=$(uname -s | tr "[A-Z]" "[a-z]")
     167        PLATFORM_LIST=
    135168        arch=$(uname -m | cut -f1 -d" ")
    136169        case ${arch} in
     
    141174                x86_64|amd64)
    142175                        PLATFORM_LIST="${X86_64_PLATFORMS}"
    143                         TARGET="${BSDTYPE}-X86_64";;
    144                 ia64)
    145                         PLATFORM_LIST="${X86_64_PLATFORMS}"
    146                         TARGET="${BSDTYPE}-ia64";;
     176                       [ -z $SUFFIX ] && SUFFIX="_64";;
     177                #ia64)
     178                #        PLATFORM_LIST="${X86_64_PLATFORMS}"
     179                #        SUFFIX="{SYS}-ia64";;
    147180                x86)
    148                         PLATFORM_LIST="${X86_PLATFORMS}"
    149                         TARGET="${BSDTYPE}-x86";;
     181                        PLATFORM_LIST="${X86_PLATFORMS}";;
    150182                *)
    151                         case ${BSDTYPE} in
     183                        case ${TARGET} in
    152184                                netbsd)
    153185                                        PLATFORM_LIST="${NETBSD_PLATFORMS}";;
     
    157189                                        PLATFORM_LIST="${FREEBSD_PLATFORMS}";;
    158190                                *)
    159                                         $ECHO "Unsupported build environment"
     191                                        echo "Unsupported build environment"
    160192                                        exit 1;;
    161193                        esac
    162194        esac
    163         $ECHO "Building ${BSDTYPE} .sos for ${arch}";;
     195        echo "Building ${TARGET} .sos for ${arch}";;
    164196*)
    165         $ECHO "Unsupported build environment"
     197        echo "Unsupported build environment"
    166198        exit;;
    167199esac
    168200
     201#####################
     202# In the below functions:
     203# $1 = gmp version
     204# $2 = platform: such as athlon64
     205# $3 = basename: "jbigi" on Windows, "libjbigi" everywhere else
     206# $4 = type/extension: windows = "dll". osx = "jnilib". Everything else = "so"
     207# $5 = target: "linux", "freebsd", "kfreebsd", "osx", "windows", etc.
     208# $6 = suffix: null if 32bit, _64 if 64bit
     209
    169210make_static () {
    170         #
    171         # TODO
    172         # Fix formatting of output filename. Final versions will need to look
    173         # like libjbigi-linux-athlon64.so or libjbigi-linux-athlon64_64.so
    174         $ECHO "Attempting .${4} creation for ${3}${5}${2}"
     211        echo "Attempting .${4} creation for ${3}${5}${2}${6}"
    175212        ../../build_jbigi.sh static || return 1
    176         cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}.${4}
     213        cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}${6}.${4}
    177214        return 0
    178215}
     
    180217make_file () {
    181218        # Nonfatal bail out on Failed build.
    182         $ECHO "Attempting build for ${3}${5}${2}"
     219        echo "Attempting build for ${3}${5}${2}"
    183220        make && return 0
    184221        cd ..
    185222        rm -R "$2"
    186         $ECHO -e "\n\nFAILED! ${3}${5}${2} not made.\a"
     223        printf "\n\nFAILED! ${3}${5}${2} not made.\a"
    187224        sleep 10
    188225        return 1
     
    190227
    191228configure_file () {
    192         $ECHO -e "\n\n\nAttempting configure for ${3}${5}${2}\n\n\n"
     229        printf "\n\n\nAttempting configure for ${3}${5}${2}${6}\n\n\n"
     230        if [ $BITS -eq 32 ] && [ "$2"  = "none" ]; then
     231            unset ABI
     232        elif [ $BITS -eq 32 ] && [ "$2" != "none" ]; then
     233            export ABI=32
     234        fi
    193235        sleep 10
    194236        # Nonfatal bail out on unsupported platform.
    195         if [ `uname -s |grep Darwin` ]; then
     237        if [ $(echo $TARGET| grep -q osx) ]; then
    196238                ../../gmp-${1}/configure --build=${2}-apple-darwin --with-pic && return 0
    197239        else
     
    200242        cd ..
    201243        rm -R "$2"
    202         $ECHO -e "\n\nSorry, ${3}${5}${2} is not supported on your build environment.\a"
     244        printf "\n\nSorry, ${3}${5}${2} is not supported on your build environment.\a"
    203245        sleep 10
    204246        return 1
     
    206248
    207249build_file () {
    208         configure_file "$1" "$2" "$3" "$4" "$5"  && make_file "$1" "$2" "$3" "$4" "$5" && make_static "$1" "$2" "$3" "$4" "$5" && return 0
    209         $ECHO -e "\n\n\nError building static!\n\n\a"
     250        configure_file "$1" "$2" "$3" "$4" "$5" "$6"  && make_file "$1" "$2" "$3" "$4" "$5" "$6" && make_static "$1" "$2" "$3" "$4" "$5" "$6" && return 0
     251        printf "\n\n\nError building static!\n\n\a"
    210252        sleep 10
    211253        return 1
    212254}
    213255
    214 $ECHO "Extracting GMP Version $VER ..."
    215 tar -xjf gmp-$VER.tar.bz2 || ( $ECHO "Error in tarball file!" ; exit 1 )
     256echo "Extracting GMP Version $VER ..."
     257if [ -e gmp-$VER.tar.bz2 ]; then
     258    tar -xjf gmp-$VER.tar.bz2 || ( echo "Error in tarball file!" >&2 ; exit 1 )
     259else
     260    echo "ERROR: gmp tarball not found in current directory" >&2
     261    exit 1
     262fi
    216263
    217264if [ ! -d bin ]; then
     
    236283                fi
    237284
    238                 build_file "$VER" "$x" "$NAME" "$TYPE" "-$TARGET-"
     285                build_file "$VER" "$x" "$NAME" "$TYPE" "-$TARGET-" "$SUFFIX"
    239286        )
    240287done
    241288
    242 $ECHO "Success!"
     289echo "Success!"
    243290exit 0
     291
     292# vim:fenc=utf-8:ai:si:ts=4:sw=4:et:nu
  • core/c/jcpuid/build.sh

    rdca5e98 rc1da7f7  
    2020mkdir -p lib/freenet/support/CPUInformation
    2121
    22 CC="gcc"
     22[ -z $CC ] && CC="gcc"
    2323
    2424case `uname -s` in
     
    6363            i?86*)
    6464                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                ;;
    6573            *)
    6674                echo "Unsupported build environment. jcpuid is only used on x86 systems."
Note: See TracChangeset for help on using the changeset viewer.