1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | # Script for acquiring and building OSX 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 temp 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, every developer 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 | set -e
|
---|
23 |
|
---|
24 | die()
|
---|
25 | {
|
---|
26 | echo ERROR: $*
|
---|
27 | exit 1
|
---|
28 | }
|
---|
29 |
|
---|
30 | download_lib()
|
---|
31 | {
|
---|
32 | local url=$1
|
---|
33 | local filename=$2
|
---|
34 |
|
---|
35 | if [ ! -e $filename ]; then
|
---|
36 | echo "Downloading $filename"
|
---|
37 | curl -L -O ${url}${filename} || die "Download of $url$filename failed"
|
---|
38 | fi
|
---|
39 | }
|
---|
40 |
|
---|
41 | JOBS=${JOBS:="-j5"}
|
---|
42 |
|
---|
43 | # Define compiler as GCC (in case anything expects e.g. gcc-4.2)
|
---|
44 | export CC=${CC:="gcc"} CXX=${CXX:="g++"}
|
---|
45 |
|
---|
46 | # The various libs offer inconsistent configure options, some allow
|
---|
47 | # setting sysroot and OSX-specific options, others don't. Adding to
|
---|
48 | # the confusion, Apple moved /Developer/SDKs into the Xcode app bundle
|
---|
49 | # so the path can't be guessed by clever build tools (like Boost.Build)
|
---|
50 | # This is why we set CFLAGS, CPPFLAGS, and LDFLAGS.
|
---|
51 |
|
---|
52 | # Check if SYSROOT is set and not empty
|
---|
53 | if [[ $SYSROOT && ${SYSROOT-_} ]]; then
|
---|
54 | CFLAGS="$CFLAGS -isysroot $SYSROOT"
|
---|
55 | CPPFLAGS="$CPPFLAGS -isysroot $SYSROOT"
|
---|
56 | LDFLAGS="$LDFLAGS -Wl,-syslibroot,$SYSROOT"
|
---|
57 | fi
|
---|
58 | # Check if MIN_OSX_VERSION is set and not empty
|
---|
59 | if [[ $MIN_OSX_VERSION && ${MIN_OSX_VERSION-_} ]]; then
|
---|
60 | CFLAGS="$CFLAGS -mmacosx-version-min=$MIN_OSX_VERSION"
|
---|
61 | CPPFLAGS="$CPPFLAGS -mmacosx-version-min=$MIN_OSX_VERSION"
|
---|
62 | fi
|
---|
63 | # Force 64-bit build (we could also add 32-bit if we want universal)
|
---|
64 | CFLAGS="$CFLAGS -arch x86_64"
|
---|
65 | CPPFLAGS="$CPPFLAGS -arch x86_64"
|
---|
66 | LDFLAGS="$LDFLAGS -arch x86_64"
|
---|
67 |
|
---|
68 | cd "$(dirname $0)"
|
---|
69 | # Now in libraries/osx/ (where we assume this script resides)
|
---|
70 |
|
---|
71 | # TODO: Do we really want to rebuild these every time?
|
---|
72 |
|
---|
73 | # ---------------------------------------------------
|
---|
74 | echo -e "\nBuilding SDL...\n"
|
---|
75 |
|
---|
76 | # SDL 1.2.15 required for Lion support
|
---|
77 | LIB_VERSION="SDL-1.2.15"
|
---|
78 | LIB_ARCHIVE="$LIB_VERSION.tar.gz"
|
---|
79 | LIB_DIRECTORY=$LIB_VERSION
|
---|
80 | LIB_URL="http://www.libsdl.org/release/"
|
---|
81 |
|
---|
82 | mkdir -p sdl
|
---|
83 | cd sdl
|
---|
84 |
|
---|
85 | INSTALL_DIR="$(pwd)"
|
---|
86 |
|
---|
87 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
88 |
|
---|
89 | rm -rf $LIB_DIRECTORY
|
---|
90 | tar -xf $LIB_ARCHIVE
|
---|
91 | cd $LIB_DIRECTORY
|
---|
92 |
|
---|
93 | (./configure CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" --prefix="$INSTALL_DIR" --enable-shared=no && make $JOBS && make install) || die "SDL build failed"
|
---|
94 |
|
---|
95 | cd ../../
|
---|
96 |
|
---|
97 | # ---------------------------------------------------
|
---|
98 | echo -e "\nBuilding Boost...\n"
|
---|
99 |
|
---|
100 | LIB_VERSION="boost_1_49_0"
|
---|
101 | LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
|
---|
102 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
103 | LIB_URL="http://download.sourceforge.net/boost/"
|
---|
104 |
|
---|
105 | mkdir -p boost
|
---|
106 | cd boost
|
---|
107 |
|
---|
108 | INSTALL_DIR="$(pwd)"
|
---|
109 |
|
---|
110 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
111 |
|
---|
112 | rm -rf $LIB_DIRECTORY
|
---|
113 | tar -xf $LIB_ARCHIVE
|
---|
114 | cd $LIB_DIRECTORY
|
---|
115 |
|
---|
116 | # Can't use macosx-version because Boost only searches /Developer for SDKs
|
---|
117 | (./bootstrap.sh --with-libraries=filesystem,system,signals --prefix=$INSTALL_DIR && ./b2 cflags="$CFLAGS" cxxflags="$CPPFLAGS" linkflags="$LDFLAGS" -d2 --layout=tagged --debug-configuration link=static threading=multi variant=release,debug install) || die "Boost build failed"
|
---|
118 |
|
---|
119 | # Copy files
|
---|
120 | cd ../../
|
---|
121 |
|
---|
122 | # ---------------------------------------------------
|
---|
123 | echo -e "\nBuilding wxWidgets...\n"
|
---|
124 |
|
---|
125 | # wxWidgets is required for Atlas
|
---|
126 | # version 2.9+ is necessary for 64-bit OSX build
|
---|
127 | # with OpenGL support
|
---|
128 | # TODO: This build takes ages, anything we can exlude?
|
---|
129 |
|
---|
130 | LIB_VERSION="wxWidgets-2.9.3"
|
---|
131 | LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
|
---|
132 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
133 | LIB_URL="http://download.sourceforge.net/wxwindows/"
|
---|
134 |
|
---|
135 | mkdir -p wxwidgets
|
---|
136 | cd wxwidgets
|
---|
137 |
|
---|
138 | INSTALL_DIR="$(pwd)"
|
---|
139 |
|
---|
140 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
141 |
|
---|
142 | rm -rf $LIB_DIRECTORY
|
---|
143 | tar -xf $LIB_ARCHIVE
|
---|
144 | cd $LIB_DIRECTORY
|
---|
145 |
|
---|
146 | mkdir -p build-release
|
---|
147 | cd build-release
|
---|
148 |
|
---|
149 | CONF_OPTS="--prefix=$INSTALL_DIR --disable-shared --enable-unicode --with-cocoa --with-opengl"
|
---|
150 | if [[ $MIN_OSX_VERSION && ${MIN_OSX_VERSION-_} ]]; then
|
---|
151 | CONF_OPTS="$CONF_OPTS --with-macosx-version-min=$MIN_OSX_VERSION"
|
---|
152 | fi
|
---|
153 | if [[ $SYSROOT && ${SYSROOT-_} ]]; then
|
---|
154 | CONF_OPTS="$CONF_OPTS --with-macosx-sdk=$SYSROOT"
|
---|
155 | fi
|
---|
156 |
|
---|
157 | (../configure $CONF_OPTS && make $JOBS && make install) || die "wxWidgets build failed"
|
---|
158 |
|
---|
159 | cd ../../../
|
---|
160 |
|
---|
161 | # ---------------------------------------------------
|
---|
162 | echo -e "\nBuilding libjpg...\n"
|
---|
163 |
|
---|
164 | LIB_VERSION="jpegsrc.v8c"
|
---|
165 | LIB_ARCHIVE="$LIB_VERSION.tar.gz"
|
---|
166 | LIB_DIRECTORY="jpeg-8c"
|
---|
167 | LIB_URL="http://www.ijg.org/files/"
|
---|
168 |
|
---|
169 | mkdir -p libjpg
|
---|
170 | cd libjpg
|
---|
171 |
|
---|
172 | INSTALL_DIR="$(pwd)"
|
---|
173 |
|
---|
174 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
175 |
|
---|
176 | rm -rf $LIB_DIRECTORY
|
---|
177 | tar -xf $LIB_ARCHIVE
|
---|
178 | cd $LIB_DIRECTORY
|
---|
179 |
|
---|
180 | CONF_OPTS="--prefix=$INSTALL_DIR --enable-shared=no"
|
---|
181 | if [[ $SYSROOT && ${SYSROOT-_} ]]; then
|
---|
182 | CONF_OPTS="$CONF_OPTS --with-sysroot=$SYSROOT"
|
---|
183 | fi
|
---|
184 | (./configure $CONF_OPTS && make $JOBS && make install) || die "libjpg build failed"
|
---|
185 |
|
---|
186 | cd ../../
|
---|
187 |
|
---|
188 | # ---------------------------------------------------
|
---|
189 | echo -e "\nBuilding libpng...\n"
|
---|
190 |
|
---|
191 | # Even though libpng is provided in the SDK, the 10.6 bundled version
|
---|
192 | # is the ancient 1.2 which lacks functions we use like
|
---|
193 | # png_set_longjmp_fn, so it seems better to provide it ourselves
|
---|
194 |
|
---|
195 | LIB_VERSION="libpng-1.5.8"
|
---|
196 | LIB_ARCHIVE="$LIB_VERSION.tar.gz"
|
---|
197 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
198 | LIB_URL="http://download.sourceforge.net/libpng/"
|
---|
199 |
|
---|
200 | mkdir -p libpng
|
---|
201 | cd libpng
|
---|
202 |
|
---|
203 | INSTALL_DIR="$(pwd)"
|
---|
204 |
|
---|
205 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
206 |
|
---|
207 | rm -rf $LIB_DIRECTORY
|
---|
208 | tar -xf $LIB_ARCHIVE
|
---|
209 | cd $LIB_DIRECTORY
|
---|
210 |
|
---|
211 | CONF_OPTS="--prefix=$INSTALL_DIR --enable-shared=no"
|
---|
212 | if [[ $SYSROOT && ${SYSROOT-_} ]]; then
|
---|
213 | CONF_OPTS="$CONF_OPTS --with-sysroot=$SYSROOT"
|
---|
214 | fi
|
---|
215 | (./configure $CONF_OPTS && make $JOBS && make install) || die "libpng build failed"
|
---|
216 |
|
---|
217 | cd ../../
|
---|
218 |
|
---|
219 | # ---------------------------------------------------
|
---|
220 | echo -e "\nBuilding libogg...\n"
|
---|
221 |
|
---|
222 | LIB_VERSION="libogg-1.3.0"
|
---|
223 | LIB_ARCHIVE="$LIB_VERSION.tar.gz"
|
---|
224 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
225 | LIB_URL="http://downloads.xiph.org/releases/ogg/"
|
---|
226 |
|
---|
227 | # Dependency of vorbis
|
---|
228 | # we can install them in the same directory for convenience
|
---|
229 | mkdir -p libogg
|
---|
230 | mkdir -p vorbis
|
---|
231 |
|
---|
232 | INSTALL_DIR="$(pwd)/vorbis"
|
---|
233 |
|
---|
234 | cd libogg
|
---|
235 |
|
---|
236 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
237 |
|
---|
238 | rm -rf $LIB_DIRECTORY
|
---|
239 | tar -xf $LIB_ARCHIVE
|
---|
240 | cd $LIB_DIRECTORY
|
---|
241 |
|
---|
242 | CONF_OPTS="--prefix=$INSTALL_DIR --enable-shared=no"
|
---|
243 | if [[ $SYSROOT && ${SYSROOT-_} ]]; then
|
---|
244 | CONF_OPTS="$CONF_OPTS --with-sysroot=$SYSROOT"
|
---|
245 | fi
|
---|
246 | (./configure $CONF_OPTS && make $JOBS && make install) || die "libogg build failed"
|
---|
247 |
|
---|
248 | cd ../../
|
---|
249 |
|
---|
250 | # ---------------------------------------------------
|
---|
251 | echo -e "\nBuilding libvorbis...\n"
|
---|
252 |
|
---|
253 | LIB_VERSION="libvorbis-1.3.2"
|
---|
254 | LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
|
---|
255 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
256 | LIB_URL="http://downloads.xiph.org/releases/vorbis/"
|
---|
257 |
|
---|
258 | cd vorbis
|
---|
259 |
|
---|
260 | INSTALL_DIR="$(pwd)"
|
---|
261 |
|
---|
262 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
263 |
|
---|
264 | rm -rf $LIB_DIRECTORY
|
---|
265 | tar -xf $LIB_ARCHIVE
|
---|
266 | cd $LIB_DIRECTORY
|
---|
267 |
|
---|
268 | (./configure CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" --prefix="$INSTALL_DIR" --enable-shared=no --with-ogg="$INSTALL_DIR" && make $JOBS && make install) || die "libvorbis build failed"
|
---|
269 |
|
---|
270 | cd ../../
|
---|
271 |
|
---|
272 | # ---------------------------------------------------
|
---|
273 | echo -e "\nBuilding libxml2...\n"
|
---|
274 |
|
---|
275 | LIB_VERSION="libxml2-2.7.8"
|
---|
276 | LIB_ARCHIVE="$LIB_VERSION.tar.gz"
|
---|
277 | LIB_DIRECTORY="$LIB_VERSION"
|
---|
278 | LIB_URL="ftp://xmlsoft.org/libxml2/"
|
---|
279 |
|
---|
280 | mkdir -p libxml2
|
---|
281 | cd libxml2
|
---|
282 |
|
---|
283 | INSTALL_DIR="$(pwd)"
|
---|
284 |
|
---|
285 | download_lib $LIB_URL $LIB_ARCHIVE
|
---|
286 |
|
---|
287 | rm -rf $LIB_DIRECTORY
|
---|
288 | tar -xf $LIB_ARCHIVE
|
---|
289 | cd $LIB_DIRECTORY
|
---|
290 |
|
---|
291 | (./configure CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" --prefix="$INSTALL_DIR" --enable-shared=no && make $JOBS && make install) || die "libxml2 build failed"
|
---|
292 |
|
---|
293 | cd ../../
|
---|
294 |
|
---|
295 |
|
---|
296 | # ---------------------------------------------------
|
---|
297 | # The following libraries are shared on different
|
---|
298 | # OSes and may be modified, so we build and install
|
---|
299 | # them from bundled sources
|
---|
300 | # ---------------------------------------------------
|
---|
301 | echo -e "\nBuilding Spidermonkey...\n"
|
---|
302 | pushd ../source/spidermonkey/
|
---|
303 |
|
---|
304 | INSTALL_DIR="$(pwd)"
|
---|
305 |
|
---|
306 | rm -f lib/*.a
|
---|
307 | rm -rf js-1.8.5
|
---|
308 | tar -xf js185-1.0.0.tar.gz
|
---|
309 | cd js-1.8.5/js/src
|
---|
310 |
|
---|
311 | # We want separate debug/release versions of the library, so change their install name in the Makefile
|
---|
312 | sed -i.bak -e 's/\(STATIC_LIBRARY_NAME),mozjs185-\)\(\$(SRCREL_ABI_VERSION)\)\{0,1\}/\1ps-debug/' Makefile.in
|
---|
313 |
|
---|
314 | CONF_OPTS="--prefix=${INSTALL_DIR} --disable-tests --disable-shared-js"
|
---|
315 | if [[ $MIN_OSX_VERSION && ${MIN_OSX_VERSION-_} ]]; then
|
---|
316 | CONF_OPTS="$CONF_OPTS --enable-macos-target=$MIN_OSX_VERSION"
|
---|
317 | fi
|
---|
318 | if [[ $SYSROOT && ${SYSROOT-_} ]]; then
|
---|
319 | CONF_OPTS="$CONF_OPTS --with-macosx-sdk=$SYSROOT"
|
---|
320 | fi
|
---|
321 |
|
---|
322 | mkdir -p build-debug
|
---|
323 | cd build-debug
|
---|
324 | (../configure $CONF_OPTS --enable-debug --disable-optimize && make ${JOBS} && make install) || die "Spidermonkey build failed"
|
---|
325 | cd ..
|
---|
326 |
|
---|
327 | sed -i.bak -e 's/\(STATIC_LIBRARY_NAME),mozjs185-\)\(ps-debug\)\{0,1\}/\1ps-release/' Makefile.in
|
---|
328 |
|
---|
329 | mkdir -p build-release
|
---|
330 | cd build-release
|
---|
331 | (../configure $CONF_OPTS && make ${JOBS} && make install) || die "Spidermonkey build failed"
|
---|
332 | cd ..
|
---|
333 |
|
---|
334 | # Remove the install name changes to avoid spurious SVN diffs
|
---|
335 | sed -i.bak -e 's/\(STATIC_LIBRARY_NAME),mozjs185-\)\(ps-release\)\{0,1\}/\1$(SRCREL_ABI_VERSION)/' Makefile.in
|
---|
336 |
|
---|
337 | popd
|
---|
338 |
|
---|
339 | # ---------------------------------------------------
|
---|
340 | echo -e "\nBuilding ENet...\n"
|
---|
341 | pushd ../source/enet/
|
---|
342 |
|
---|
343 | INSTALL_DIR="$(pwd)"
|
---|
344 |
|
---|
345 | pushd src
|
---|
346 | (./configure CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" --prefix=${INSTALL_DIR} --enable-shared=no && make ${JOBS} && make install) || die "ENet build failed"
|
---|
347 | popd
|
---|
348 |
|
---|
349 | popd
|
---|
350 |
|
---|
351 | # ---------------------------------------------------
|
---|
352 | # NVTT - no install
|
---|
353 | echo -e "\nBuilding NVTT...\n"
|
---|
354 | pushd ../source/nvtt/src
|
---|
355 |
|
---|
356 | rm -rf build
|
---|
357 | mkdir -p build
|
---|
358 |
|
---|
359 | pushd build
|
---|
360 |
|
---|
361 | CMAKE_OPTS=""
|
---|
362 | if [[ $SYSROOT && ${SYSROOT-_} ]]; then
|
---|
363 | CMAKE_OPTS="-DCMAKE_OSX_SYSROOT=$SYSROOT"
|
---|
364 | fi
|
---|
365 | (cmake .. $CMAKE_OPTS -DCMAKE_BUILD_TYPE=Release -DBINDIR=bin -DLIBDIR=lib -DGLUT=0 -DGLEW=0 -DCG=0 -DCUDA=0 -DOPENEXR=0 -G "Unix Makefiles" && make clean && make nvtt ${JOBS}) || die "NVTT build failed"
|
---|
366 | popd
|
---|
367 |
|
---|
368 | mkdir -p ../lib
|
---|
369 | cp build/src/nv*/libnv*.a ../lib/
|
---|
370 | cp build/src/nvtt/squish/libsquish.a ../lib/
|
---|
371 |
|
---|
372 | popd
|
---|
373 |
|
---|
374 | # ---------------------------------------------------
|
---|
375 | # FCollada - no install
|
---|
376 | echo -e "\nBuilding FCollada...\n"
|
---|
377 | pushd ../source/fcollada/src
|
---|
378 |
|
---|
379 | rm -rf output
|
---|
380 | # The Makefile refers to pkg-config for libxml2, but we
|
---|
381 | # don't have that (replace with xml2-config instead)
|
---|
382 | sed -i.bak -e 's/pkg-config libxml-2.0/xml2-config/' Makefile
|
---|
383 | make $JOBS || die "FCollada build failed"
|
---|
384 | # Undo Makefile change
|
---|
385 | sed -i.bak -e 's/xml2-config/pkg-config libxml-2.0/' Makefile
|
---|
386 |
|
---|
387 | popd
|
---|
388 |
|
---|