source: core/c/jbigi/mbuild-all.sh @ c1da7f7

Last change on this file since c1da7f7 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: 9.1 KB
Line 
1#!/bin/sh
2
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"
10MISC_DARWIN_PLATFORMS="powerpc powerpc64 powerpc64le powerpcle"
11
12# Note: You will have to add the CPU ID for the platform in the CPU ID code
13# for a new CPU. Just adding them here won't let I2P use the code!
14
15#
16# If you know of other platforms i2p on linux works on,
17# please add them here.
18# Do NOT add any X86 platforms, do that below in the x86 platform list.
19#
20MISC_LINUX_PLATFORMS="hppa2.0 alphaev56 armv5tel mips64el itanium itanium2 ultrasparc2 ultrasparc2i alphaev6 powerpc970 powerpc7455 powerpc7447"
21
22#
23# If you know of other platforms i2p on *BSD works on,
24# please add them here.
25# Do NOT add any X86 platforms, do that below in the x86 platform list.
26#
27MISC_FREEBSD_PLATFORMS="alphaev56 ultrasparc2i"
28MISC_NETBSD_PLATFORMS="armv5tel mips64el ultrasparc2i sgi hppa2.0 alphaev56 powerpc powerpc64 powerpc64le powerpcle atari amiga m68knommu" # and many, many more
29MISC_OPENBSD_PLATFORMS="alphaev56 ultrasparc2i sgi powerpc powerpc64 hppa2.0 alphaev56 armv5tel mips64el"
30
31#
32# MINGW/Windows??
33#
34MISC_MINGW_PLATFORMS=""
35
36#
37# Are there any other X86 platforms that work on i2p? Add them here.
38#
39
40# Note! these build on 32bit as 32bit when operating as 32bit...
41X86_64_PLATFORMS="atom athlon64 core2 corei nano pentium4"
42
43# Note! these are 32bit _ONLY_
44X86_PLATFORMS="pentium pentiummmx pentium2 pentium3 pentiumm k6 k62 k63 athlon geode viac3 viac32 ${X86_64_PLATFORMS}"
45
46MINGW_PLATFORMS="${X86_PLATFORMS} ${MISC_MINGW_PLATFORMS}"
47LINUX_PLATFORMS="${X86_PLATFORMS} ${MISC_LINUX_PLATFORMS}"
48FREEBSD_PLATFORMS="${X86_PLATFORMS} ${MISC_FREEBSD_PLATFORMS}"
49# As they say, "Of course it runs NetBSD!"
50NETBSD_PLATFORMS="${FREEBSD_PLATFORMS} ${MISC_LINUX_PLATFORMS} ${MISC_NETBSD_PLATFORMS}"
51OPENBSD_PLATFORM="${X86_PLATFORMS} ${MISC_OPENBSD_PLATFORMS}"
52
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
75
76# Set the version to 5.0.2 for OSX because AFAIK there are only 64bit capable CPUs for the Intel Macs
77# FIXME do this without sed (and tail) (= portably)
78if [ `echo $TARGET|grep darwin` ]; then
79        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)
82else
83        VER=$(echo gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | tail -n 1)
84fi
85
86if [ "$VER" = "" ] ; then
87        echo "ERROR! Can't find gmp source tarball."
88        exit 1
89fi
90
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*)
107        PLATFORM_LIST="${MINGW_PLATFORMS}"
108        NAME="jbigi"
109        TYPE="dll"
110        TARGET="windows"
111        echo "Building windows .dlls for all architectures";;
112darwin*)
113        PLATFORM_LIST="${DARWIN_PLATFORMS}"
114        NAME="libjbigi"
115        TYPE="jnilib"
116        TARGET="osx"
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)
132        NAME="libjbigi"
133        TYPE="so"
134        PLATFORM_LIST=""
135        case "$TARGET" in
136            *kfreebsd)
137                TARGET="kfreebsd"
138                ;;
139            *)
140                TARGET="linux"
141                ;;
142        esac
143        arch=$(uname -m | cut -f1 -d" ")
144        case ${arch} in
145                i[3-6]86)
146                        arch="x86";;
147        esac
148        case ${arch} in
149                x86_64 | amd64)
150                        PLATFORM_LIST="${X86_64_PLATFORMS}"
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";;
158                x86)
159                        PLATFORM_LIST="${X86_PLATFORMS}";;
160                *)
161                        PLATFORM_LIST="${LINUX_PLATFORMS}";;
162        esac
163        echo "Building ${TARGET} .sos for ${arch}";;
164netbsd*|freebsd*|openbsd*)
165        NAME="libjbigi"
166        TYPE="so"
167        PLATFORM_LIST=
168        arch=$(uname -m | cut -f1 -d" ")
169        case ${arch} in
170                i[3-6]86)
171                        arch="x86";;
172        esac
173        case ${arch} in
174                x86_64|amd64)
175                        PLATFORM_LIST="${X86_64_PLATFORMS}"
176                       [ -z $SUFFIX ] && SUFFIX="_64";;
177                #ia64)
178                #        PLATFORM_LIST="${X86_64_PLATFORMS}"
179                #        SUFFIX="{SYS}-ia64";;
180                x86)
181                        PLATFORM_LIST="${X86_PLATFORMS}";;
182                *)
183                        case ${TARGET} in
184                                netbsd)
185                                        PLATFORM_LIST="${NETBSD_PLATFORMS}";;
186                                openbsd)
187                                        PLATFORM_LIST="${OPENBSD_PLATFORMS}";;
188                                freebsd)
189                                        PLATFORM_LIST="${FREEBSD_PLATFORMS}";;
190                                *)
191                                        echo "Unsupported build environment"
192                                        exit 1;;
193                        esac
194        esac
195        echo "Building ${TARGET} .sos for ${arch}";;
196*)
197        echo "Unsupported build environment"
198        exit;;
199esac
200
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
210make_static () {
211        echo "Attempting .${4} creation for ${3}${5}${2}${6}"
212        ../../build_jbigi.sh static || return 1
213        cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}${6}.${4}
214        return 0
215}
216
217make_file () {
218        # Nonfatal bail out on Failed build.
219        echo "Attempting build for ${3}${5}${2}"
220        make && return 0
221        cd ..
222        rm -R "$2"
223        printf "\n\nFAILED! ${3}${5}${2} not made.\a"
224        sleep 10
225        return 1
226}
227
228configure_file () {
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
235        sleep 10
236        # Nonfatal bail out on unsupported platform.
237        if [ $(echo $TARGET| grep -q osx) ]; then
238                ../../gmp-${1}/configure --build=${2}-apple-darwin --with-pic && return 0
239        else
240                ../../gmp-${1}/configure --build=${2} --with-pic && return 0
241        fi
242        cd ..
243        rm -R "$2"
244        printf "\n\nSorry, ${3}${5}${2} is not supported on your build environment.\a"
245        sleep 10
246        return 1
247}
248
249build_file () {
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"
252        sleep 10
253        return 1
254}
255
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
263
264if [ ! -d bin ]; then
265        mkdir bin
266fi
267if [ ! -d lib/net/i2p/util ]; then
268        mkdir -p lib/net/i2p/util
269fi
270
271# Don't touch this one.
272NO_PLATFORM=none
273
274for x in $NO_PLATFORM $PLATFORM_LIST
275do
276        (
277                if [ ! -d bin/$x ]; then
278                        mkdir bin/$x
279                        cd bin/$x
280                else
281                        cd bin/$x
282                        rm -Rf *
283                fi
284
285                build_file "$VER" "$x" "$NAME" "$TYPE" "-$TARGET-" "$SUFFIX"
286        )
287done
288
289echo "Success!"
290exit 0
291
292# vim:fenc=utf-8:ai:si:ts=4:sw=4:et:nu
Note: See TracBrowser for help on using the repository browser.