Compile for Mac

Revision as of 19:33, 21 January 2012 by Dlp (talk | contribs) (Universal (i.e., PPC + Intel) binaries)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Non-universal (i.e., Intel-only) binaries

Step 1. Install MacPorts

Instructions are at This will have you install Apple's X11 (not sure why it is needed), the Xcode development environment (needed for the compiler, etc), and the MacPorts program.

Step 2: Install SDL

sudo port configure libsdl +universal
sudo port install libsdl-framework
sudo port install libsdl_mixer-framework libsdl_ttf-framework libsdl_image-framework

Step 3: Install other libraries and tools

sudo port install libtheora XviD git-core p7zip python26

Now you should be able to fetch UFO-AI and compile it.

Universal (i.e., PPC + Intel) binaries

Install the libraries gettext, openssl, libpng and libjpeg from MacPorts 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.

Step 1: Install Xcode, X11, and MacPorts. 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 PPCs, and ncursesw is broken for universal compilation. Until these are fixed, fetch gtk+2 frameworks from 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).

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.

./configure --enable-universal
make uforadiant
make macinstaller

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.

First, run the configure script.


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

Before compiling for the first time

UFO:AI compilation requires some paths that are not taken care of for you by the MacPorts installation process. Therefore, a minor edit to your .profile is needed.

If you don't understand the preceding sentences: (a) Download TextWrangler (freeware) from ; (b) Use its File > Open to navigate to your home folder and enable its "Show hidden files" option; and (c) Open the ".profile" file you should see now so you can edit it.

Toward the bottom, substitute this export command:

export PATH=$PATH:/opt/local/bin:opt/local/sbin:opt/local

Save the file, quit Terminal, then relaunch Terminal to make the new PATH operative.

Now, the following "make" commands should execute without errors. You should also be able to compile newer versions of UFO:AI without editing .profile again, i.e., this is a one-time fix.


To compile the binaries, just type (after the configure call was successful).


after that, you need to create the languages and maps

make lang models maps-sync

To create the application bundle (i.e., a .dmg), just type

make macinstaller