Difference between revisions of "Compile for Mac"

From UFO:AI
(Step 2: Install SDL)
Line 1: Line 1:
==Non-universal (i.e., Intel-only) binaries==
+
==Step 1. Installation==
  
===Step 1. Install MacPorts===
+
Install Xcode, X11, and MacPorts
  
 
Instructions are at {{http|guide.macports.org/#installing}}
 
Instructions are at {{http|guide.macports.org/#installing}}
 
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.
 
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.
  
====Add headerpad_max_install_names LDFLAGS to MacPorts====
+
===Add headerpad_max_install_names LDFLAGS to MacPorts===
 
Modify /opt/local/share/macports/Tcl/port1.0/portconfigure.tcl configure.ldflags to  
 
Modify /opt/local/share/macports/Tcl/port1.0/portconfigure.tcl configure.ldflags to  
 
  default configure.ldflags {"-L${prefix}/lib -Wl,-headerpad_max_install_names"}
 
  default configure.ldflags {"-L${prefix}/lib -Wl,-headerpad_max_install_names"}
Line 12: Line 12:
 
This change is only needed if you would like to create dmgs.
 
This change is only needed if you would like to create dmgs.
  
===Step 2: Install SDL===
+
==Step 2: Install dependencies==
  
 
  sudo port configure libsdl +universal
 
  sudo port configure libsdl +universal
 
  sudo port install libsdl-framework
 
  sudo port install libsdl-framework
 
  sudo port install libsdl_mixer-framework libsdl_ttf-framework
 
  sudo port install libsdl_mixer-framework libsdl_ttf-framework
 
+
sudo port install jpeg libpng XviD libtheora gtkglext
===Step 3: Install other libraries and tools===
 
 
  sudo port install libtheora XviD git-core p7zip python26
 
  sudo port install libtheora XviD git-core p7zip python26
  
 
Now you should be able to [[Getting the source|fetch UFO-AI]] and compile it.
 
Now you should be able to [[Getting the source|fetch UFO-AI]] and compile it.
  
==Universal (i.e., PPC + Intel) binaries==
+
==Step 3: Compilation==
 
 
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: {{http|www.mail-archive.com/macports-users@lists.macosforge.org/msg05922.html}}
 
 
 
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 {{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).
 
 
 
<pre>
 
#!/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.
 
 
 
./configure --enable-universal
 
make
 
make uforadiant
 
make macinstaller
 
</pre>
 
 
 
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.
 
./configure
 
 
 
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.
 
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.
  
Line 102: Line 35:
 
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.
 
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.
  
== Compilation ==
 
 
To compile the binaries, just type (after the configure call was successful).
 
To compile the binaries, just type (after the configure call was successful).
 
  make
 
  make

Revision as of 22:02, 14 May 2012

Step 1. Installation

Install Xcode, X11, and MacPorts

Instructions are at http://guide.macports.org/#installing 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.

Add headerpad_max_install_names LDFLAGS to MacPorts

Modify /opt/local/share/macports/Tcl/port1.0/portconfigure.tcl configure.ldflags to

default configure.ldflags {"-L${prefix}/lib -Wl,-headerpad_max_install_names"}

This change is only needed if you would like to create dmgs.

Step 2: Install dependencies

sudo port configure libsdl +universal
sudo port install libsdl-framework
sudo port install libsdl_mixer-framework libsdl_ttf-framework
sudo port install jpeg libpng XviD libtheora gtkglext
sudo port install libtheora XviD git-core p7zip python26

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

Step 3: Compilation

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 http://www.barebones.com/products/textwrangler/download.html ; (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).

make

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