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.

Contents

Preparation: SDL

Download the following:

* SDL
* SDL_mixer
* SDL_ttf

From each of those dmg installers, copy the ".framework" folder to /Library/Frameworks/


Quickstart for fink users

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.

fink install svn-ssl svn-client sdl sdl-ttf gettext libjpeg libpng3
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 lang
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
cd base
sh archives.sh
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.


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


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'

If this succeeds, start the build process

make

after that, you need to create the languages and maps

make lang
make 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:

Maps on Sourceforge

...and pack them into pk3

cd base
sh archives.sh

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 or ppc.

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'. (Though this seems to be not working good right now r12836)


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 '-arch i386 -arch ppc' to both LDFLAGS and CFLAGS when running configure:

./configure CFLAGS='-arch i386 -arch ppc' LDFLAGS='-arch i386 -arch ppc'

You need to remove the '-MD -MT $@ -MP' options from the compile rules in build/client.mk, build/game.mk, build/server.mk and build/tools.mk. This will have no effect on the resulting executable (other than being able to create universal binaries...) Once this is done, you can run make, make lang, make maps as usual.

project-navigation