1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | # Script for acquiring and building OS X dependencies for 0 A.D.
|
---|
4 | #
|
---|
5 | # The script checks whether a source tarball exists for each
|
---|
6 | # dependency, if not it will download the correct version from
|
---|
7 | # the project's website, then it removes previous build files,
|
---|
8 | # extracts the tarball, configures and builds the lib. The script
|
---|
9 | # should die on any errors to ease troubleshooting.
|
---|
10 | #
|
---|
11 | # make install is used to copy the compiled libs to each specific
|
---|
12 | # directory and also the config tools (e.g. sdl-config). Because
|
---|
13 | # of this, OS X developers must run this script at least once,
|
---|
14 | # to configure the correct lib directories. It must be run again
|
---|
15 | # if the libraries are moved.
|
---|
16 | #
|
---|
17 | # Building against an SDK is an option, though not required,
|
---|
18 | # as not all build environments contain the Developer SDKs
|
---|
19 | # (Xcode does, but the Command Line Tools package does not)
|
---|
20 | #
|
---|
21 | # --------------------------------------------------------------
|
---|
22 | # Library versions for ease of updating:
|
---|
23 | ZLIB_VERSION="zlib-1.2.8"
|
---|
24 | CURL_VERSION="curl-7.32.0"
|
---|
25 | ICONV_VERSION="libiconv-1.14"
|
---|
26 | XML2_VERSION="libxml2-2.9.1"
|
---|
27 | # * SDL 1.2.15+ required for Lion support
|
---|
28 | SDL_VERSION="SDL-1.2.15"
|
---|
29 | BOOST_VERSION="boost_1_52_0"
|
---|
30 | # * wxWidgets 2.9+ is necessary for 64-bit OS X build w/ OpenGL support
|
---|
31 | WXWIDGETS_VERSION="wxWidgets-3.0.0"
|
---|
32 | JPEG_VERSION="jpegsrc.v8d"
|
---|
33 | JPEG_DIR="jpeg-8d" # Must match directory name inside source tarball
|
---|
34 | # * libpng was included as part of X11 but that's removed from Mountain Lion
|
---|
35 | # (also the Snow Leopard version was ancient 1.2)
|
---|
36 | PNG_VERSION="libpng-1.5.13"
|
---|
37 | OGG_VERSION="libogg-1.3.0"
|
---|
38 | VORBIS_VERSION="libvorbis-1.3.3"
|
---|
39 | # gloox is necessary for multiplayer lobby
|
---|
40 | GLOOX_VERSION="gloox-1.0.9"
|
---|
41 | # --------------------------------------------------------------
|
---|
42 | # Bundled with the game:
|
---|
43 | # * SpiderMonkey 1.8.5
|
---|
44 | # * ENet 1.3.3
|
---|
45 | # * NVTT
|
---|
46 | # * FCollada
|
---|
47 | # * MiniUPnPc
|
---|
48 | # --------------------------------------------------------------
|
---|
49 | # Provided by OS X:
|
---|
50 | # * OpenAL
|
---|
51 | # * OpenGL
|
---|
52 | # --------------------------------------------------------------
|
---|
53 |
|
---|
54 | # Force build architecture, as sometimes environment is broken.
|
---|
55 | # For a universal fat binary, the approach would be to build every
|
---|
56 | # dependency with both archs and combine them with lipo, then do the
|
---|
57 | # same thing with the game itself.
|
---|
58 | # Choices are "x86_64" or "i386" (ppc and ppc64 not supported)
|
---|
59 | ARCH=${ARCH:="x86_64"}
|
---|
60 |
|
---|
61 | # Define compiler as "gcc" (in case anything expects e.g. gcc-4.2)
|
---|
62 | # On newer OS X versions, this will be a symbolic link to LLVM GCC
|
---|
63 | # TODO: don't rely on that
|
---|
64 | export CC=${CC:="gcc"} CXX=${CXX:="g++"}
|
---|
65 |
|
---|
66 | # The various libs offer inconsistent configure options, some allow
|
---|
67 | # setting sysroot and OS X-specific options, others don't. Adding to
|
---|
68 | # the confusion, Apple moved /Developer/SDKs into the Xcode app bundle
|
---|
69 | # so the path can't be guessed by clever build tools (like Boost.Build).
|
---|
70 | # Sometimes configure gets it wrong anyway, especially on cross compiles.
|
---|
71 | # This is why we prefer using CFLAGS, CPPFLAGS, and LDFLAGS.
|
---|
72 |
|
---|
73 | # Check if SYSROOT is set and not empty
|
---|
74 | if [[ $SYSROOT && ${SYSROOT-_} ]]; then
|
---|
75 | CFLAGS="$CFLAGS -isysroot $SYSROOT"
|
---|
76 | LDFLAGS="$LDFLAGS -Wl,-syslibroot,$SYSROOT"
|
---|
77 | fi
|
---|
78 | # Check if MIN_OSX_VERSION is set and not empty
|
---|
79 | if [[ $MIN_OSX_VERSION && ${MIN_OSX_VERSION-_} ]]; then
|
---|
80 | CFLAGS="$CFLAGS -mmacosx-version-min=$MIN_OSX_VERSION"
|
---|
81 | # clang and llvm-gcc look at mmacosx-version-min to determine link target
|
---|
82 | # and CRT version, and use it to set the macosx_version_min linker flag
|
---|
83 | LDFLAGS="$LDFLAGS -mmacosx-version-min=$MIN_OSX_VERSION"
|
---|
84 | fi
|
---|
85 | CFLAGS="$CFLAGS -arch $ARCH"
|
---|
86 | # Avoid linker warnings about compiling translation units with different visibility settings
|
---|
87 | CPPFLAGS="$CPPFLAGS $CFLAGS -fvisibility=hidden"
|
---|
88 | LDFLAGS="$LDFLAGS -arch $ARCH"
|
---|
89 |
|
---|
90 | JOBS=${JOBS:="-j2"}
|
---|
91 |
|
---|
92 | set -e
|
---|
93 |
|
---|
94 | die()
|
---|
95 | {
|
---|
96 | echo ERROR: $*
|
---|
97 | exit 1
|
---|
98 | }
|
---|
99 |
|
---|
100 | download_lib()
|
---|
101 | {
|
---|
102 | local url=$1
|
---|
103 | local filename=$2
|
---|
104 |
|
---|
105 | if [ ! -e $filename ]; then
|
---|
106 | echo "Downloading $filename"
|
---|
107 | curl -L -O ${url}${filename} || die "Download of $url$filename failed"
|
---|
108 | fi
|
---|
109 | }
|
---|
110 |
|
---|
111 | already_built()
|
---|
112 | {
|
---|
113 | echo -e "Skipping - already built (use --force-rebuild to override)"
|
---|
114 | }
|
---|
115 |
|
---|
116 | # Check that we're actually on OS X
|
---|
117 | if [ "`uname -s`" != "Darwin" ]; then
|
---|
118 | die "This script is intended for OS X only"
|
---|
119 | fi
|
---|
120 |
|
---|
121 | # Parse command-line options:
|
---|
122 | force_rebuild=false
|
---|
123 |
|
---|
124 | for i in "$@"
|
---|
125 | do
|
---|
126 | case $i in
|
---|
127 | --force-rebuild ) force_rebuild=true;;
|
---|
128 | -j* ) JOBS=$i ;;
|
---|
129 | esac
|
---|
130 | done
|
---|
131 |
|
---|
132 | cd "$(dirname $0)"
|
---|
133 | # Now in libraries/osx/ (where we assume this script resides)
|
---|
134 |
|
---|
135 | # --------------------------------------------------------------
|
---|
136 | echo -e "Building zlib..."
|
---|
137 |
|
---|
138 | LIB_VERSION="${ZLIB_VERSION}"
|
---|
139 | LIB_ARCHIVE="$LIB_VERSION.tar.gz"
|
---|
140 | LIB_DIRECTORY=$LIB_VERSION
|
---|
141 | LIB_URL="http://zlib.net/"
|
---|
142 |
|
---|
143 | mkdir -p zlib
|
---|
144 | pushd zlib > /dev/null
|
---|
145 |
|
---|
146 | ZLIB_DIR="$(pwd)"
|
---|
147 |
|
---|
148 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
|
---|
149 | then
|
---|
150 | rm -f .already-built
|
---|
151 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
152 |
|
---|
153 | rm -rf $LIB_DIRECTORY include lib share
|
---|
154 | tar -xf $LIB_ARCHIVE
|
---|
155 | pushd $LIB_DIRECTORY
|
---|
156 |
|
---|
157 | # patch zlib's configure script to use our CFLAGS and LDFLAGS
|
---|
158 | # TODO: could be done with sed...
|
---|
159 | (patch -p0 -i ../../patches/zlib_flags.diff && CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" ./configure --prefix="$ZLIB_DIR" --static && make ${JOBS} && make install) || die "zlib build failed"
|
---|
160 | popd
|
---|
161 | touch .already-built
|
---|
162 | else
|
---|
163 | already_built
|
---|
164 | fi
|
---|
165 | popd > /dev/null
|
---|
166 |
|
---|
167 | # --------------------------------------------------------------
|
---|
168 | echo -e "Building libcurl..."
|
---|
169 |
|
---|
170 | LIB_VERSION="${CURL_VERSION}"
|
---|
171 | LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
|
---|
172 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
173 | LIB_URL="http://curl.haxx.se/download/"
|
---|
174 |
|
---|
175 | mkdir -p libcurl
|
---|
176 | pushd libcurl > /dev/null
|
---|
177 |
|
---|
178 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
|
---|
179 | then
|
---|
180 | INSTALL_DIR="$(pwd)"
|
---|
181 |
|
---|
182 | rm -f .already-built
|
---|
183 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
184 |
|
---|
185 | rm -rf $LIB_DIRECTORY bin include lib share
|
---|
186 | tar -xf $LIB_ARCHIVE
|
---|
187 | pushd $LIB_DIRECTORY
|
---|
188 |
|
---|
189 | (./configure CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" --prefix="$INSTALL_DIR" --enable-ipv6 --without-gnutls --without-gssapi --without-libmetalink --without-librtmp --without-libssh2 --without-nss --without-polarssl --without-spnego --without-ssl --disable-ares --disable-ldap --disable-ldaps --without-libidn --with-zlib="${ZLIB_DIR}" --enable-shared=no && make ${JOBS} && make install) || die "libcurl build failed"
|
---|
190 | popd
|
---|
191 | touch .already-built
|
---|
192 | else
|
---|
193 | already_built
|
---|
194 | fi
|
---|
195 | popd > /dev/null
|
---|
196 |
|
---|
197 | # --------------------------------------------------------------
|
---|
198 | echo -e "Building libiconv..."
|
---|
199 |
|
---|
200 | LIB_VERSION="${ICONV_VERSION}"
|
---|
201 | LIB_ARCHIVE="$LIB_VERSION.tar.gz"
|
---|
202 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
203 | LIB_URL="http://ftp.gnu.org/pub/gnu/libiconv/"
|
---|
204 |
|
---|
205 | mkdir -p libiconv
|
---|
206 | pushd libiconv > /dev/null
|
---|
207 |
|
---|
208 | ICONV_DIR="$(pwd)"
|
---|
209 |
|
---|
210 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
|
---|
211 | then
|
---|
212 | rm -f .already-built
|
---|
213 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
214 |
|
---|
215 | rm -rf $LIB_DIRECTORY bin include lib share
|
---|
216 | tar -xf $LIB_ARCHIVE
|
---|
217 | pushd $LIB_DIRECTORY
|
---|
218 |
|
---|
219 | (./configure CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" --prefix="$ICONV_DIR" --without-libiconv-prefix --without-libintl-prefix --disable-nls --enable-shared=no && make ${JOBS} && make install) || die "libiconv build failed"
|
---|
220 | popd
|
---|
221 | touch .already-built
|
---|
222 | else
|
---|
223 | already_built
|
---|
224 | fi
|
---|
225 | popd > /dev/null
|
---|
226 |
|
---|
227 | # --------------------------------------------------------------
|
---|
228 | echo -e "Building libxml2..."
|
---|
229 |
|
---|
230 | LIB_VERSION="${XML2_VERSION}"
|
---|
231 | LIB_ARCHIVE="$LIB_VERSION.tar.gz"
|
---|
232 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
233 | LIB_URL="ftp://xmlsoft.org/libxml2/"
|
---|
234 |
|
---|
235 | mkdir -p libxml2
|
---|
236 | pushd libxml2 > /dev/null
|
---|
237 |
|
---|
238 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
|
---|
239 | then
|
---|
240 | INSTALL_DIR="$(pwd)"
|
---|
241 |
|
---|
242 | rm -f .already-built
|
---|
243 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
244 |
|
---|
245 | rm -rf $LIB_DIRECTORY bin include lib share
|
---|
246 | tar -xf $LIB_ARCHIVE
|
---|
247 | pushd $LIB_DIRECTORY
|
---|
248 |
|
---|
249 | (./configure CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" --prefix="$INSTALL_DIR" --without-lzma --without-python --with-iconv="${ICONV_DIR}" --with-zlib="${ZLIB_DIR}" --enable-shared=no && make ${JOBS} && make install) || die "libxml2 build failed"
|
---|
250 | popd
|
---|
251 | touch .already-built
|
---|
252 | else
|
---|
253 | already_built
|
---|
254 | fi
|
---|
255 | popd > /dev/null
|
---|
256 |
|
---|
257 | # --------------------------------------------------------------
|
---|
258 |
|
---|
259 | echo -e "Building SDL..."
|
---|
260 |
|
---|
261 | LIB_VERSION="${SDL_VERSION}"
|
---|
262 | LIB_ARCHIVE="$LIB_VERSION.tar.gz"
|
---|
263 | LIB_DIRECTORY=$LIB_VERSION
|
---|
264 | LIB_URL="http://www.libsdl.org/release/"
|
---|
265 |
|
---|
266 | mkdir -p sdl
|
---|
267 | pushd sdl > /dev/null
|
---|
268 |
|
---|
269 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
|
---|
270 | then
|
---|
271 | INSTALL_DIR="$(pwd)"
|
---|
272 |
|
---|
273 | rm -f .already-built
|
---|
274 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
275 |
|
---|
276 | rm -rf $LIB_DIRECTORY bin include lib share
|
---|
277 | tar -xf $LIB_ARCHIVE
|
---|
278 | pushd $LIB_DIRECTORY
|
---|
279 |
|
---|
280 |
|
---|
281 | # patch SDL to fix Mavericks build (fixed upstream, see https://bugzilla.libsdl.org/show_bug.cgi?id=2085 )
|
---|
282 | # Don't use X11 - we don't need it and Mountain Lion removed it
|
---|
283 | (patch -p0 -i ../../patches/sdl-mavericks-quartz-fix.diff && ./configure CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" --prefix="$INSTALL_DIR" --disable-video-x11 --without-x --enable-shared=no && make $JOBS && make install) || die "SDL build failed"
|
---|
284 | popd
|
---|
285 | touch .already-built
|
---|
286 | else
|
---|
287 | already_built
|
---|
288 | fi
|
---|
289 | popd > /dev/null
|
---|
290 |
|
---|
291 | # --------------------------------------------------------------
|
---|
292 | echo -e "Building Boost..."
|
---|
293 |
|
---|
294 | LIB_VERSION="${BOOST_VERSION}"
|
---|
295 | LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
|
---|
296 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
297 | LIB_URL="http://download.sourceforge.net/boost/"
|
---|
298 |
|
---|
299 | mkdir -p boost
|
---|
300 | pushd boost > /dev/null
|
---|
301 |
|
---|
302 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
|
---|
303 | then
|
---|
304 | INSTALL_DIR="$(pwd)"
|
---|
305 |
|
---|
306 | rm -f .already-built
|
---|
307 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
308 |
|
---|
309 | rm -rf $LIB_DIRECTORY include lib
|
---|
310 | tar -xf $LIB_ARCHIVE
|
---|
311 | pushd $LIB_DIRECTORY
|
---|
312 |
|
---|
313 | # Can't use macosx-version, see above comment.
|
---|
314 | (./bootstrap.sh --with-libraries=filesystem,system,signals --prefix=$INSTALL_DIR && ./b2 cflags="$CFLAGS" cxxflags="$CPPFLAGS" linkflags="$LDFLAGS" ${JOBS} -d2 --layout=tagged --debug-configuration link=static threading=multi variant=release,debug install) || die "Boost build failed"
|
---|
315 |
|
---|
316 | popd
|
---|
317 | touch .already-built
|
---|
318 | else
|
---|
319 | already_built
|
---|
320 | fi
|
---|
321 | popd > /dev/null
|
---|
322 |
|
---|
323 | # --------------------------------------------------------------
|
---|
324 | # TODO: This build takes ages, anything we can exlude?
|
---|
325 | echo -e "skipping wxWidgets..."
|
---|
326 |
|
---|
327 |
|
---|
328 | # --------------------------------------------------------------
|
---|
329 | echo -e "Building libjpg..."
|
---|
330 |
|
---|
331 | LIB_VERSION="${JPEG_VERSION}"
|
---|
332 | LIB_ARCHIVE="$LIB_VERSION.tar.gz"
|
---|
333 | LIB_DIRECTORY="${JPEG_DIR}"
|
---|
334 | LIB_URL="http://www.ijg.org/files/"
|
---|
335 |
|
---|
336 | mkdir -p libjpg
|
---|
337 | pushd libjpg > /dev/null
|
---|
338 |
|
---|
339 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
|
---|
340 | then
|
---|
341 | INSTALL_DIR="$(pwd)"
|
---|
342 |
|
---|
343 | rm -f .already-built
|
---|
344 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
345 |
|
---|
346 | rm -rf $LIB_DIRECTORY bin include lib share
|
---|
347 | tar -xf $LIB_ARCHIVE
|
---|
348 | pushd $LIB_DIRECTORY
|
---|
349 |
|
---|
350 | (./configure CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" --prefix=$INSTALL_DIR --enable-shared=no && make ${JOBS} && make install) || die "libjpg build failed"
|
---|
351 | popd
|
---|
352 | touch .already-built
|
---|
353 | else
|
---|
354 | already_built
|
---|
355 | fi
|
---|
356 | popd > /dev/null
|
---|
357 |
|
---|
358 | # --------------------------------------------------------------
|
---|
359 | echo -e "Building libpng..."
|
---|
360 |
|
---|
361 | LIB_VERSION="${PNG_VERSION}"
|
---|
362 | LIB_ARCHIVE="$LIB_VERSION.tar.gz"
|
---|
363 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
364 | LIB_URL="http://download.sourceforge.net/libpng/"
|
---|
365 |
|
---|
366 | mkdir -p libpng
|
---|
367 | pushd libpng > /dev/null
|
---|
368 |
|
---|
369 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
|
---|
370 | then
|
---|
371 | INSTALL_DIR="$(pwd)"
|
---|
372 |
|
---|
373 | rm -f .already-built
|
---|
374 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
375 |
|
---|
376 | rm -rf $LIB_DIRECTORY bin include lib share
|
---|
377 | tar -xf $LIB_ARCHIVE
|
---|
378 | pushd $LIB_DIRECTORY
|
---|
379 |
|
---|
380 | (./configure CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" --prefix=$INSTALL_DIR --enable-shared=no && make ${JOBS} && make install) || die "libpng build failed"
|
---|
381 | popd
|
---|
382 | touch .already-built
|
---|
383 | else
|
---|
384 | already_built
|
---|
385 | fi
|
---|
386 | popd > /dev/null
|
---|
387 |
|
---|
388 | # --------------------------------------------------------------
|
---|
389 | echo -e "Building libogg..."
|
---|
390 |
|
---|
391 | LIB_VERSION="${OGG_VERSION}"
|
---|
392 | LIB_ARCHIVE="$LIB_VERSION.tar.gz"
|
---|
393 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
394 | LIB_URL="http://downloads.xiph.org/releases/ogg/"
|
---|
395 |
|
---|
396 | # Dependency of vorbis
|
---|
397 | # we can install them in the same directory for convenience
|
---|
398 | mkdir -p libogg
|
---|
399 | mkdir -p vorbis
|
---|
400 |
|
---|
401 | pushd libogg > /dev/null
|
---|
402 | OGG_DIR="$(pwd)"
|
---|
403 |
|
---|
404 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
|
---|
405 | then
|
---|
406 | rm -f .already-built
|
---|
407 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
408 |
|
---|
409 | rm -rf $LIB_DIRECTORY include lib share
|
---|
410 | tar -xf $LIB_ARCHIVE
|
---|
411 | pushd $LIB_DIRECTORY
|
---|
412 |
|
---|
413 | (./configure CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" --prefix=$OGG_DIR --enable-shared=no && make ${JOBS} && make install) || die "libogg build failed"
|
---|
414 | popd
|
---|
415 | touch .already-built
|
---|
416 | else
|
---|
417 | already_built
|
---|
418 | fi
|
---|
419 | popd > /dev/null
|
---|
420 |
|
---|
421 | # --------------------------------------------------------------
|
---|
422 | echo -e "Building libvorbis..."
|
---|
423 |
|
---|
424 | LIB_VERSION="${VORBIS_VERSION}"
|
---|
425 | LIB_ARCHIVE="$LIB_VERSION.tar.gz"
|
---|
426 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
427 | LIB_URL="http://downloads.xiph.org/releases/vorbis/"
|
---|
428 |
|
---|
429 | pushd vorbis > /dev/null
|
---|
430 |
|
---|
431 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
|
---|
432 | then
|
---|
433 | INSTALL_DIR="$(pwd)"
|
---|
434 |
|
---|
435 | rm -f .already-built
|
---|
436 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
437 |
|
---|
438 | rm -rf $LIB_DIRECTORY include lib share
|
---|
439 | tar -xf $LIB_ARCHIVE
|
---|
440 | pushd $LIB_DIRECTORY
|
---|
441 |
|
---|
442 | (./configure CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" --prefix="$INSTALL_DIR" --enable-shared=no --with-ogg="$OGG_DIR" && make ${JOBS} && make install) || die "libvorbis build failed"
|
---|
443 | popd
|
---|
444 | touch .already-built
|
---|
445 | else
|
---|
446 | already_built
|
---|
447 | fi
|
---|
448 | popd > /dev/null
|
---|
449 |
|
---|
450 | # --------------------------------------------------------------
|
---|
451 | echo -e "Building gloox..."
|
---|
452 |
|
---|
453 | LIB_VERSION="${GLOOX_VERSION}"
|
---|
454 | LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
|
---|
455 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
456 | LIB_URL="http://camaya.net/download/"
|
---|
457 |
|
---|
458 | mkdir -p gloox
|
---|
459 | pushd gloox > /dev/null
|
---|
460 |
|
---|
461 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
|
---|
462 | then
|
---|
463 | INSTALL_DIR="$(pwd)"
|
---|
464 |
|
---|
465 | rm -f .already-built
|
---|
466 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
467 |
|
---|
468 | rm -rf $LIB_DIRECTORY bin include lib
|
---|
469 | tar -xf $LIB_ARCHIVE
|
---|
470 | pushd $LIB_DIRECTORY
|
---|
471 |
|
---|
472 | # patch gloox to fix build error (fixed upstream in r4529)
|
---|
473 | # TODO: pulls in libresolv dependency from /usr/lib
|
---|
474 | # TODO: if we ever use SSL/TLS, that will add yet another dependency...
|
---|
475 | (patch -p0 -i ../../patches/gloox-r4529.diff && ./configure CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" --prefix="$INSTALL_DIR" --enable-shared=no --with-zlib="${ZLIB_DIR}" --without-libidn --without-gnutls --without-openssl --without-tests --without-examples && make ${JOBS} && make install) || die "gloox build failed"
|
---|
476 | popd
|
---|
477 | touch .already-built
|
---|
478 | else
|
---|
479 | already_built
|
---|
480 | fi
|
---|
481 | popd > /dev/null
|
---|
482 |
|
---|
483 | # --------------------------------------------------------------------
|
---|
484 | # The following libraries are shared on different OSes and may
|
---|
485 | # be customzied, so we build and install them from bundled sources
|
---|
486 | # --------------------------------------------------------------------
|
---|
487 | echo -e "Building Spidermonkey..."
|
---|
488 | export CC=${CC:="clang"} CXX=${CXX:="clang++"}
|
---|
489 |
|
---|
490 | LIB_VERSION="mozjs-24.2.0"
|
---|
491 | LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
|
---|
492 | LIB_DIRECTORY="mozjs24"
|
---|
493 |
|
---|
494 | pushd ../source/spidermonkey/ > /dev/null
|
---|
495 |
|
---|
496 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
|
---|
497 | then
|
---|
498 | INSTALL_DIR="$(pwd)"
|
---|
499 |
|
---|
500 | rm -f .already-built
|
---|
501 | rm -f lib/*.a
|
---|
502 | rm -rf $LIB_DIRECTORY
|
---|
503 | tar -xf $LIB_ARCHIVE
|
---|
504 | mv mozjs-24.2.0 mozjs24
|
---|
505 | pushd mozjs24/js/src
|
---|
506 |
|
---|
507 | # We want separate debug/release versions of the library, so change their install name in the Makefile
|
---|
508 | #sed -i.bak -e 's/\(STATIC_LIBRARY_NAME),mozjs24-\)\(\$(SRCREL_ABI_VERSION)\)\{0,1\}/\1ps-debug/' Makefile.in
|
---|
509 | echo DEBUGTEST1
|
---|
510 | perl -i.bak -pe 's/(^LIBRARY_NAME\s+=).*/$1mozjs24-ps-debug/' Makefile.in
|
---|
511 | echo DEBUGTEST2
|
---|
512 | CONF_OPTS="--prefix=${INSTALL_DIR}"
|
---|
513 | echo DEBUGTEST3
|
---|
514 | # Uncomment this line for 32-bit 10.5 cross compile:
|
---|
515 | #CONF_OPTS="$CONF_OPTS --target=i386-apple-darwin9.0.0"
|
---|
516 | if [[ $MIN_OSX_VERSION && ${MIN_OSX_VERSION-_} ]]; then
|
---|
517 | CONF_OPTS="$CONF_OPTS --enable-macos-target=$MIN_OSX_VERSION"
|
---|
518 | fi
|
---|
519 | if [[ $SYSROOT && ${SYSROOT-_} ]]; then
|
---|
520 | CONF_OPTS="$CONF_OPTS --with-macosx-sdk=$SYSROOT"
|
---|
521 | fi
|
---|
522 | echo DEBUGTEST4
|
---|
523 | mkdir -p build-debug
|
---|
524 | pushd build-debug
|
---|
525 | (clang -v ../configure $CONF_OPTS && make ${JOBS} && make install) || die "Spidermonkey build failed"
|
---|
526 | popd
|
---|
527 | mv Makefile.in.bak Makefile.in
|
---|
528 | echo DEBUGTEST5
|
---|
529 | #sed -i.bak -e 's/\(STATIC_LIBRARY_NAME),mozjs24-\)\(\$(SRCREL_ABI_VERSION)\)\{0,1\}/\1ps-release/' Makefile.in
|
---|
530 | perl -i.bak -pe 's/(^LIBRARY_NAME\s+=).*/$1mozjs24-ps-release/' Makefile.in
|
---|
531 | echo DEBUGTEST6
|
---|
532 | mkdir -p build-release
|
---|
533 | pushd build-release
|
---|
534 |
|
---|
535 | (CC="$CC -arch $ARCH" CXX="$CXX -arch $ARCH" AR=ar CROSS_COMPILE=1 ../configure $CONF_OPTS --with-nspr-libs="$NSPR_LIBS" --with-nspr-cflags="$NSPR_INCLUDES" --enable-optimize && make ${JOBS} && make install) || die "Spidermonkey build failed"
|
---|
536 | popd
|
---|
537 | mv Makefile.in.bak Makefile.in
|
---|
538 | echo DEBUGTEST7
|
---|
539 |
|
---|
540 | popd
|
---|
541 | touch .already-built
|
---|
542 | else
|
---|
543 | already_built
|
---|
544 | fi
|
---|
545 | popd > /dev/null
|
---|
546 | export CC=${CC:="clang"} CXX=${CXX:="clang++ "}
|
---|
547 |
|
---|
548 | # --------------------------------------------------------------
|
---|
549 | echo -e "Building ENet..."
|
---|
550 |
|
---|
551 | pushd ../source/enet/ > /dev/null
|
---|
552 |
|
---|
553 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]]
|
---|
554 | then
|
---|
555 | INSTALL_DIR="$(pwd)"
|
---|
556 | rm -f .already-built
|
---|
557 |
|
---|
558 | pushd src
|
---|
559 | (./configure CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" --prefix=${INSTALL_DIR} --enable-shared=no && make clean && make ${JOBS} && make install) || die "ENet build failed"
|
---|
560 | popd
|
---|
561 | touch .already-built
|
---|
562 | else
|
---|
563 | already_built
|
---|
564 | fi
|
---|
565 | popd > /dev/null
|
---|
566 |
|
---|
567 | # --------------------------------------------------------------
|
---|
568 | # NVTT - no install
|
---|
569 | echo -e "Building NVTT..."
|
---|
570 |
|
---|
571 | pushd ../source/nvtt > /dev/null
|
---|
572 |
|
---|
573 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]]
|
---|
574 | then
|
---|
575 | rm -f .already-built
|
---|
576 | rm -f lib/*.a
|
---|
577 | pushd src
|
---|
578 | rm -rf build
|
---|
579 | mkdir -p build
|
---|
580 |
|
---|
581 | pushd build
|
---|
582 |
|
---|
583 | # Could use CMAKE_OSX_DEPLOYMENT_TARGET and CMAKE_OSX_SYSROOT
|
---|
584 | # but they're not as flexible for cross-compiling
|
---|
585 | # Disable optional libs that we don't need (avoids some conflicts with MacPorts)
|
---|
586 | (cmake .. -DCMAKE_LINK_FLAGS="$LDFLAGS" -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CPPFLAGS" -DCMAKE_BUILD_TYPE=Release -DBINDIR=bin -DLIBDIR=lib -DGLUT=0 -DGLEW=0 -DCG=0 -DCUDA=0 -DOPENEXR=0 -DJPEG=0 -DPNG=0 -DTIFF=0 -G "Unix Makefiles" && make clean && make nvtt ${JOBS}) || die "NVTT build failed"
|
---|
587 | popd
|
---|
588 |
|
---|
589 | mkdir -p ../lib
|
---|
590 | cp build/src/nv*/libnv*.a ../lib/
|
---|
591 | cp build/src/nvtt/squish/libsquish.a ../lib/
|
---|
592 | popd
|
---|
593 | touch .already-built
|
---|
594 | else
|
---|
595 | already_built
|
---|
596 | fi
|
---|
597 | popd > /dev/null
|
---|
598 |
|
---|
599 | # --------------------------------------------------------------
|
---|
600 | # FCollada - no install
|
---|
601 | echo -e "Building FCollada..."
|
---|
602 |
|
---|
603 | pushd ../source/fcollada > /dev/null
|
---|
604 |
|
---|
605 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]]
|
---|
606 | then
|
---|
607 | rm -f .already-built
|
---|
608 | rm -f lib/*.a
|
---|
609 | pushd src
|
---|
610 | rm -rf output
|
---|
611 | mkdir -p ../lib
|
---|
612 |
|
---|
613 | # The Makefile refers to pkg-config for libxml2, but we
|
---|
614 | # don't have that (replace with xml2-config instead)
|
---|
615 | sed -i.bak -e 's/pkg-config libxml-2.0/xml2-config/' Makefile
|
---|
616 | (make clean && CXXFLAGS=$CPPFLAGS make ${JOBS}) || die "FCollada build failed"
|
---|
617 | # Undo Makefile change
|
---|
618 | mv Makefile.bak Makefile
|
---|
619 | popd
|
---|
620 | touch .already-built
|
---|
621 | else
|
---|
622 | already_built
|
---|
623 | fi
|
---|
624 | popd > /dev/null
|
---|
625 |
|
---|
626 | # --------------------------------------------------------------
|
---|
627 | # MiniUPnPc - no install
|
---|
628 | echo -e "Building MiniUPnPc..."
|
---|
629 |
|
---|
630 | pushd ../source/miniupnpc > /dev/null
|
---|
631 |
|
---|
632 | if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]]
|
---|
633 | then
|
---|
634 | rm -f .already-built
|
---|
635 | rm -f lib/*.a
|
---|
636 | pushd src
|
---|
637 | rm -rf output
|
---|
638 | mkdir -p ../lib
|
---|
639 |
|
---|
640 | (make clean && CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS make ${JOBS}) || die "MiniUPnPc build failed"
|
---|
641 |
|
---|
642 | cp libminiupnpc.a ../lib/
|
---|
643 |
|
---|
644 | popd
|
---|
645 | touch .already-built
|
---|
646 | else
|
---|
647 | already_built
|
---|
648 | fi
|
---|
649 | popd > /dev/null
|
---|