Ticket #2442: build-osx-libs.sh

File build-osx-libs.sh, 19.5 KB (added by Tom Brewe, 10 years ago)

modified osx build script so far

Line 
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:
23ZLIB_VERSION="zlib-1.2.8"
24CURL_VERSION="curl-7.32.0"
25ICONV_VERSION="libiconv-1.14"
26XML2_VERSION="libxml2-2.9.1"
27# * SDL 1.2.15+ required for Lion support
28SDL_VERSION="SDL-1.2.15"
29BOOST_VERSION="boost_1_52_0"
30# * wxWidgets 2.9+ is necessary for 64-bit OS X build w/ OpenGL support
31WXWIDGETS_VERSION="wxWidgets-3.0.0"
32JPEG_VERSION="jpegsrc.v8d"
33JPEG_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)
36PNG_VERSION="libpng-1.5.13"
37OGG_VERSION="libogg-1.3.0"
38VORBIS_VERSION="libvorbis-1.3.3"
39# gloox is necessary for multiplayer lobby
40GLOOX_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)
59ARCH=${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
64export 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
74if [[ $SYSROOT && ${SYSROOT-_} ]]; then
75 CFLAGS="$CFLAGS -isysroot $SYSROOT"
76 LDFLAGS="$LDFLAGS -Wl,-syslibroot,$SYSROOT"
77fi
78# Check if MIN_OSX_VERSION is set and not empty
79if [[ $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"
84fi
85CFLAGS="$CFLAGS -arch $ARCH"
86# Avoid linker warnings about compiling translation units with different visibility settings
87CPPFLAGS="$CPPFLAGS $CFLAGS -fvisibility=hidden"
88LDFLAGS="$LDFLAGS -arch $ARCH"
89
90JOBS=${JOBS:="-j2"}
91
92set -e
93
94die()
95{
96 echo ERROR: $*
97 exit 1
98}
99
100download_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
111already_built()
112{
113 echo -e "Skipping - already built (use --force-rebuild to override)"
114}
115
116# Check that we're actually on OS X
117if [ "`uname -s`" != "Darwin" ]; then
118 die "This script is intended for OS X only"
119fi
120
121# Parse command-line options:
122force_rebuild=false
123
124for i in "$@"
125do
126 case $i in
127 --force-rebuild ) force_rebuild=true;;
128 -j* ) JOBS=$i ;;
129 esac
130done
131
132cd "$(dirname $0)"
133# Now in libraries/osx/ (where we assume this script resides)
134
135# --------------------------------------------------------------
136echo -e "Building zlib..."
137
138LIB_VERSION="${ZLIB_VERSION}"
139LIB_ARCHIVE="$LIB_VERSION.tar.gz"
140LIB_DIRECTORY=$LIB_VERSION
141LIB_URL="http://zlib.net/"
142
143mkdir -p zlib
144pushd zlib > /dev/null
145
146ZLIB_DIR="$(pwd)"
147
148if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
149then
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
162else
163 already_built
164fi
165popd > /dev/null
166
167# --------------------------------------------------------------
168echo -e "Building libcurl..."
169
170LIB_VERSION="${CURL_VERSION}"
171LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
172LIB_DIRECTORY="$LIB_VERSION"
173LIB_URL="http://curl.haxx.se/download/"
174
175mkdir -p libcurl
176pushd libcurl > /dev/null
177
178if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
179then
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
192else
193 already_built
194fi
195popd > /dev/null
196
197# --------------------------------------------------------------
198echo -e "Building libiconv..."
199
200LIB_VERSION="${ICONV_VERSION}"
201LIB_ARCHIVE="$LIB_VERSION.tar.gz"
202LIB_DIRECTORY="$LIB_VERSION"
203LIB_URL="http://ftp.gnu.org/pub/gnu/libiconv/"
204
205mkdir -p libiconv
206pushd libiconv > /dev/null
207
208ICONV_DIR="$(pwd)"
209
210if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
211then
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
222else
223 already_built
224fi
225popd > /dev/null
226
227# --------------------------------------------------------------
228echo -e "Building libxml2..."
229
230LIB_VERSION="${XML2_VERSION}"
231LIB_ARCHIVE="$LIB_VERSION.tar.gz"
232LIB_DIRECTORY="$LIB_VERSION"
233LIB_URL="ftp://xmlsoft.org/libxml2/"
234
235mkdir -p libxml2
236pushd libxml2 > /dev/null
237
238if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
239then
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
252else
253 already_built
254fi
255popd > /dev/null
256
257# --------------------------------------------------------------
258
259echo -e "Building SDL..."
260
261LIB_VERSION="${SDL_VERSION}"
262LIB_ARCHIVE="$LIB_VERSION.tar.gz"
263LIB_DIRECTORY=$LIB_VERSION
264LIB_URL="http://www.libsdl.org/release/"
265
266mkdir -p sdl
267pushd sdl > /dev/null
268
269if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
270then
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
286else
287 already_built
288fi
289popd > /dev/null
290
291# --------------------------------------------------------------
292echo -e "Building Boost..."
293
294LIB_VERSION="${BOOST_VERSION}"
295LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
296LIB_DIRECTORY="$LIB_VERSION"
297LIB_URL="http://download.sourceforge.net/boost/"
298
299mkdir -p boost
300pushd boost > /dev/null
301
302if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
303then
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
318else
319 already_built
320fi
321popd > /dev/null
322
323# --------------------------------------------------------------
324# TODO: This build takes ages, anything we can exlude?
325echo -e "skipping wxWidgets..."
326
327
328# --------------------------------------------------------------
329echo -e "Building libjpg..."
330
331LIB_VERSION="${JPEG_VERSION}"
332LIB_ARCHIVE="$LIB_VERSION.tar.gz"
333LIB_DIRECTORY="${JPEG_DIR}"
334LIB_URL="http://www.ijg.org/files/"
335
336mkdir -p libjpg
337pushd libjpg > /dev/null
338
339if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
340then
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
353else
354 already_built
355fi
356popd > /dev/null
357
358# --------------------------------------------------------------
359echo -e "Building libpng..."
360
361LIB_VERSION="${PNG_VERSION}"
362LIB_ARCHIVE="$LIB_VERSION.tar.gz"
363LIB_DIRECTORY="$LIB_VERSION"
364LIB_URL="http://download.sourceforge.net/libpng/"
365
366mkdir -p libpng
367pushd libpng > /dev/null
368
369if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
370then
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
383else
384 already_built
385fi
386popd > /dev/null
387
388# --------------------------------------------------------------
389echo -e "Building libogg..."
390
391LIB_VERSION="${OGG_VERSION}"
392LIB_ARCHIVE="$LIB_VERSION.tar.gz"
393LIB_DIRECTORY="$LIB_VERSION"
394LIB_URL="http://downloads.xiph.org/releases/ogg/"
395
396# Dependency of vorbis
397# we can install them in the same directory for convenience
398mkdir -p libogg
399mkdir -p vorbis
400
401pushd libogg > /dev/null
402OGG_DIR="$(pwd)"
403
404if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
405then
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
416else
417 already_built
418fi
419popd > /dev/null
420
421# --------------------------------------------------------------
422echo -e "Building libvorbis..."
423
424LIB_VERSION="${VORBIS_VERSION}"
425LIB_ARCHIVE="$LIB_VERSION.tar.gz"
426LIB_DIRECTORY="$LIB_VERSION"
427LIB_URL="http://downloads.xiph.org/releases/vorbis/"
428
429pushd vorbis > /dev/null
430
431if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
432then
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
445else
446 already_built
447fi
448popd > /dev/null
449
450# --------------------------------------------------------------
451echo -e "Building gloox..."
452
453LIB_VERSION="${GLOOX_VERSION}"
454LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
455LIB_DIRECTORY="$LIB_VERSION"
456LIB_URL="http://camaya.net/download/"
457
458mkdir -p gloox
459pushd gloox > /dev/null
460
461if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
462then
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
478else
479 already_built
480fi
481popd > /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# --------------------------------------------------------------------
487echo -e "Building Spidermonkey..."
488export CC=${CC:="clang"} CXX=${CXX:="clang++"}
489
490LIB_VERSION="mozjs-24.2.0"
491LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
492LIB_DIRECTORY="mozjs24"
493
494pushd ../source/spidermonkey/ > /dev/null
495
496if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
497then
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
542else
543 already_built
544fi
545popd > /dev/null
546export CC=${CC:="clang"} CXX=${CXX:="clang++ "}
547
548# --------------------------------------------------------------
549echo -e "Building ENet..."
550
551pushd ../source/enet/ > /dev/null
552
553if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]]
554then
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
562else
563 already_built
564fi
565popd > /dev/null
566
567# --------------------------------------------------------------
568# NVTT - no install
569echo -e "Building NVTT..."
570
571pushd ../source/nvtt > /dev/null
572
573if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]]
574then
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
594else
595 already_built
596fi
597popd > /dev/null
598
599# --------------------------------------------------------------
600# FCollada - no install
601echo -e "Building FCollada..."
602
603pushd ../source/fcollada > /dev/null
604
605if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]]
606then
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
621else
622 already_built
623fi
624popd > /dev/null
625
626# --------------------------------------------------------------
627# MiniUPnPc - no install
628echo -e "Building MiniUPnPc..."
629
630pushd ../source/miniupnpc > /dev/null
631
632if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]]
633then
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
646else
647 already_built
648fi
649popd > /dev/null