3 # Build a fat binary on Mac OS X, thanks Ryan!
5 # Number of CPUs (for make -j)
6 NCPU=`sysctl -n hw.ncpu`
10 # Generic, cross-platform CFLAGS you always want go here.
13 # Locate Xcode SDK path
14 SDK_PATH=/Developer/SDKs
15 if [ ! -d $SDK_PATH ]; then
16 echo "Couldn't find SDK path"
20 # See if we can use 10.2 or 10.3 runtime compatibility
21 if [ -d "$SDK_PATH/MacOSX10.2.8.sdk" ]; then
22 # PowerPC configure flags (10.2 runtime compatibility)
23 # We dynamically load X11, so using the system X11 headers is fine.
24 CONFIG_PPC="--build=`uname -p`-apple-darwin --host=powerpc-apple-darwin \
25 --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
27 # PowerPC compiler flags
28 CC_PPC="gcc-3.3 -arch ppc"
29 CXX_PPC="g++-3.3 -arch ppc"
31 CPPFLAGS_PPC="-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
33 -F$SDK_PATH/MacOSX10.2.8.sdk/System/Library/Frameworks \
34 -I$SDK_PATH/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
35 -isystem $SDK_PATH/MacOSX10.2.8.sdk/usr/include"
37 # PowerPC linker flags
38 LFLAGS_PPC="-Wl,-headerpad_max_install_names -arch ppc \
39 -L$SDK_PATH/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
40 -F$SDK_PATH/MacOSX10.2.8.sdk/System/Library/Frameworks \
41 -Wl,-syslibroot,$SDK_PATH/MacOSX10.2.8.sdk"
43 else # 10.2 or 10.3 SDK
45 # PowerPC configure flags (10.3 runtime compatibility)
46 # We dynamically load X11, so using the system X11 headers is fine.
47 CONFIG_PPC="--build=`uname -p`-apple-darwin --host=powerpc-apple-darwin \
48 --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
50 # PowerPC compiler flags
51 CC_PPC="gcc-4.0 -arch ppc"
52 CXX_PPC="g++-4.0 -arch ppc"
54 CPPFLAGS_PPC="-DMAC_OS_X_VERSION_MIN_REQUIRED=1030 \
56 -F$SDK_PATH/MacOSX10.3.9.sdk/System/Library/Frameworks \
57 -I$SDK_PATH/MacOSX10.3.9.sdk/usr/lib/gcc/powerpc-apple-darwin9/4.0.1/include \
58 -isystem $SDK_PATH/MacOSX10.3.9.sdk/usr/include"
60 # PowerPC linker flags
61 LFLAGS_PPC="-Wl,-headerpad_max_install_names -arch ppc -mmacosx-version-min=10.3 \
62 -L$SDK_PATH/MacOSX10.3.9.sdk/usr/lib/gcc/powerpc-apple-darwin9/4.0.1 \
63 -F$SDK_PATH/MacOSX10.3.9.sdk/System/Library/Frameworks \
64 -Wl,-syslibroot,$SDK_PATH/MacOSX10.3.9.sdk"
68 # Intel configure flags (10.4 runtime compatibility)
69 # We dynamically load X11, so using the system X11 headers is fine.
70 CONFIG_X86="--build=`uname -p`-apple-darwin --host=i386-apple-darwin \
71 --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
73 # Intel compiler flags
74 CC_X86="gcc-4.0 -arch i386"
75 CXX_X86="g++-4.0 -arch i386"
76 CFLAGS_X86="-mmacosx-version-min=10.4"
77 CPPFLAGS_X86="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
79 -F$SDK_PATH/MacOSX10.4u.sdk/System/Library/Frameworks \
80 -I$SDK_PATH/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1/include \
81 -isystem $SDK_PATH/MacOSX10.4u.sdk/usr/include"
84 LFLAGS_X86="-Wl,-headerpad_max_install_names -arch i386 -mmacosx-version-min=10.4 \
85 -L$SDK_PATH/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1 \
86 -Wl,-syslibroot,$SDK_PATH/MacOSX10.4u.sdk"
89 # Find the configure script
91 srcdir=`dirname $0`/..
92 auxdir=$srcdir/build-scripts
96 # Figure out which phase to build:
98 # configure, configure-ppc, configure-x86,
99 # make, make-ppc, make-x86, merge
102 if test x"$1" = x; then
172 echo "Usage: $0 [all|configure[-ppc|-x86]|make[-ppc|-x86]|merge|install|clean]"
184 echo "Couldn't figure out native architecture path"
190 # Create the build directories
192 for dir in build build/ppc build/x86; do
193 if test -d $dir; then
201 # Build the PowerPC binary
203 if test x$configure_ppc = xyes; then
205 sh ../../configure $CONFIG_PPC CC="$CC_PPC" CXX="$CXX_PPC" CFLAGS="$CFLAGS $CFLAGS_PPC" CPPFLAGS="$CPPFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2
207 if test x$make_ppc = xyes; then
208 (cd build/ppc && ls include && make -j$NJOB) || exit 3
212 # Build the Intel binary
214 if test x$configure_x86 = xyes; then
216 sh ../../configure $CONFIG_X86 CC="$CC_X86" CXX="$CXX_X86" CFLAGS="$CFLAGS $CFLAGS_X86" CPPFLAGS="$CPPFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2
218 if test x$make_x86 = xyes; then
219 (cd build/x86 && make -j$NJOB) || exit 3
223 # Combine into fat binary
225 if test x$merge = xyes; then
227 sh $auxdir/mkinstalldirs build/$output
229 target=`find . -mindepth 3 -type f -name '*.dylib' | head -1 | sed 's|.*/||'`
230 (lipo -create -o $output/$target `find . -mindepth 3 -type f -name "*.dylib"` &&
231 ln -sf $target $output/libSDL-1.2.0.dylib &&
232 ln -sf $target $output/libSDL.dylib &&
233 lipo -create -o $output/libSDL.a */build/.libs/libSDL.a &&
234 cp $native_path/build/.libs/libSDL.la $output &&
235 cp $native_path/build/.libs/libSDL.lai $output &&
236 cp $native_path/build/libSDL.la . &&
237 lipo -create -o libSDLmain.a */build/libSDLmain.a &&
238 echo "Build complete!" &&
239 echo "Files can be found in the build directory.") || exit 4
251 if test x$prefix = x; then
254 if test x$exec_prefix = x; then
257 if test x$bindir = x; then
258 bindir=$exec_prefix/bin
260 if test x$libdir = x; then
261 libdir=$exec_prefix/lib
263 if test x$includedir = x; then
264 includedir=$prefix/include
266 if test x$datadir = x; then
267 datadir=$prefix/share
269 if test x$mandir = x; then
272 if test x$install_bin = xyes; then
273 do_install sh $auxdir/mkinstalldirs $bindir
274 do_install /usr/bin/install -c -m 755 build/$native_path/sdl-config $bindir/sdl-config
276 if test x$install_hdrs = xyes; then
277 do_install sh $auxdir/mkinstalldirs $includedir/SDL
278 for src in $srcdir/include/*.h; do \
279 file=`echo $src | sed -e 's|^.*/||'`; \
280 do_install /usr/bin/install -c -m 644 $src $includedir/SDL/$file; \
282 do_install /usr/bin/install -c -m 644 $srcdir/include/SDL_config_macosx.h $includedir/SDL/SDL_config.h
284 if test x$install_lib = xyes; then
285 do_install sh $auxdir/mkinstalldirs $libdir
286 do_install sh build/$native_path/libtool --mode=install /usr/bin/install -c build/libSDL.la $libdir/libSDL.la
287 do_install /usr/bin/install -c -m 644 build/libSDLmain.a $libdir/libSDLmain.a
288 do_install ranlib $libdir/libSDLmain.a
290 if test x$install_data = xyes; then
291 do_install sh $auxdir/mkinstalldirs $datadir/aclocal
292 do_install /usr/bin/install -c -m 644 $srcdir/sdl.m4 $datadir/aclocal/sdl.m4
294 if test x$install_man = xyes; then
295 do_install sh $auxdir/mkinstalldirs $mandir/man3
296 for src in $srcdir/docs/man3/*.3; do \
297 file=`echo $src | sed -e 's|^.*/||'`; \
298 do_install /usr/bin/install -c -m 644 $src $mandir/man3/$file; \
310 if test x$clean_x86 = xyes; then
311 do_clean rm -r build/x86
313 if test x$clean_ppc = xyes; then
314 do_clean rm -r build/ppc