# Ultimate Stunts on Mac OS X - install instructions

Notes:

1. This is how I did it, there are other ways (namely using frameworks and not Unix libs, or using macports or fink)
2. You should at least understand a bit what you are doing, I do not claim my instructions are perfect. They should get you started in the right direction however.

### Setting up your environment

- Install developer tools, either from the OS X Install DVD or from Apple's website
- Add /usr/local/bin to your PATH, before /usr/bin ( http://www.troubleshooters.com/linux/prepostpath.htm) so that the new versions of stuff you install are picked over the older ones installed by default
- pkg-config
  Download from http://pkgconfig.freedesktop.org/releases/. Build with:

          % cd /path/to/pkg-config-0.22
          % ./configure
          % make
          % sudo make install

- Autotools
  Only necessary if you get CVS version (I think)
  Install more recent autotools (the ones that come with OS X 10.4 are too old. Maybe 10.5 users don't need this.). For this make sure /usr/local/bin is in your PATH as described above otherwise it won't work (will pick old versions).

All the following programs can be built and installed with the following commands on the terminal:

        % cd /path/to/source_file
        % ./configure
        % make
        % sudo make install

- get M4 from http://ftp.gnu.org/gnu/m4/ and install it
- symlink m4 to gm4 since that's how some programs refer to it.

          % sudo ln -s /usr/local/bin/m4 /usr/local/bin/gm4

- Then, build and install autoconf and automake from GNU the same way as described above
  - http://www.gnu.org/software/autoconf/
  - http://www.gnu.org/software/automake/

### OpenAL

The OpenAL framework provided by Apple on OS X 10.4 is too old. Once again maybe 10.5 users will have a more recent one - but anyway Ultimate Stunts's build system was not patched for mac frameworks so building the library Unix style is easiest. This part is currently a little mess, and we're not even building with .ogg support (which means no music) so this will really need to be improved.

- Checkout OpenAL SVN (or probably source code of version 1.1 will do but I didn't test)

          % svn checkout http://www.openal.org/repos/openal/trunk openal
          % cd openal

- Build OpenAL:
  - open folder OpenAL-MacOSX, open XCode project
  - select target openal.dylib and build style "deployment"
  - build
  - find /OpenAL-MacOSX/build/Deployment/openal.dylib and copy it to /usr/local/lib, renaming it to libopenal.dylib

                    % sudo cp ./OpenAL-MacOSX/build/Deployment/openal.dylib /usr/local/lib/libopenal.dylib
                    % sudo install_name_tool -id /usr/local/lib/libopenal.dylib /usr/local/lib/libopenal.dylib

- copy headers in /OpenAL-MacOSXbuild/include/AL to /usr/local/include/AL

          % sudo cp -r ./include/AL/  /usr/local/include/AL

- create openal.pc in /usr/local/lib/pkgconfig

      prefix=/usr/local
      exec_prefix=${prefix}
      libdir=${exec_prefix}/lib
      includedir=${prefix}/include

      Name: OpenAL
      Description: OpenAL blah blah blah not an official .pc file
      Requires:
      Version: 1.1.0
      Libs: -L${libdir} -lopenal
      Cflags: -I${includedir}

- build alut:

          % cd /openal/alut
          % ./autogen.sh
          % ./configure
          % make
          % sudo make install

### Getting the dependencies

- Get libjpeg from http://people.imendio.com/richard/gtk-osx/files/jpeg-6b.tar.gz (as of writing this document my understanding is that the official version of libjpeg still can't build libraries for mac)

          % ./configure --enable-static --enable-shared
          % make
          % sudo make install

- Get libpng ( http://libpng.sourceforge.net/)

          % ./configure
          % make
          % sudo make install

- Get gettext (get gettext source from ftp://mirrors.kernel.org/gnu/gettext) source code

          % cd /path/to/gettext-0.16
          % ./configure
          % make
          % sudo make install

Install SDL from source with terminal, do not use the binaries they provide (support for the provided SDL binaries can be added in the future but for now building yourself from terminal is easier as it requires less patching of Ultimate Stunts's build system)

- Get SDL ( http://www.libsdl.org/download-1.2.php) source code

          % cd /path/to/SDL-1.2.13
          % ./configure --without-x --disable-x11-video
          % make
          % sudo make install

- Get SDL_image source code

          % cd /path/to/SDL_image-1.2.6
          % ./configure --enable-jpg-shared=false --enable-png-shared=false
          % make
          % sudo make install

- symlink include folder of OpenGL framework to /usr/local/include/GL (Unix programs have an easier time finding it this way)

          % sudo ln -s /System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/ /usr/local/include/GL

### Building ultimate Stunts

- get source code
- if you need to generate a configure script (like if you got it from CVS), do "autoconf"

        %./configure
        % make

### Running Ultimate Stunts

        % ./ultimatestunts/ustunts

enjoy =)