Compile for Mac
From UFO:AI
This guide describes the compilation process on MacOS X and is based on the latest revision (r12836). Of course you need the MacOS X Developer tools [1] installed.
On a 1.42 G4, expect to use about 5 and a half hours, and 4 GB of space.
Contents |
Preparation: SDL
(This is not needed if you use the "Quickstart for Mac Ports" below)
Download the following:
* SDL * SDL_mixer * SDL_ttf * SDL_image
From each of those dmg installers, copy the ".framework" folder to /Library/Frameworks/
If you use MacPorts, you can choose to install SDL using ports:
* install libsdl * install libsdl_mixer * install libsdl_ttf * install libsdl_image
If SDL installed with MacPorts, the build-process will prefere this over a /Library/Frameworks installation
Quickstart for fink users
It might be possible that you have to call the following stuff to let fink update itself and download the latest versions.
fink selfupdate fink selfupdate-rsync fink index -f fink selfupdate
If you use fink, the following set of commands should do the trick and will allow you to skip the entire remainder of this page. If configure fails (for example in zlib or libjpeg), it could be a sign that building universal binaries doesn't work without some extra effort. If you are only compiling for yourself, try giving --disable-universal switch to configure.
fink install svn-ssl svn-client sdl sdl-ttf sdl-image gettext libjpeg libpng3 glib2-dev gtk+2-dev gtkglext1 gtksourceview2 pango1-dev pango1-xft2-dev atk1 libgettext3-dev mkdir -p ufoai/trunk cd ufoai/trunk svn co https://ufoai.svn.sourceforge.net/svnroot/ufoai/ufoai/trunk . ./configure CPPFLAGS="-I/sw/include/" LDFLAGS="-L/sw/lib" make make uforadiant make macinstaller
This will skip the map-compilation step, which doesn't generate multiplayer-compatible maps from a mac anyway, and instead download a precompiled map package. If you want to build the mac application with locally compiled maps (and you have a spare couple of days -- the map build is SLOW!), you can run:
make maps make pk3 cd src/ports/macosx/installer make bundle TARGET_CPU=<arch>
where arch is i386 or ppc.
In either case the resulting .app or .dmg file will be left in src/ports/macosx/installer.
Quickstart for Mac Port users, or people who have no development environment and want to set one up. Generates a universal app
Step 1: Install XCode, X11, Mac Ports. Requires downloading .dmg's and other mousing around. (As of Aug 29, 2009 libsdl will not install on Mac OS X 10.6 via macports)
Step 1.5: Gtk2 will not build universal out of macports currently. Glib2 is broken on PPC's, and ncursesw is broken for universal compilation. Until these are fixed, fetch gtk+2 frameworks from http://gtk-osx.org/. NB: This is not production quality code yet. Do not expect radiant to run.
Step 2: Run the following shell script: This will request your password (for a "sudo" command), and the first time it will ask you to verify an SSL certificate fingerprint (for the svn checkout).
On my 1.42 G4, that was about 2 hours into the run.
#!/bin/sh set -e # Abort on any error sudo port -d selfupdate sudo port -d upgrade outdated # gtkglext requires gtk2; gtk2 requires glib2. They do not need to be # explicitly mentioned. sudo port install libsdl_image +universal libsdl_ttf +universal libsdl_mixer +universal jpeg +universal libpng +universal XviD +universal libtheora +universal gtkglext +universal gtksourceview2 +universal # openal +universal # OpenAl is part of Mac os from 10.4 on. # I don't know how up-to-date it is, but the version in macports is both # out of date and does not support universal. mkdir -p ufoai/trunk cd ufoai/trunk svn co https://ufoai.svn.sourceforge.net/svnroot/ufoai/ufoai/trunk . ./configure --enable-universal --disable-signals make make uforadiant make lang # warning: Maps may need to be compiled locally. But if you want to play multiplayer, use the one from the repository. # make maps contrib/scripts/map-get upgrade # May prompt you to continue; say "Y"es make pk3 cd src/ports/macosx/installer/ make TARGET_CPU=universal
If you have already non-universal ports installed, you have to uninstall them first by typing e.g.:
sudo port -f uninstall glib2 sudo port clean glib2 sudo port -v install glib2 +universal
If you are having trouble getting things to compile, be aware that most of the issues come from installing autoconfig/automake as universal. This doesn't actually need to be universal unless you are a file server for multiple arch development environments.
To work around this (the problem is in "ncursesw"), use the following command:
sudo port install libiconv +universal expat +universal automake libsdl_ttf +universal libsdl_mixer +universal jpeg +universal libpng +universal XviD +universal libtheora +universal
Automake (needed for building X-based stuff) ultimately needs gettext; gettext uses libiconv and expat (both of which build universal), and ncursesw (which does not). Gettext cannot compile universal until this is fixed.
Note that this does not solve the gimp stuff -- gtkglext, gtksourceview, which use gtk2 and glib2 (broken on PPC in macports at this time) -- used by radiant.
From scratch, with a 1.5 Mbps connection, this takes about 75 minutes.
Without fink: Preparation
You need to install the following. You may choose to install directly from source, or use something like MacPorts.
The following headers will be needed for compilation, and are also available from MacPorts and fink. Note that while you can also get them from their respective home pages, the binaries aren't sufficient; you only get headers by installing these from source:
- libjpeg
- libpng3
See this guide for usage information of the port program.
Compilation
First, run the configure script. It automatically adds /opt/local to your prefix, since most people will have their additional libs installed there:
./configure
If you installed gettext, libjpeg, or libpng3 somewhere else (like /sw, as fink does by default), add this to your configure path (if you installed to /usr/local you do not need this, of course):
./configure LDFLAGS='-L/sw/lib' CFLAGS='-I/sw/include'
In latest svn version, UFORadiant is enabled by default. This might fail on a mac as it depends on various external libraries like pkg-config, gtk+ etc. To disable UFORadiant, simply
./configure --disable-uforadiant
If this succeeds, start the build process
make
after that, you need to create the languages and maps
make lang make maps (or use the contrib/scripts/map-get.py script to download the maps)
- note that compiling maps is not necessary unless you wish to have the very latest maps. It is also extremely slow on PPC machines [took me five days on a G4, during which time i did not use the computer elsewise]. Precompiled maps are obtained here:
WARNING: This link fetches 2.2 maps, which are not compatible with 2.3.
If you are building a version >= 2.3 - you can use the contrib/script/map-get python script to fetch the latest map builds out of a repository.
...and pack them into pk3
make pk3
Finally, you need to create an application bundle. For now,
cd src/ports/macosx/installer
and do
make bundle TARGET_CPU=<arch>
where arch is i386, ppc or universal.
This will create UFOAI.app in this directory, which can be simple started by double-clicking it.
Notes
You can have the last steps automated by choosing
make macinstaller
from the root directory, but this will also upload/download stuff and create an disk-image, which might be not desired in your case.
Also, please note that the final UFOAI.app will contain all necessary libraries. If you do not want or need this, you can simple stop after the 'make maps' part and launch ufo from Terminal with './ufo'.
Contact
Please direct any comments, questions etc regarding compiling for MacOS X to
zerm (at) users . sourceforge . net
Universal binaries
Install the libraries gettext, openssl, libpng and libjpeg from MacPorts (fink does not currently support universal binaries) using the +universal variant (this is currently broken for libjpeg so you have to follow the manual steps described here):
port install pkgname +universal
Add --enable-universal when running configure:
./configure --enable-universal
Please note that it does not seem possible to build Radiant as a universal package at this time.

