Build-MacOSX
From Freeciv
Contents |
[edit] Introduction
This page covers building freeciv from source on Mac OS X. The contents are taken, in part, from here.
This page assumes familiarity with development tools like make [gcc.gnu.org/ gcc] and subversion.
The good news is that Freeciv compiles on Mac OS X without any source code modification.
This was written with:
- Freeciv
- 2.1.3
- Mac OS X
- 10.4.11
(please add on if these instructions have worked)
[edit] Possible Clients
Freeciv supports several clients on Mac OS X:
- GTK+1 (deprecated)
- GTK+2 (recommended)
- GTK2 +x11 (ported from linux)
- GTK2 +quartz (under development)
- SDL
- xaw (does not require supporting libraries -- ie. port or fink)
the x11 / quartz choice is purely a Mac issue, and does not seem to be covered elsewhere. --User:Teyrana
[edit] Before You Start
There are several tools that are useful in this process, and will make our job *much* easier. These are:
- subversion revision control system. Similiar to cvs.
- MacPorts package system for many open source packages
- Fink Package system. Similiar to MacPorts, but not as up to date.
Although the source code does not need modification, it takes a good bit of work to lay the foundation so that you can compile Freeciv on top of it. Thankfully heavy lifting can be done for you by a package manager like port or fink, mentioned above.
As of this writing, fink is not as up-to-date as macports. Therefore, I recomend using 'port' as your package manager. -- User:Teyrana
[edit] Prepare Mac OS X
[edit] Installing MacPorts
- Head over to MacPorts, follow the installation instructions to install MacPorts.
- The default install paths for macports is /opt/local/*. Because these aren't always included in the default paths, you may need to add them to the normal compiler search paths:
% export CC="gcc -I/opt/local/include/ -L/opt/local/lib/"
- You will notice this problem if libraries fail to link while compiling.
[edit] Installing Fink
Instructions to install Fink can be found here. It's recomended that you use the included FinkCommander. You will want to install the following packages:
(installing the shlib and dev packages is recomended)
[edit] GTK +X11
- Install X11 and X11 SDK components. Both are available on your Mac OS X CD. However, X11 itself is also available as a download (Panther compatable download here) from Apple.
- Install Xcode 1.2, 1.5 (For Panther), 2.0 (For Tiger) or 3.0 (For Leopard)
- GTK+ 2.0 client - If done by a package manager, the supporting packages will be installed automatically.
- gettext
- glib2
- pango
- atk
- gtk2
[edit] GTK +quartz
(Does not yet work. )
- Install Xcode 1.2, 1.5 (For Panther), 2.0 (For Tiger) or 3.0 (For Leopard)
- GTK+ 2.0 client - If done by a package manager, the supporting packages will be installed automatically.
- gettext
- glib2
- pango
- atk
- gtk2
[edit] SDL
The SDL client has improved a lot in the 2.1-beta3 release. It requires some hacks to compile, but it is definitely worth the sweat as it provides a quite different experience than the other clients. The instructions below are for OS X 10.3.9 on an iBook G3, and might or might not work on other setups. --Hima 08:41, 19 February 2007 (UTC)
The required packages are:
- Caveat 1: MacPorts did not install all necessary headers for me, so I had to install the important packages manually. Download the source tarballs from the links above.
- Caveat 2: I had to compile SDL_image with the following variables to make it work:
./configure --disable-tif --disable-tif-shared --disable-jpg --disable-jpg-shared
- Caveat 3: To get SDL to work, I had to add the option "-Dmain=SDL_main" to the "--cflags)" part in the /usr/local/bin/sdl-config script
Build and install in above order, then compile the Freeciv tarball with "--enable-client=sdl".
If you get stuck, you might get some help from an installation guide for another SDL-based game at [1]
[edit] SDL Client with MacPorts
I've been able to build the SDL client using the libs provided by MacPorts. Changing the "--cflags)" section of /opt/local/bin/sdl-config to
-I${prefix}/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE \
-I${prefix}/include/ -Dmain=SDL_main
[edit] Configure and Setup
[edit] (1) Get Source
- Option A: get source tarball from here and extract it.
- Option B: get a fresh source tree: Svn
- Note where you put this. This directory is the prefix directory. We'll refer to it later.
At this point, it's a good idea to read the INSTALL file located in the top-level directory of the archive. It contains information on dependencies and other useful information.
[edit] (2) autogen.sh
This step applies only if you're building from a development version of the source (subversion).
- Note: This will also run configure. If you know what you're doing, you can pass the 'configure' arguements directly to autogen.sh, and you may then skip step (3) below.
[edit] (3) configure
- Set up your environment:
% env CC="gcc -no-cpp-precomp" CFLAGS="-O3"
- To build the GTK+2 client, execute this configure command from the command line, at the top-level directory of the source archive:
% ./configure \
--enable-client=gtk2 \
--prefix=/Users/your_user_name/freeciv-2.0.4
unter Leopard zusätzlich:
--with-readline=builtin --with-libiconv-prefix=${prefix}/include
- As of version 2.1.13 there is a bug which requires building without readline:
% --without-readline
[edit] Compile
[edit] (4) Run Make
- Compile the source by executing this command:
% make
[edit] (4b) Troubleshooting
[edit] Potential Errors During Compiling
Compiling Freeciv using the before specified commands may yield the following error:
stdinhand.c: In function 'freeciv_completion': stdinhand.c:4509: error: 'rl_attempted_completion_over' undeclared (first use in this function) stdinhand.c:4509: error: (Each undeclared identifier is reported only once stdinhand.c:4509: error: for each function it appears in.) make[3]: *** [stdinhand.o] Error 1 make[2]: *** [all-recursive] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2
A workaround for this problem was mentioned at the Freeciv-Dev Mailing list:
You can probably work around it by running ./configure --without-readline. However it would be nice to fix it if you'll help us track down the problem.
This applies to users of Mac OS X 10.4 (Tiger).
[edit] Install
[edit] (5) Test
If you've gotten this far, test your shiny new program. This command will run the client.
% ./civ
[edit] (6) Install and Enjoy
Assuming everything works properly, execute this command to install it in directory you specified as the prefix:prefix:
% make install
- Now, you should be able to find three executables in the /prefix/bin directory:
civclient civserver civmanual
You might have success in launching the client by simply double-clicking on the civclient executable from within the Finder.
- Enjoy!
[edit] Optional Support
[edit] Sound Support
You need to install the following for SDL sound support:
- libsdl
- libsdl_mixer
You'll also need to download a soundset. You can find information about sounds and sound sets here.
When running Freeciv's configure script, be sure to use the following option:
--with-sdl-prefix=/opt/local
Furthermore, you need to define your CC environment variable to be the following:
gcc= " -no-cpp-precomp -I/opt/local/include -L/opt/local/lib"
After you have built the binaries, copy the .soundspec file, and the accompanying folder containing the actual sound files from the sound set archive into your path_to_freeciv/share/freeciv directory.
[edit] Localization Support
You need to have a functioning installation of the gettext package to be able to run Freeciv with a language other than English.
When running Freeciv's configure script, be sure to use the following option:
--enable-nls
Furthermore, you need to define your CC environment variable to be the following (to where MacPorts install packages):
gcc = "-no-cpp-precomp -I/opt/local/include -L/opt/local/lib"
You may start either the server or client or both in the locale of your choice by giving a full LANG prefix when executing them. E.G. the civclient in Swedish locale:
LANG="sv_SE.UTF-8 civclient"
Note that by giving a full locale string as the example above, you avoid potential encoding conversion warnings and glitches.
