Compiling on MacOSX

From Secret Maryo Chronicles Wiki
Jump to: navigation, search

This guide will walk you through the main steps involved in building and packaging SMC on mac OS X. It expects you have a basic knowledge about compiling and using the terminal. It will work for SMC versions 1.6 or greater.

Unfortunately, the current state of CEGUI does not allow you to run SMC without packaging it. I have however sent patches to the CEGUI author and there is good hope that by CEGUI 0.7 it will be possible.

Contents

Environment

  • Install your developer tools from the OS X install disk
  • Get pkg-config, either from macports or from their website.
  • If you got the source from SVN, you will want to install new autotools if you intend to build stuff from SVN or if you meet weird errors (those from macports will probably do). if you install them by hand, put /usr/local/bin before /usr/bin in your PATH so that the new versions of stuff are picked over the old ones as you compile, and symlink gm4 to m4. --> m4 autoconf automake.
  • 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

Dependencies

List of dependencies :

How to get them :

  • A first way to go is to install them through macports or fink. Not recommended because macports installs by default a SDL_mixer binary that loads ogg support dynamically at runtime from /opt/local. If you use macports, the resulting app will not have audio on computers where ogg support is not installed (i.e. if you use macports you'll produce a SMC that can't play music on any computer but yours)
    • Note : if you use macports, smpeg is required for libsdl_mixer; smpeg is unable to build with the GL symblink in /usr/local/include/
  • You can also install them from source, usually with the standard "./configure && make && sudo make install", except boost which uses its own build system (read its build instructions... unfortunately their build system tends to screw up seriously on mac, i needed to fix the libraries manually with install_name_tool in the end), AND except SDL_mixer and SDL_image that must be built this way to be 'bundle'able :
% cd /path/to/SDL_mixer-1.2.8
% ./configure --enable-music-ogg-shared=false
% make
% sudo make install
% cd /path/to/SDL_image-1.2.6
% ./configure --enable-jpg-shared=false --enable-png-shared=false
% make
% sudo make install

CEGUI

Download the mac binaries from the CEGUI website Install CEGUI.framework and CEGUIOpenGLRenderer.framework from [CEGUI download]/Frameworks/Deployment to [Hard Disk]/Library/Frameworks.

I used version 0.6.1, things might change in later versions though.

SMC

Get the source code of SMC, either the archive or from SVN.

Compile and install it with flags like this :

export CEGUI_CFLAGS="-I/Library/Frameworks/CEGUI.framework/Headers/ -I/Library/Frameworks/CEGUIOpenGLRenderer.framework/Headers/ -framework CEGUI -framework CEGUIOpenGLRenderer"
export CEGUI_LIBS="-bind_at_load -framework CEGUI -framework CEGUIOpenGLRenderer -F/Library/Frameworks/CEGUI.framework/Resources/ -weak_framework freetype2 -weak_framework PCRE"

cd /path/to/smc-src

# only if you got code from SVN
./autogen.sh

./configure --prefix=/opt/smc

NOTE: if configure fails on the SDL detection. Open configure.ac in a text editor and remove

-lboost_system

and rerun ./autogen.sh

make
sudo make install

Packaging it

  • Make an icon file for SMC and name it smc.icns
  • Make an Info.plist file for SMC with the usual contents in it
  • Bundle SMC with a sh script that looks like this :
INSTALL_PREFIX="/opt/smc"
CONTENTS="./SMC.app/Contents"

echo "* Removing any existing installation"
rm -rf ./SMC.app

echo "* Creating skeleton"
mkdir -p $CONTENTS/Resources
mkdir -p $CONTENTS/MacOS
cp Info.plist $CONTENTS/Info.plist
cp smc.icns $CONTENTS/Resources/smc.icns

echo "* Copying executable"
cp $INSTALL_PREFIX/bin/smc $CONTENTS/MacOS/smc
strip $CONTENTS/MacOS/smc

echo "* Copying data files"
cp -r $INSTALL_PREFIX/share/smc $CONTENTS/Resources/data

echo "* Cleaning up SVN files (IGNORE any error that may appear in this section)"
find $CONTENTS -name ".svn" -exec rm -rf '{}' \;
  • Once the script is done, copy CEGUI.framework and CEGUIOpenGLRenderer.framework into /SMC.app/Contents/Resources.
  • In CEGUI.framework/Resources, you can remove the following bundles to save space :
    • CEGUIXercesParser.bundle
    • CEGUICoronaImageCodec.bundle
    • CEGUIDevILImageCodec.bundle
    • CEGUITGAImageCodec.bundle
    • CEGUITinyXMLParser.bundle

Once the app bundle is ready, bundle the libs using dylibbundler by running either of the following, depending on your system (making a difference between PPC and intel like i do below is only useful if you intend to build universal binaries by merging two builds)

#on PPC
dylibbundler -b -x ./SMC.app/Contents/MacOS/smc -d ./SMC.app/Contents/libs-ppc -od -p @executable_path/../libs-ppc/

# on intel
dylibbundler -b -x ./SMC.app/Contents/MacOS/smc -d ./SMC.app/Contents/libs-intel -od -p @executable_path/../libs-intel/

Done =)

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox