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

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

Improved support for GNU/kFreeBSD

  • add kFreeBSD to NBI and CPUID
  • add kFreeBSD to jcpuid/jbigi build scripts
  • refresh debian patches to compensate for kFreeBSD changes
  • i2prouter: Detect kFreeBSD and normalize its name
  • clean up osid (switching to "elif") and adding support for detecting kFreeBSD
  • update postinstall.sh; I2P cannot be installed using gij so postinstall.sh will not be run. If/when openjdk finally comes to kFreeBSD, we'll be ready for it.
  • Property mode set to 100755
File size: 7.8 KB
Line 
1#!/bin/sh
2
3# If JAVA_HOME isn't set we'll try to figure it out
4[ -z $JAVA_HOME ] && . ../find-java-home
5if [ ! -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
9fi
10
11#FIXME What platforms for MacOS?
12MISC_DARWIN_PLATFORMS="powerpc powerpc64 powerpc64le powerpcle"
13
14# Note: You will have to add the CPU ID for the platform in the CPU ID code
15# for a new CPU. Just adding them here won't let I2P use the code!
16
17#
18# If you know of other platforms i2p on linux works on,
19# please add them here.
20# Do NOT add any X86 platforms, do that below in the x86 platform list.
21#
22MISC_LINUX_PLATFORMS="hppa2.0 alphaev56 armv5tel mips64el itanium itanium2 ultrasparc2 ultrasparc2i alphaev6 powerpc970 powerpc7455 powerpc7447"
23
24#
25# If you know of other platforms i2p on *BSD works on,
26# please add them here.
27# Do NOT add any X86 platforms, do that below in the x86 platform list.
28#
29MISC_FREEBSD_PLATFORMS="alphaev56 ultrasparc2i"
30MISC_NETBSD_PLATFORMS="armv5tel mips64el ultrasparc2i sgi hppa2.0 alphaev56 powerpc powerpc64 powerpc64le powerpcle atari amiga m68knommu" # and many, many more
31MISC_OPENBSD_PLATFORMS="alphaev56 ultrasparc2i sgi powerpc powerpc64 hppa2.0 alphaev56 armv5tel mips64el"
32
33#
34# MINGW/Windows??
35#
36MISC_MINGW_PLATFORMS=""
37
38#
39# Are there any other X86 platforms that work on i2p? Add them here.
40#
41
42# Note! these build on 32bit as 32bit when operating as 32bit...
43X86_64_PLATFORMS="atom athlon64 core2 corei nano pentium4"
44
45# Note! these are 32bit _ONLY_
46X86_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
58if [ $(uname -s |tr "[A-Z]" "[a-z]") = "linux" ]; then
59        ECHO="/bin/echo"
60elif [ $(uname -s |tr "[A-Z]" "[a-z]") = "gnu/kfreebsd" ]; then
61        ECHO="/bin/echo"
62else
63        ECHO="echo"
64fi
65
66MINGW_PLATFORMS="${X86_PLATFORMS} ${MISC_MINGW_PLATFORMS}"
67LINUX_PLATFORMS="${X86_PLATFORMS} ${MISC_LINUX_PLATFORMS}"
68FREEBSD_PLATFORMS="${X86_PLATFORMS} ${MISC_FREEBSD_PLATFORMS}"
69# As they say, "Of course it runs NetBSD!"
70NETBSD_PLATFORMS="${FREEBSD_PLATFORMS} ${MISC_LINUX_PLATFORMS} ${MISC_NETBSD_PLATFORMS}"
71OPENBSD_PLATFORM="${X86_PLATFORMS} ${MISC_OPENBSD_PLATFORMS}"
72
73# FIXME Is this all?
74DARWIN_PLATFORMS="core2 corei"
75
76# Set the version to 5.0.2 for OSX because AFAIK there are only 64bit capable CPUs for the Intel Macs
77if [ `uname -s |grep Darwin` ]; then
78        VER=5.0.2
79else
80        VER=$($ECHO gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | tail -n 1)
81fi
82
83if [ "$VER" = "" ] ; then
84        $ECHO "ERROR! Can't find gmp source tarball."
85        exit 1
86fi
87
88
89case `uname -s` in
90MINGW*)
91        PLATFORM_LIST="${MINGW_PLATFORMS}"
92        NAME="jbigi"
93        TYPE="dll"
94        TARGET="windows"
95        $ECHO "Building windows .dlls for all architectures";;
96Darwin*)
97        PLATFORM_LIST="${DARWIN_PLATFORMS}"
98        NAME="libjbigi"
99        TYPE="jnilib"
100        TARGET="osx"
101        $ECHO "Building ${TARGET} .jnilibs for all architectures";;
102Linux*|*kFreeBSD)
103        NAME="libjbigi"
104        TYPE="so"
105        PLATFORM_LIST=""
106        if [ $(uname -s | tr "[A-Z]" "[a-z]") = "gnu/kfreebsd" ]; then
107                TARGET="kfreebsd"
108        else
109                TARGET="linux"
110        fi
111        arch=$(uname -m | cut -f1 -d" ")
112        case ${arch} in
113                i[3-6]86)
114                        arch="x86";;
115        esac
116        case ${arch} in
117                x86_64 | amd64)
118                        PLATFORM_LIST="${X86_64_PLATFORMS}"
119                        TARGET="$TARGET-X86_64";;
120                ia64)
121                        PLATFORM_LIST="${X86_64_PLATFORMS}"
122                        TARGET="$TARGET-ia64";;
123                x86)
124                        PLATFORM_LIST="${X86_PLATFORMS}"
125                        TARGET="$TARGET-x86";;
126                *)
127                        PLATFORM_LIST="${LINUX_PLATFORMS}";;
128        esac
129        $ECHO "Building ${TARGET} .sos for ${arch}";;
130NetBSD*|FreeBSD*|OpenBSD*)
131        NAME="libjbigi"
132        TYPE="so"
133        PLATFORM_LIST=""
134        BSDTYPE=$(uname -s | tr "[A-Z]" "[a-z]")
135        arch=$(uname -m | cut -f1 -d" ")
136        case ${arch} in
137                i[3-6]86)
138                        arch="x86";;
139        esac
140        case ${arch} in
141                x86_64|amd64)
142                        PLATFORM_LIST="${X86_64_PLATFORMS}"
143                        TARGET="${BSDTYPE}-X86_64";;
144                ia64)
145                        PLATFORM_LIST="${X86_64_PLATFORMS}"
146                        TARGET="${BSDTYPE}-ia64";;
147                x86)
148                        PLATFORM_LIST="${X86_PLATFORMS}"
149                        TARGET="${BSDTYPE}-x86";;
150                *)
151                        case ${BSDTYPE} in
152                                netbsd)
153                                        PLATFORM_LIST="${NETBSD_PLATFORMS}";;
154                                openbsd)
155                                        PLATFORM_LIST="${OPENBSD_PLATFORMS}";;
156                                freebsd)
157                                        PLATFORM_LIST="${FREEBSD_PLATFORMS}";;
158                                *)
159                                        $ECHO "Unsupported build environment"
160                                        exit 1;;
161                        esac
162        esac
163        $ECHO "Building ${BSDTYPE} .sos for ${arch}";;
164*)
165        $ECHO "Unsupported build environment"
166        exit;;
167esac
168
169make_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}"
175        ../../build_jbigi.sh static || return 1
176        cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}.${4}
177        return 0
178}
179
180make_file () {
181        # Nonfatal bail out on Failed build.
182        $ECHO "Attempting build for ${3}${5}${2}"
183        make && return 0
184        cd ..
185        rm -R "$2"
186        $ECHO -e "\n\nFAILED! ${3}${5}${2} not made.\a"
187        sleep 10
188        return 1
189}
190
191configure_file () {
192        $ECHO -e "\n\n\nAttempting configure for ${3}${5}${2}\n\n\n"
193        sleep 10
194        # Nonfatal bail out on unsupported platform.
195        if [ `uname -s |grep Darwin` ]; then
196                ../../gmp-${1}/configure --build=${2}-apple-darwin --with-pic && return 0
197        else
198                ../../gmp-${1}/configure --build=${2} --with-pic && return 0
199        fi
200        cd ..
201        rm -R "$2"
202        $ECHO -e "\n\nSorry, ${3}${5}${2} is not supported on your build environment.\a"
203        sleep 10
204        return 1
205}
206
207build_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"
210        sleep 10
211        return 1
212}
213
214$ECHO "Extracting GMP Version $VER ..."
215tar -xjf gmp-$VER.tar.bz2 || ( $ECHO "Error in tarball file!" ; exit 1 )
216
217if [ ! -d bin ]; then
218        mkdir bin
219fi
220if [ ! -d lib/net/i2p/util ]; then
221        mkdir -p lib/net/i2p/util
222fi
223
224# Don't touch this one.
225NO_PLATFORM=none
226
227for x in $NO_PLATFORM $PLATFORM_LIST
228do
229        (
230                if [ ! -d bin/$x ]; then
231                        mkdir bin/$x
232                        cd bin/$x
233                else
234                        cd bin/$x
235                        rm -Rf *
236                fi
237
238                build_file "$VER" "$x" "$NAME" "$TYPE" "-$TARGET-"
239        )
240done
241
242$ECHO "Success!"
243exit 0
Note: See TracBrowser for help on using the repository browser.