1#!/bin/sh 2APPBUNDLE=OpenArena.app 3BINARY=openarena.ub 4DEDBIN=oa_ded.ub 5PKGINFO=APPLIOOA 6ICNS=misc/quake3.icns 7DESTDIR=build/release-darwin-ub 8BASEDIR=baseoa 9MPACKDIR=missionpack 10 11BIN_OBJ=" 12 build/release-darwin-ppc/openarena-smp.ppc 13 build/release-darwin-i386/openarena-smp.i386 14" 15BIN_DEDOBJ=" 16 build/release-darwin-ppc/oa_ded.ppc 17 build/release-darwin-i386/oa_ded.i386 18" 19BASE_OBJ=" 20 build/release-darwin-ppc/$BASEDIR/cgameppc.dylib 21 build/release-darwin-i386/$BASEDIR/cgamei386.dylib 22 build/release-darwin-ppc/$BASEDIR/uippc.dylib 23 build/release-darwin-i386/$BASEDIR/uii386.dylib 24 build/release-darwin-ppc/$BASEDIR/qagameppc.dylib 25 build/release-darwin-i386/$BASEDIR/qagamei386.dylib 26" 27MPACK_OBJ=" 28 build/release-darwin-ppc/$MPACKDIR/cgameppc.dylib 29 build/release-darwin-i386/$MPACKDIR/cgamei386.dylib 30 build/release-darwin-ppc/$MPACKDIR/uippc.dylib 31 build/release-darwin-i386/$MPACKDIR/uii386.dylib 32 build/release-darwin-ppc/$MPACKDIR/qagameppc.dylib 33 build/release-darwin-i386/$MPACKDIR/qagamei386.dylib 34" 35 36cd `dirname $0` 37if [ ! -f Makefile ]; then 38 echo "This script must be run from the ioquake3 build directory" 39 exit 1 40fi 41 42Q3_VERSION=`grep '^VERSION=' Makefile | sed -e 's/.*=\(.*\)/\1/'` 43 44# We only care if we're >= 10.4, not if we're specifically Tiger. 45# "8" is the Darwin major kernel version. 46TIGERHOST=`uname -r |perl -w -p -e 's/\A(\d+)\..*\Z/$1/; $_ = (($_ >= 8) ? "1" : "0");'` 47 48# we want to use the oldest available SDK for max compatiblity 49unset PPC_SDK 50unset PPC_CFLAGS 51unset PPC_LDFLAGS 52unset X86_SDK 53unset X86_CFLAGS 54unset X86_LDFLAGS 55if [ -d /Developer/SDKs/MacOSX10.5.sdk ]; then 56 PPC_SDK=/Developer/SDKs/MacOSX10.5.sdk 57 PPC_CFLAGS="-arch ppc -isysroot /Developer/SDKs/MacOSX10.5.sdk \ 58 -DMAC_OS_X_VERSION_MIN_REQUIRED=1050" 59 PPC_LDFLAGS=" -mmacosx-version-min=10.5" 60 61 X86_SDK=/Developer/SDKs/MacOSX10.5.sdk 62 X86_CFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk \ 63 -DMAC_OS_X_VERSION_MIN_REQUIRED=1050" 64 X86_LDFLAGS=" -mmacosx-version-min=10.5" 65fi 66 67if [ -d /Developer/SDKs/MacOSX10.4u.sdk ]; then 68 PPC_SDK=/Developer/SDKs/MacOSX10.4u.sdk 69 PPC_CFLAGS="-arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk \ 70 -DMAC_OS_X_VERSION_MIN_REQUIRED=1040" 71 PPC_LDFLAGS=" -mmacosx-version-min=10.4" 72 73 X86_SDK=/Developer/SDKs/MacOSX10.4u.sdk 74 X86_CFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk \ 75 -DMAC_OS_X_VERSION_MIN_REQUIRED=1040" 76 X86_LDFLAGS=" -mmacosx-version-min=10.4" 77fi 78 79if [ -d /Developer/SDKs/MacOSX10.3.9.sdk ] && [ $TIGERHOST ]; then 80 PPC_SDK=/Developer/SDKs/MacOSX10.3.9.sdk 81 PPC_CFLAGS="-arch ppc -isysroot /Developer/SDKs/MacOSX10.3.9.sdk \ 82 -DMAC_OS_X_VERSION_MIN_REQUIRED=1030" 83 PPC_LDFLAGS=" -mmacosx-version-min=10.3" 84fi 85 86if [ -z $PPC_SDK ] || [ -z $X86_SDK ]; then 87 echo "\ 88ERROR: This script is for building a Universal Binary. You cannot build 89 for a different architecture unless you have the proper Mac OS X SDKs 90 installed. If you just want to to compile for your own system run 91 'make' instead of this script." 92 exit 1 93fi 94 95echo "Building PPC Client/Dedicated Server against \"$PPC_SDK\"" 96echo "Building X86 Client/Dedicated Server against \"$X86_SDK\"" 97if [ "$PPC_SDK" != "/Developer/SDKs/MacOSX10.3.9.sdk" ] || \ 98 [ "$X86_SDK" != "/Developer/SDKs/MacOSX10.4u.sdk" ]; then 99 echo "\ 100WARNING: in order to build a binary with maximum compatibility you must 101 build on Mac OS X 10.4 using Xcode 2.3 or 2.5 and have the 102 MacOSX10.3.9, and MacOSX10.4u SDKs installed from the Xcode 103 install disk Packages folder." 104fi 105sleep 3 106 107if [ ! -d $DESTDIR ]; then 108 mkdir -p $DESTDIR 109fi 110 111# For parallel make on multicore boxes... 112NCPU=`sysctl -n hw.ncpu` 113 114# ppc client and server 115if [ -d build/release-darwin-ppc ]; then 116 rm -r build/release-darwin-ppc 117fi 118(ARCH=ppc CFLAGS=$PPC_CFLAGS LDFLAGS="$PPC_LDFLAGS -L./libs" make -j$NCPU) || exit 1; 119 120# intel client and server 121if [ -d build/release-darwin-i386 ]; then 122 rm -r build/release-darwin-i386 123fi 124(ARCH=i386 CFLAGS=$X86_CFLAGS LDFLAGS="$X86_LDFLAGS -L./libs" make -j$NCPU) || exit 1; 125 126echo "Creating .app bundle $DESTDIR/$APPBUNDLE" 127if [ ! -d $DESTDIR/$APPBUNDLE/Contents/MacOS/$BASEDIR ]; then 128 mkdir -p $DESTDIR/$APPBUNDLE/Contents/MacOS/$BASEDIR || exit 1; 129fi 130if [ ! -d $DESTDIR/$APPBUNDLE/Contents/MacOS/$MPACKDIR ]; then 131 mkdir -p $DESTDIR/$APPBUNDLE/Contents/MacOS/$MPACKDIR || exit 1; 132fi 133if [ ! -d $DESTDIR/$APPBUNDLE/Contents/Resources ]; then 134 mkdir -p $DESTDIR/$APPBUNDLE/Contents/Resources 135fi 136cp $ICNS $DESTDIR/$APPBUNDLE/Contents/Resources/ioquake3.icns || exit 1; 137echo $PKGINFO > $DESTDIR/$APPBUNDLE/Contents/PkgInfo 138echo " 139 <?xml version=\"1.0\" encoding=\"UTF-8\"?> 140 <!DOCTYPE plist 141 PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" 142 \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> 143 <plist version=\"1.0\"> 144 <dict> 145 <key>CFBundleDevelopmentRegion</key> 146 <string>English</string> 147 <key>CFBundleExecutable</key> 148 <string>$BINARY</string> 149 <key>CFBundleGetInfoString</key> 150 <string>OpenArena $Q3_VERSION</string> 151 <key>CFBundleIconFile</key> 152 <string>ioquake3.icns</string> 153 <key>CFBundleIdentifier</key> 154 <string>ws.openarena.OpenArena</string> 155 <key>CFBundleInfoDictionaryVersion</key> 156 <string>6.0</string> 157 <key>CFBundleName</key> 158 <string>OpenArena</string> 159 <key>CFBundlePackageType</key> 160 <string>APPL</string> 161 <key>CFBundleShortVersionString</key> 162 <string>$Q3_VERSION</string> 163 <key>CFBundleSignature</key> 164 <string>$PKGINFO</string> 165 <key>CFBundleVersion</key> 166 <string>$Q3_VERSION</string> 167 <key>NSExtensions</key> 168 <dict/> 169 <key>NSPrincipalClass</key> 170 <string>NSApplication</string> 171 </dict> 172 </plist> 173 " > $DESTDIR/$APPBUNDLE/Contents/Info.plist 174 175lipo -create -o $DESTDIR/$APPBUNDLE/Contents/MacOS/$BINARY $BIN_OBJ 176lipo -create -o $DESTDIR/$APPBUNDLE/Contents/MacOS/$DEDBIN $BIN_DEDOBJ 177cp $BASE_OBJ $DESTDIR/$APPBUNDLE/Contents/MacOS/$BASEDIR/ 178cp $MPACK_OBJ $DESTDIR/$APPBUNDLE/Contents/MacOS/$MPACKDIR/ 179cp code/libs/macosx/*.dylib $DESTDIR/$APPBUNDLE/Contents/MacOS/ 180 181