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