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? |
---|
17 | DARWIN_PLATFORMS="core2 corei" |
---|
18 | MISC_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 | # |
---|
28 | MISC_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 | # |
---|
35 | MISC_FREEBSD_PLATFORMS="alphaev56 ultrasparc2i" |
---|
36 | MISC_NETBSD_PLATFORMS="armv5tel mips64el ultrasparc2i sgi hppa2.0 alphaev56 powerpc powerpc64 powerpc64le powerpcle atari amiga m68knommu" # and many, many more |
---|
37 | MISC_OPENBSD_PLATFORMS="alphaev56 ultrasparc2i sgi powerpc powerpc64 hppa2.0 alphaev56 armv5tel mips64el" |
---|
38 | |
---|
39 | # |
---|
40 | # MINGW/Windows?? |
---|
41 | # |
---|
42 | MISC_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 | # |
---|
60 | X86_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) |
---|
63 | X86_PLATFORMS="${X86_64_PLATFORMS} pentium pentiummmx pentium2 pentium3 pentiumm k6 k62 k63 athlon geode viac3 viac32" |
---|
64 | |
---|
65 | MINGW_PLATFORMS="${X86_PLATFORMS} ${MISC_MINGW_PLATFORMS}" |
---|
66 | LINUX_PLATFORMS="${X86_PLATFORMS} ${MISC_LINUX_PLATFORMS}" |
---|
67 | FREEBSD_PLATFORMS="${X86_PLATFORMS} ${MISC_FREEBSD_PLATFORMS}" |
---|
68 | # As they say, "Of course it runs NetBSD!" |
---|
69 | NETBSD_PLATFORMS="${FREEBSD_PLATFORMS} ${MISC_LINUX_PLATFORMS} ${MISC_NETBSD_PLATFORMS}" |
---|
70 | OPENBSD_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 |
---|
78 | if [ ! -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 |
---|
82 | fi |
---|
83 | |
---|
84 | if [ ! $(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 |
---|
88 | fi |
---|
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) |
---|
97 | if [ `echo $TARGET|grep darwin` ]; then |
---|
98 | VER=5.0.2 |
---|
99 | elif [ `echo $TARGET|grep sunos` ]; then |
---|
100 | VER=$(echo gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | /usr/xpg4/bin/tail -n 1) |
---|
101 | else |
---|
102 | VER=$(echo gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | tail -n 1) |
---|
103 | fi |
---|
104 | |
---|
105 | if [ "$VER" = "" ] ; then |
---|
106 | echo "ERROR! Can't find gmp source tarball." |
---|
107 | exit 1 |
---|
108 | fi |
---|
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 | |
---|
114 | if [ $BITS -eq 32 ]; then |
---|
115 | export CC="gcc -m32" |
---|
116 | export CFLAGS="-m32" |
---|
117 | export LDFLAGS="-m32" |
---|
118 | SUFFIX= |
---|
119 | elif [ $BITS -eq 64 ]; then |
---|
120 | export CC="gcc -m64" |
---|
121 | export CFLAGS="-m64" |
---|
122 | fi |
---|
123 | |
---|
124 | case "$TARGET" in |
---|
125 | mingw*) |
---|
126 | PLATFORM_LIST="${MINGW_PLATFORMS}" |
---|
127 | NAME="jbigi" |
---|
128 | TYPE="dll" |
---|
129 | TARGET="windows" |
---|
130 | echo "Building windows .dlls for all architectures";; |
---|
131 | darwin*) |
---|
132 | PLATFORM_LIST="${DARWIN_PLATFORMS}" |
---|
133 | NAME="libjbigi" |
---|
134 | TYPE="jnilib" |
---|
135 | TARGET="osx" |
---|
136 | echo "Building ${TARGET} .jnilibs for all architectures";; |
---|
137 | sunos*) |
---|
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_PLATFORMS}" |
---|
146 | else |
---|
147 | PLATFORM_LIST="${X86_PLATFORMS}" |
---|
148 | fi |
---|
149 | echo "Building ${TARGET} .sos for all architectures";; |
---|
150 | linux*|*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}";; |
---|
183 | netbsd*|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;; |
---|
218 | esac |
---|
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 | |
---|
229 | make_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 | |
---|
236 | make_file () { |
---|
237 | # Nonfatal bail out on Failed build. |
---|
238 | echo "Attempting build for ${3}${5}${2}" |
---|
239 | make -j && 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 | |
---|
247 | configure_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 1 |
---|
255 | |
---|
256 | # Nonfatal bail out on unsupported platform. |
---|
257 | (cd ../../gmp-${1}; make clean) |
---|
258 | if [ $(echo $TARGET| grep -q osx) ]; then |
---|
259 | ../../gmp-${1}/configure --build=${2}-apple-darwin --with-pic && return 0 |
---|
260 | else |
---|
261 | ../../gmp-${1}/configure --build=${2} --with-pic && return 0 |
---|
262 | fi |
---|
263 | cd .. |
---|
264 | rm -R "$2" |
---|
265 | printf "\n\nSorry, ${3}${5}${2} is not supported on your build environment.\a" |
---|
266 | sleep 10 |
---|
267 | return 1 |
---|
268 | } |
---|
269 | |
---|
270 | build_file () { |
---|
271 | 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 |
---|
272 | printf "\n\n\nError building static!\n\n\a" |
---|
273 | sleep 10 |
---|
274 | return 1 |
---|
275 | } |
---|
276 | |
---|
277 | if [ ! -d gmp-$VER ]; then |
---|
278 | echo "Extracting GMP Version $VER ..." |
---|
279 | if [ -e gmp-$VER.tar.bz2 ]; then |
---|
280 | tar -xjf gmp-$VER.tar.bz2 || ( echo "Error in tarball file!" >&2 ; exit 1 ) |
---|
281 | else |
---|
282 | echo "ERROR: gmp tarball not found in current directory" >&2 |
---|
283 | exit 1 |
---|
284 | fi |
---|
285 | fi |
---|
286 | |
---|
287 | if [ ! -d bin ]; then |
---|
288 | mkdir bin |
---|
289 | fi |
---|
290 | if [ ! -d lib/net/i2p/util ]; then |
---|
291 | mkdir -p lib/net/i2p/util |
---|
292 | fi |
---|
293 | |
---|
294 | # Don't touch this one. |
---|
295 | NO_PLATFORM=none |
---|
296 | |
---|
297 | for x in $X86_PLATFORMS |
---|
298 | do |
---|
299 | ( |
---|
300 | if [ ! -d bin/$x ]; then |
---|
301 | mkdir bin/$x |
---|
302 | cd bin/$x |
---|
303 | else |
---|
304 | cd bin/$x |
---|
305 | rm -Rf * |
---|
306 | fi |
---|
307 | |
---|
308 | build_file "$VER" "$x" "$NAME" "$TYPE" "-$TARGET-" "$SUFFIX" |
---|
309 | ) |
---|
310 | done |
---|
311 | |
---|
312 | echo "Success!" |
---|
313 | exit 0 |
---|
314 | |
---|
315 | # vim:fenc=utf-8:ai:si:ts=4:sw=4:et:nu |
---|