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

Last change on this file since 9134d28 was 9134d28, checked in by dev <dev@…>, 5 years ago

Don't unpack gmp before every build. Do a distclean instead.

  • Property mode set to 100755
File size: 9.9 KB
Line 
1#!/bin/sh
2#
3# Run with BITS=32 to generate 32-bit libs on a 64-bit platform
4# On Ubuntu you will need sudo apt-get install gcc-multilib libc6-i386 libc6-dev-i386
5#
6
7# ON Solaris 11 (at least) this variable must be set.
8# Linux and *BSD will do the right thing.
9#
10#BITS=32
11
12#
13# look in configure file in gmp source for supported host CPUs, at about line 5000
14#
15
16# FIXME Is this all?
17DARWIN_PLATFORMS="core2 corei"
18MISC_DARWIN_PLATFORMS="powerpc powerpc64 powerpc64le powerpcle"
19
20# Note: You will have to add the CPU ID for the platform in the CPU ID code
21# for a new CPU. Just adding them here won't let I2P use the code!
22
23#
24# If you know of other platforms i2p on linux works on,
25# please add them here.
26# Do NOT add any X86 platforms, do that below in the x86 platform list.
27#
28MISC_LINUX_PLATFORMS="hppa2.0 alphaev56 armv5tel mips64el itanium itanium2 ultrasparc2 ultrasparc2i alphaev6 powerpc970 powerpc7455 powerpc7447"
29
30#
31# If you know of other platforms i2p on *BSD works on,
32# please add them here.
33# Do NOT add any X86 platforms, do that below in the x86 platform list.
34#
35MISC_FREEBSD_PLATFORMS="alphaev56 ultrasparc2i"
36MISC_NETBSD_PLATFORMS="armv5tel mips64el ultrasparc2i sgi hppa2.0 alphaev56 powerpc powerpc64 powerpc64le powerpcle atari amiga m68knommu" # and many, many more
37MISC_OPENBSD_PLATFORMS="alphaev56 ultrasparc2i sgi powerpc powerpc64 hppa2.0 alphaev56 armv5tel mips64el"
38
39#
40# MINGW/Windows??
41#
42MISC_MINGW_PLATFORMS=""
43
44#
45# Are there any other X86 platforms that work on i2p? Add them here.
46#
47# Note! these build on 32bit as 32bit when operating as 32bit...
48# starting with k10 added for 6.0.0
49# As of GMP 6.0.0, libgmp 3,
50# the following architectures appear to build to identical code:
51#    coreisbr coreihwl coreibwl
52#    core2 corei
53#    bulldozer piledriver streamroller excavator
54#    bobcat jaguar
55#    k62 k63
56#    viac32 pentium3
57#
58# Even more duplicates are in 32-bit mode, so it doesn't pay to have everything for 32 bit.
59#
60X86_64_PLATFORMS="coreisbr coreihwl coreibwl bobcat jaguar bulldozer piledriver steamroller excavator atom athlon64 core2 corei nano pentium4 k10"
61
62# Note! these are 32bit _ONLY_ (after the 64 bit ones)
63X86_PLATFORMS="${X86_64_PLATFORMS} pentium pentiummmx pentium2 pentium3 pentiumm k6 k62 k63 athlon geode viac3 viac32"
64
65MINGW_PLATFORMS="${X86_PLATFORMS} ${MISC_MINGW_PLATFORMS}"
66LINUX_PLATFORMS="${X86_PLATFORMS} ${MISC_LINUX_PLATFORMS}"
67FREEBSD_PLATFORMS="${X86_PLATFORMS} ${MISC_FREEBSD_PLATFORMS}"
68# As they say, "Of course it runs NetBSD!"
69NETBSD_PLATFORMS="${FREEBSD_PLATFORMS} ${MISC_LINUX_PLATFORMS} ${MISC_NETBSD_PLATFORMS}"
70OPENBSD_PLATFORM="${X86_PLATFORMS} ${MISC_OPENBSD_PLATFORMS}"
71
72#
73# You should not need to edit anything below this comment.
74#
75
76# If JAVA_HOME isn't set we'll try to figure it out
77[ -z $JAVA_HOME ] && . ../find-java-home
78if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
79    echo "Cannot find jni.h! Looked in '$JAVA_HOME/include/jni.h'" >&2
80    echo "Please set JAVA_HOME to a java home that has the JNI" >&2
81    exit 1
82fi
83
84if [ ! $(which m4)  ]; then
85    printf "\aWARNING: \`m4\` not found. If this process fails to complete, install m4 " >&2
86    printf "and re-run this script.\n\n\n\a" >&2
87    sleep 10
88fi
89
90
91# Allow TARGET to be overridden (e.g. for use with cross compilers)
92[ -z $TARGET ] && TARGET=$(uname -s |tr "[A-Z]" "[a-z]")
93
94
95# Set the version to 5.0.2 for OSX because AFAIK there are only 64bit capable CPUs for the Intel Macs
96# FIXME do this without sed (and tail) (= portably)
97if [ `echo $TARGET|grep darwin` ]; then
98        VER=5.0.2
99elif [ `echo $TARGET|grep sunos` ]; then
100        VER=$(echo gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | /usr/xpg4/bin/tail -n 1)
101else
102        VER=$(echo gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | tail -n 1)
103fi
104
105if [ "$VER" = "" ] ; then
106        echo "ERROR! Can't find gmp source tarball."
107        exit 1
108fi
109
110# If the BITS variable isn't set above we'll proceed without setting the *FLAGS
111# variables ourselves.
112[ -z $BITS ] && BITS=0
113
114if [ $BITS -eq 32 ]; then
115    export CC="gcc -m32"
116    export CFLAGS="-m32"
117    export LDFLAGS="-m32"
118    SUFFIX=
119elif [ $BITS -eq 64 ]; then
120    export CC="gcc -m64"
121    export CFLAGS="-m64"
122fi
123
124case "$TARGET" in
125mingw*)
126        PLATFORM_LIST="${MINGW_PLATFORMS}"
127        NAME="jbigi"
128        TYPE="dll"
129        TARGET="windows"
130        echo "Building windows .dlls for all architectures";;
131darwin*)
132        PLATFORM_LIST="${DARWIN_PLATFORMS}"
133        NAME="libjbigi"
134        TYPE="jnilib"
135        TARGET="osx"
136        echo "Building ${TARGET} .jnilibs for all architectures";;
137sunos*)
138        PLATFORM_LIST="${X86_64_PLATFORMS}"
139        NAME="libjbigi"
140        TYPE="so"
141        UNIXTYPE="solaris"
142        TARGET="${UNIXTYPE}"
143        if $(echo "$CFLAGS" | grep -q "\-m64") ; then
144            [ -z $SUFFIX ] && SUFFIX="_64"
145            PLATFORM_LIST="${X86_64_PLATFORMS}"
146        else
147            PLATFORM_LIST="${X86_PLATFORMS}"
148        fi
149        echo "Building ${TARGET} .sos for all architectures";;
150linux*|*kfreebsd)
151        NAME="libjbigi"
152        TYPE="so"
153        PLATFORM_LIST=""
154        case "$TARGET" in
155            *kfreebsd)
156                TARGET="kfreebsd"
157                ;;
158            *)
159                TARGET="linux"
160                ;;
161        esac
162        arch=$(uname -m | cut -f1 -d" ")
163        case ${arch} in
164                i[3-6]86)
165                        arch="x86";;
166        esac
167        case ${arch} in
168                x86_64 | amd64)
169                        PLATFORM_LIST="${X86_64_PLATFORMS}"
170                        if [ $BITS -ne 32 ]; then
171                            [ -z $SUFFIX ] && SUFFIX="_64"
172                        fi
173                        ;;
174                #ia64)
175                #        PLATFORM_LIST="${X86_64_PLATFORMS}"
176                #        TARGET="$TARGET-ia64";;
177                x86)
178                        PLATFORM_LIST="${X86_PLATFORMS}";;
179                *)
180                        PLATFORM_LIST="${LINUX_PLATFORMS}";;
181        esac
182        echo "Building ${TARGET} .sos for ${arch}";;
183netbsd*|freebsd*|openbsd*)
184        NAME="libjbigi"
185        TYPE="so"
186        PLATFORM_LIST=
187        arch=$(uname -m | cut -f1 -d" ")
188        case ${arch} in
189                i[3-6]86)
190                        arch="x86";;
191        esac
192        case ${arch} in
193                x86_64|amd64)
194                        PLATFORM_LIST="${X86_64_PLATFORMS}"
195                       [ -z $SUFFIX ] && SUFFIX="_64";;
196                #ia64)
197                #        PLATFORM_LIST="${X86_64_PLATFORMS}"
198                #        SUFFIX="{SYS}-ia64";;
199                x86)
200                        PLATFORM_LIST="${X86_PLATFORMS}";;
201                *)
202                        case ${TARGET} in
203                                netbsd)
204                                        PLATFORM_LIST="${NETBSD_PLATFORMS}";;
205                                openbsd)
206                                        PLATFORM_LIST="${OPENBSD_PLATFORMS}";;
207                                freebsd)
208                                        PLATFORM_LIST="${FREEBSD_PLATFORMS}";;
209                                *)
210                                        echo "Unsupported build environment"
211                                        exit 1;;
212                        esac
213        esac
214        echo "Building ${TARGET} .sos for ${arch}";;
215*)
216        echo "Unsupported build environment"
217        exit;;
218esac
219
220#####################
221# In the below functions:
222# $1 = gmp version
223# $2 = platform: such as athlon64
224# $3 = basename: "jbigi" on Windows, "libjbigi" everywhere else
225# $4 = type/extension: windows = "dll". osx = "jnilib". Everything else = "so"
226# $5 = target: "linux", "freebsd", "kfreebsd", "osx", "windows", etc.
227# $6 = suffix: null if 32bit, _64 if 64bit
228
229make_static () {
230        echo "Attempting .${4} creation for ${3}${5}${2}${6}"
231        ../../build_jbigi.sh static || return 1
232        cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}${6}.${4}
233        return 0
234}
235
236make_file () {
237        # Nonfatal bail out on Failed build.
238        echo "Attempting build for ${3}${5}${2}"
239        make && return 0
240        cd ..
241        rm -R "$2"
242        printf "\n\nFAILED! ${3}${5}${2} not made.\a"
243        sleep 10
244        return 1
245}
246
247configure_file () {
248        printf "\n\n\nAttempting configure for ${3}${5}${2}${6}\n\n\n"
249        if [ $BITS -eq 32 ] && [ "$2"  = "none" ]; then
250            unset ABI
251        elif [ $BITS -eq 32 ] && [ "$2" != "none" ]; then
252            export ABI=32
253        fi
254        sleep 10
255        # Nonfatal bail out on unsupported platform.
256        (cd ../../gmp-${1}; make distclean)
257        if [ $(echo $TARGET| grep -q osx) ]; then
258                ../../gmp-${1}/configure --build=${2}-apple-darwin --with-pic && return 0
259        else
260                ../../gmp-${1}/configure --build=${2} --with-pic && return 0
261        fi
262        cd ..
263        rm -R "$2"
264        printf "\n\nSorry, ${3}${5}${2} is not supported on your build environment.\a"
265        sleep 10
266        return 1
267}
268
269build_file () {
270        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
271        printf "\n\n\nError building static!\n\n\a"
272        sleep 10
273        return 1
274}
275
276if [ ! -d gmp-$VER ]; then
277  echo "Extracting GMP Version $VER ..."
278  if [ -e gmp-$VER.tar.bz2 ]; then
279    tar -xjf gmp-$VER.tar.bz2 || ( echo "Error in tarball file!" >&2 ; exit 1 )
280  else
281    echo "ERROR: gmp tarball not found in current directory" >&2
282    exit 1
283  fi
284fi
285
286if [ ! -d bin ]; then
287        mkdir bin
288fi
289if [ ! -d lib/net/i2p/util ]; then
290        mkdir -p lib/net/i2p/util
291fi
292
293# Don't touch this one.
294NO_PLATFORM=none
295
296for x in $PLATFORM_LIST $NO_PLATFORM
297do
298        (
299                if [ ! -d bin/$x ]; then
300                        mkdir bin/$x
301                        cd bin/$x
302                else
303                        cd bin/$x
304                        rm -Rf *
305                fi
306
307                build_file "$VER" "$x" "$NAME" "$TYPE" "-$TARGET-" "$SUFFIX"
308        )
309done
310
311echo "Success!"
312exit 0
313
314# vim:fenc=utf-8:ai:si:ts=4:sw=4:et:nu
Note: See TracBrowser for help on using the repository browser.