This wiki has been moved to https://github.com/SuperTux/wiki into the mediawiki branch.
User:RavuAlHemio/Mac OS X compilation
So you've decided to compile SuperTux on Mac OS X. It's a bit less error-prone than compiling on Windows, so just follow these instructions and you should get it up and running (optionally as a universal binary) in just about no time.
While this document describes how to make use of the OpenGL and OpenAL frameworks that are included with Mac OS X, it tells you how to get SDL compiled and installed UNIX-style (/usr/include and /usr/lib). If you wish to use the SDL framework available on its website, you will have to do some things differently. (This is where Linux programming knowledge is useful.)
This guide also makes you compile SuperTux UNIX-style; you will use the Terminal instead of Xcode. Since it also describes exclusive use of GCC 4.0, your build will only run on versions ≥ Tiger. (Search the web to find out how to use GCC 3 for the PPC build.)
Quite a few instructions here imply you have already found your way around the terminal. If you haven't, you may wish to search for a few tutorials to become more proficient.
Installing the development tools
Insert your Mac OS X installation CD into your DVD-ROM drive. In the window that opens, double-click on Xcode Tools and then on XcodeTools.mpkg. Continue through the installation wizard until you come to the Installation Type section. Here, click Customize. A successful constellation only requires Developer Tools Software, gcc 4.0, the Software Development Ki ts and the Mac OS X 10.4 (Universal) SDK (from under Cross Development). Keep on clicking yourself through the wizard until said tools are installed.
Building the libraries
You will need the following libraries to run SuperTux:
Most of the time, the triplet
./configure && make && sudo make install (supplying your own password when asked for it) is enough.
If you intend to build distributable app bundles, pass --enable-jpg-shared=false --enable-png-shared=false flags to configure when compiling SDL_image.
( Note: RavuAlHemio, the original author of this document instructed to install libraries in /usr. I (Auria) personally prefer leaving the install default to /usr/local, because this way i can easily tell at any time what libs came with OS X and what libs i installed myself. That's valuable knowledge when you need to decide which libs you will package inside the app bundle ;) Nonetheless, if you would like to install in /usr instead, run
./configure --prefix=/usr && make && sudo make install. If you install in /usr/local, also don't forget to add /usr/local/bin to your PATH)
Since SuperTux uses jam as its building tool, you'll need to download and compile that too. (Apple bundles it with the development tools, but their version is somehow defective, so you're better off getting a clean distribution from Perforce.)
First, download the archive (either in zip or uncompressed tar format) from the Perforce FTP server. Then, extract the files into a directory of your choice, enter it via the Terminal and run
make. When everything is done, copy the resulting jam binary from build.x86 or build.ppc to /usr/bin (e.g.
sudo cp build.x86/jam /usr/bin/) and you're all set.
Getting Subversion and downloading SuperTux
To download the development version of SuperTux, you'll need Subversion. You can either download precompiled disk images or compile the source yourself using the triplet introduced above. Once this is done, follow the directions in the article Download/Subversion.
In the Terminal, switch to the directory you have checked out SuperTux into. Then, run the following command to generate the configure script:
If you don't get any answer and find yourself back at the command prompt, everything should have gone well. Next, you will have to do a nice hack: link the header files for OpenGL and OpenAL so that SuperTux can find them. This hack is awesomely stupid. Just issue the following commands:
ln -s /System/Library/Frameworks/OpenAL.framework/Headers/ AL ln -s /System/Library/Frameworks/OpenGL.framework/Headers/ GL
At long last, you can run configure. Here there are two ways.
- If you just want to run supertux on your computer the Unix way, run:
./configure --with-apple-opengl-framework CPPFLAGS="-I."
- If you want to make an app bundle, rather run:
./configure --with-apple-opengl-framework CPPFLAGS="-I. -DMACOSX"
Now, at long last, you can run the command that will compile everything.
This will take forever, so grab a coffee or other beverage, play a game of chess, whatever.
When the build process is completed and you are feeling lucky, the following command will start SuperTux and make your life complete:
This should have done the trick. If something is too unclear or you think I haven't added enough detail, please alert me on this article's talk page and I will do my best to improve this document.
Building an app bundle
Okay, launching from the terminal works, but you'd like an app bundle like all OS X native apps. The instructions below will make it happen.
- create a folder named e.g. "supertux_bundle" and cd into it.
- copy the 'supertux' executable you just built into this folder.
- copy the 'data' folder there too (if you built supertux from SVN be careful as the one you see is filled with SVN invisible files)
- pick a file you think makes a nice icon (e.g. /data/images/creatures/tux_grow/left-7.png), resize it to at least 128x128 in your favorite graphics editor, and turn it into a .icns file with an app like CocoThumbX. Rename it to "supertux.icns" and place it in the same folder.
- In this folder, place a file called "info.plist" with the following contents:
<?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>CFBundleExecutable</key> <string>supertux</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>Supertux</string> <key>CFBundleIconFile</key> <string>supertux.icns</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleVersion</key> <string>0.3.0</string> <key>CSResourcesFileMapped</key> <true/> </dict> </plist>
(When you copy and paste from your web browser, make sure the line endings are okay. Sometimes web browsers gives non-Unix line endings if you copy from them. Text editor Smultron has a feature to fix them and probably others too.)
- create the skeleton with a script like this one:
mkdir -p ./SuperTux.app/Contents/Resources mkdir ./SuperTux.app/Contents/MacOS cp info.plist ./SuperTux.app/Contents/info.plist cp supertux.icns ./SuperTux.app/Contents/Resources/supertux.icns cp supertux ./SuperTux.app/Contents/MacOS/supertux cp -r ./data ./SuperTux.app/Contents/Resources/data
- The app bundle will be ready and if all went correctly you should now be able to run SuperTux with a double-click from the Finder! It will not have an icon right now but that will eventually appear. However, this bundle cannot yet be distributed as it depends on libraries not included inside the bundle.
Making the app bundle distributable
These instructions should result in a package that you can compress as dmg and put as download on a website.
- Download mac dylib bundler from http://macdylibbundler.sf.net version 0.3 or better and build it with make && sudo make install
- run the following command on the terminal:
dylibbundler -b -x ./SuperTux.app/Contents/MacOS/supertux -d ./SuperTux.app/Contents/libs/ -od
- On my computer, libphysfs was linked in a weird way i had never seen before so there were a few problems.
This will only work if you installed libs in /usr/local or another prefix (e.g. /opt/local for macports). If you put them in /usr they are undistinguishable from libraries installed by default on OS X so it's harder to package them, and dylibbundler won't be able to do it automatically.
Done! Want to test to see if everything is linked properly? sudo mv /usr/local /usr/local-disabled (or any other suffix) will temporarly restore your mac in a near vanilla state for libraries. Then you can test the game, and of course run the opposite command after to put the folder back in its correct location. You can also test the resulting executable and libraries with otool -L