How to build FlightGear cvs in a unix way

This document illustrates how to build fgfs in a unix way for intel Macs with cvs-head on Mac OS 10.5.x with Xcode 3.0 or later. This doesn't generate GUI launcher at this moment. So if you expect the way to build FlightGear.app, see How to build FlightGear cvs on Mac OS X.

Requirements

System Requirements

  • Mac OS 10.5.x (Leopard) or higher
  • Xcode 3.0 or higher (3.1.x is recommended as of June 19, 2009)

Required Skills

We assume you have some basic knowledge about using:

  • terminal (/Applications/Utilities/Terminal.app) - must
  • Xcode (inlcuding gcc etc)
  • Unix commands

If you are not familiar with the tools above, we highly recommend you consult some web articles and/or books about these before you get started. Please DO NOT ask project members about the use of these tools.

Easy steps to build (for the first time)

  1. download Xcode project files and patches. you can get it by one of the following ways:
    • tar ball.
    • svn
      svn co https://macflightgear.svn.sourceforge.net/svnroot/macflightgear/trunk trunk
  2. In trunk folder, type the following commands
  3. sh ./localbuild.sh
    • This script will automatically do the following things:
      • download all source packages
      • apply Mac OS specific patches
      • build everything in the proper order
      • install everything you need under /usr/local/... and /Library/Frameworks

When everything is done. You'll have fgfs, fgjs, terrasync and all binaries at /usr/local/FlightGear/bin. The base package (data) will be symlink'ed to /usr/local/FlightGear/data

Note: it will take 30-50 minutes to build everything. It also requires your password for installation and patches for libraries.

Test Flight

You can run fgfs with the following command (of course on Terminal.app)

$ FG_ROOT=/usr/local/FlightGear/data \ 
  DYLD_LIBRARY_PATH=/usr/local/OpenSceneGraph/lib \ 
  /usr/local/FlightGear/bin/fgfs <any options you like>

It is a bit long command, so you may want to make an alias command in ~/.profile or ~/.bashrc

alias fgrun='FG_ROOT=/usr/local/FlightGear/data \
 DYLD_LIBRARY_PATH=/usr/local/OpenSceneGraph/lib \
 /usr/localFlightGear/bin/fgfs'

Note

If you encounter some warning / error message regarding to missing Frameworks, then install all Frameworks to /usr/local/FlightGear/Frameworks (or make symlinks to ".frameworks under that folder).

For second build (or more)

Run localbuild.sh with the following option

$ sh ./localbuild.sh --skip=patch

Options for localbuild.sh

--skip: skipping a certain process (--skip)

Giving --skip= option can save your time especially for continuous build in debugging. Available elements are:

  • download
  • patch
  • plib
  • osg
  • simgear
  • fg
  • libs (libraries for terrasync)

--with-plib-framework / --with-osg-framework: for specifying framework paths

If you don't want to (or have to) build PLIB or OSG Frameworks yourself, you can specify existing frameworks. In such case, you can specify --with-plib-framework=<path for PLIB.framework> and --with-osg-framework=<path for OSG frameworks>. These options automatically specifies These frameworks are available from either the latest FlightGear/CVS package and the OSG Web site.

--prefix : for specifying where to install everything

By default, localbuild.sh will install everything to /usr/local. If you want to change the destination folder, specify this option (e.g. --prefix=$PWD/build).

--arch (specifying either i386 or ppc)

This option allows you to build FlightGear for a given architecture. i386 or ppc is available at this moment.

--debug/-d: for debugging

Giving "-d" or "--debug" option to localbuild.sh will automatically build a debug version of everything (except libraries for terrasync). Here is an example use of debug option:

$ sh ./localclean.sh
$ sh ./localbuild.sh --skip=download,patch -d

Don't forget to run localclean.sh before running localbuild.sh. Otherwise you'll get a release version or mixed one.

example use of skip option

  • skips patching and osg build
    $ sh ./localbuild.sh --skip=patch,osg 
  • skips downloading, patching, and building libraries for terrasync. This is usual updating process for me.
    $ sh ./localbuild.sh --skip=download,patch,libs
  • build only flightgear
    $ sh ./localbuild.sh --skip=download,patch,plib,osg,simgear

Note: Do not add white space before or after commas

Building a debug version

It's very easy.

When something goes wrong

There are so many causes that may loess you to encounter build errors. So It is good to make a build log to see what's wrong. Here is an example of capturing entire build log to log.txt:

$ sh ./localbuild.sh > log.txt 2>&1

you can easily find a bad portion by running grep error log.txt When weird error occurs, then you can do:

  • update parches and apply these
    • svn update at trunk folder
  • redo download and patch
  • run localclean.sh and localbuild.sh
  • revert your localbuild.sh if you think you made any changes
    • svn revert localbuild.sh
  • ask me or someone via fg-devel list
  • revert local changes, and then apply the patches again