Building STK 06 on OSX
This page will explain how I built and packaged SuperTuxKart on mac OS X. This page is also available in German
You could also use OS X frameworks instead of Unix-style libs, this would of course require heavier patching of the STK build system.
Contents |
Getting Started
- Install developer tools, either from the OS X Install DVD or from Apple's website
- symlink include folder of OpenGL framework to /usr/local/include/GL (Unix programs have an easier time finding it this way)
% sudo ln -s /System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/ /usr/local/include/GL
(you might need to create /usr/local/include/ first if you never built and installed anything from source! sudo mkdir -p /usr/local/include/)
From there you can install dependencies either from source or from macports. Using macports might be easier for newcomers, however be warned that macports has a quite high failure rate, and on failure you will need to contact the macports team, the STK team won't be able to provide support for macports. If you don't mind spending some time on it, building from source is more reliable.
Building dependencies from source
Environment
- Add /usr/local/bin to your PATH, *before* /usr/bin so that the new versions of stuff you install are picked over the older ones installed by default (this might not be necessary if you don't install autotools below)
- In a terminal : sudo nano /etc/profile (enter your password as prompted)
- add the line export PATH=/usr/local/bin:$PATH at the bottom of the file
- Hit Ctrl+O then press enter to save changes.
- Hit Ctrl-X to exit.
- For detailed instructions and explainations, see http://www.troubleshooters.com/linux/prepostpath.htm
- Download pkg-config sources from http://pkgconfig.freedesktop.org/releases/ and build it:
% cd /path/to/pkg-config-0.22
% ./configure
% make
% sudo make install
Autotools
This step is probably only necessary for OS X 10.4 users who use SVN version of STK (I think) - OS X 10.5 users can skip it. On OS X 10.4, you will want to install more recent autotools (the ones that came with your computer are too old). Before doing this, make sure /usr/local/bin is in your PATH as described above otherwise it won't work (will pick old versions and just ignore the new ones).
It is probably possible to install these with macports to make it quicker.
All the following programs can be built and installed with the following commands on the terminal :
% cd /path/to/source_file
% ./configure
% make
% sudo make install
- get M4 from http://ftp.gnu.org/gnu/m4/ and install it
- symlink m4 to gm4 since that's how some programs refer to it.
% sudo ln -s /usr/local/bin/m4 /usr/local/bin/gm4
- Then, build and install autoconf and automake from GNU the same way as described above
Gettext
Build and install gnu gettext using regular ./configure && make && sudo make install
ogg/vorbis
- download libogg sources from http://xiph.org/downloads/
% ./configure
% make
% sudo make install
- download libvorbis from http://xiph.org/downloads/
% ./configure PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
% make
% sudo make install
SDL
- get source code archive from http://www.libsdl.org/download-1.2.php
% cd /path/to/SDL-1.2.13
% ./configure --without-x --disable-x11-video
% make
% sudo make install
PLib
- The sources you can download from the official plib website will not build on mac. Instead, download the modified sources from the dependencies package of the downloads area here : http://sourceforge.net/projects/supertuxkart
% ./configure
% make
% sudo make install
Alternate path : macports
- Add /opt/local/bin to your PATH, *before* /usr/bin (http://www.troubleshooters.com/linux/prepostpath.htm) so that the new versions of stuff you install are picked over the older ones installed by default (this might no be necessary if you don't install autotools below)
These commands install a bit more stuff than needed, because their author jpenguin needed to build other games too.
sudo port -v install pkgconfig sudo port -v install plib sudo port -v install libsdl +quartz sudo port -v install libogg sudo port -v install libvorbis sudo port -v install gettext
OpenAL still causes trouble here, so it's best to use the instructions posted just under.
OpenAL
OpenAL on OS X is a bit of a pain in the a...
- OS X comes with a pre-built OpenAL framework, however this framework apepars to be too old on 10.4. Since we wish to retain 10.4 compatibility, we cannot use Apple's framework so we will instead build from source. If you are on OS X 10.5 and are only building for yourself (not creating any packages) you can simply skip this step.
- The OpenAL repository has been down for ages so use this snapshot if necessary : http://www.mediafire.com/?t3mmdmtwunz
- Unfortunately the OpenAL guys didn't include strong mac support in, so the build procedure is a little complicated.
- Get OpenAL source code
- I personnaly used SVN. It's actually probably not a good idea to use an unstable version. Anyway it worked for me so I leave it this way but you might want to try a source archive or a stable branch instead.
% svn checkout svn://connect.creativelabs.com/OpenAL/trunk openal
% cd openal
- build OpenAL:
- open folder OpenAL-MacOSX, open XCode project
- select target openal.dylib and build style "deployment"
- build
- find /OpenAL-MacOSX/build/Deployment/openal.dylib and copy it to /usr/local/lib, renaming it to libopenal.dylib
% sudo cp ./OpenAL-MacOSX/build/Deployment/openal.dylib /usr/local/lib/libopenal.dylib
% sudo install_name_tool -id /usr/local/lib/libopenal.dylib /usr/local/lib/libopenal.dylib
- copy headers from /OpenAL-MacOSXbuild/include/AL to /usr/local/include/AL
% sudo cp -r ./include/AL/ /usr/local/include/AL
- create openal.pc in /usr/local/lib/pkgconfig (beware, if you copy-and-paste from your browser, line endings may be messed up) :
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: OpenAL
Description: OpenAL blah blah blah not an official .pc file
Requires:
Version: 1.1.0
Libs: -L${libdir} -lopenal
Cflags: -I${includedir}
Building STK
- If you have anything installed in /opt/supertuxkart (like an older version) it's probably a good idea to delete it now so you can start with a clean install.
% ./autogen.sh (for SVN version only?)
% ./configure PKG_CONFIG_PATH=/usr/local/lib/pkgconfig --enable-debug=no --prefix=/opt/supertuxkart
% make
% sudo make install
- You can now launch STK from terminal
% /opt/supertuxkart/games/supertuxkart
- In the rare case that 'make install' doesn't work, but you cand still launch SuperTuxKart from typing './src/supertuxkart' from your source directory; you can still package STK- just use the alternative makeapp.sh script
Making an app bundle
makeapp.sh
INSTALL_PREFIX="/opt/supertuxkart" echo "* Removing any existing installation" rm -rf ./SuperTuxKart.app echo "* Creating skeleton" mkdir -p ./SuperTuxKart.app/Contents/Resources mkdir ./SuperTuxKart.app/Contents/MacOS cp info.plist ./SuperTuxKart.app/Contents/info.plist cp stk.icns ./SuperTuxKart.app/Contents/Resources/stk.icns echo "* Copying executable" cp $INSTALL_PREFIX/games/supertuxkart ./SuperTuxKart.app/Contents/MacOS/supertuxkart echo "* Copying data files" cp -r $INSTALL_PREFIX/share/games/supertuxkart ./SuperTuxKart.app/Contents/Resources/data/
alternative makeapp.sh
INSTALL_PREFIX="/users/jpenguin/supertuxkartirr"
echo "* Removing any existing installation"
rm -rf ./SuperTuxKart.app
echo "* Creating skeleton"
mkdir -p ./SuperTuxKart.app/Contents/Resources
mkdir ./SuperTuxKart.app/Contents/MacOS
cp info.plist ./SuperTuxKart.app/Contents/info.plist
cp stk.icns ./SuperTuxKart.app/Contents/Resources/stk.icns
echo "* Copying executable"
cp $INSTALL_PREFIX/src/supertuxkart ./SuperTuxKart.app/Contents/MacOS/supertuxkart
echo "* Copying data files"
mkdir ./SuperTuxKart.app/Contents/Resources/data
cp -r $INSTALL_PREFIX/data ./SuperTuxKart.app/Contents/Resources/data/data
echo "* Cleaning up SVN files (IGNORE any error that may appear in this section)"
find ./SuperTuxKart.app/Contents/ -name ".svn" -exec rm -rf '{}' \;
For either makeapp.sh
- You'll need an icon file named 'stk.icns'
- Create an Info.plist file like the following one (adapt version number) :
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>English</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CSResourcesFileMapped</key> <true/> <key>CFBundleName</key> <string>SuperTuxKart</string> <key>CFBundleIconFile</key> <string>stk.icns</string> <key>CFBundleExecutable</key> <string>supertuxkart</string> <key>CFBundleVersion</key> <string>0.6</string> <key>CFBundleShortVersionString</key> <string>0.6</string> </dict> </plist>
And run it as :
% chmod +x makeapp.sh
% ./makeapp.sh
You should now be able to open it by double-clicking, however you can't send it to another computer.
Getting ready for distribution
- Here, many strategies are possible, I personnaly used dylib bundler.
Get its sources from http://macdylibbundler.sourceforge.net (version 0.3 or better required), build it and install it.
Issue one of these two depending on your architecture
% dylibbundler -b -x ./SuperTuxKart.app/Contents/MacOS/supertuxkart -d ./SuperTuxKart.app/Contents/libs-ppc/ -od -p @executable_path/../libs-ppc/
% dylibbundler -b -x ./SuperTuxKart.app/Contents/MacOS/supertuxkart -d ./SuperTuxKart.app/Contents/libs-intel/ -od -p @executable_path/../libs-intel/
- To make a Universal Binary, you need to build it on 2 computers, then you can merge the two executable with command
% lipo -create [ppc-file] [intel-file] -output [filename]
Making a DMG
To make a DMG place your executables in a folder, along with the changelog, data/CREDITS, COPYING, ChangeLog & README, and optionnally a background image. Then open disk utility and create a new disk image from folder; once you select the folder you put your files in, select read/write from the format menu in 2nd dialog.
Using a background image : Once that disk image has been created, open it up. Once the disk image is open, change it to icon view; then select Show View Options from the Veiw menu, select "this window only" and then select "picture", choose your image in your disk image, and close the "view options, then resize the window and position the icon how you want example; next open terminal and type
/developer/tools/setfile -a V ''PATHTOIMAGE''
Then open disk utility back up, click on convert, select the supertuxkart disk image you just made, select "compressed (bzip2)"(Panther does not support bz2 compressed dmgs, `soo unless you want to exclude panther users; use another compressed format) from the format drop-down menu, and click save. Your disk image is complete!