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