Difference between revisions of "Build for MacOSX"

From X-Moto
Jump to: navigation, search
(add link to my packaging setup)
m
Line 11: Line 11:
 
FLAGS
 
FLAGS
 
  export CPPFLAGS="-I/opt/local/include -I/usr/X11R6/include"
 
  export CPPFLAGS="-I/opt/local/include -I/usr/X11R6/include"
  export LDFLAGS="-framework OpenGL -framework Cocoa -L/opt/local/lib -lstdc++ -lSDLmain -lSDL -lSDL_mixer"
+
  export LDFLAGS="-framework OpenGL -framework Cocoa -L/opt/local/lib -lstdc   -lSDLmain -lSDL -lSDL_mixer"
 
   
 
   
 
Compile
 
Compile
Line 44: Line 44:
 
  cd ode-0.8
 
  cd ode-0.8
 
  ./configure prefix=/tmp/libs
 
  ./configure prefix=/tmp/libs
  make && make install
+
  make
 
 
== Anatomy of a Mac OSX Application ==
 
X-Moto.app
 
Contents
 
Frameworks - it will store libraries needed to run
 
MacOS - it will store the binary
 
Resources - it will store the data needed to run xmoto
 
appIcon.icns - application icon
 
Info.plist
 
 
 
When we perform a double-click, we are calling the binary from the directory, so our data will be on X-Moto.app/Contents/Resources
 
 
 
== Building ==
 
This is a single line command, but aligned for better readability
 
./configure
 
CPPFLAGS="-I/sw/include -I/tmp/libs/include"
 
LDFLAGS="-L/sw/lib -L/tmp/libs/lib"
 
--with-gamedatadir=X-Moto.app/Contents/Resources
 
--with-apple-opengl-framework
 
--with-enable-www=1
 
--disable-nls
 
 
 
= Compiling the cvs version using fink =
 
This section applies to Mac OS X 10.4.8 on an iBook G4. You should know the basic commands of the shell (Terminal.app).
 
 
 
== Prerequisites ==
 
The dependencies are as usual, so look in [[Build_from_CVS#Dependencies|"Build from cvs"]] for what packages you need to install first. Of course, you don't need to install g++ from fink, neither OpenGL (as Apple provides an OpenGL framework).
 
 
 
To find all the packages in fink, you will probably need to enable the unstable tree; see the [http://fink.sourceforge.net/faq/usage-fink.php Fink FAQ] on how to do this (or give [http://finkcommander.sourceforge.net/ FinkCommander] a try, where it is only a mouse click). You should install the packages named "libgettext3-dev", "libgettext3-shlibs" and "gettext" as well (maybe some combination of these solves the src/Makefile-problem mentioned below, I'll have to check that).
 
 
 
== Getting the cvs version ==
 
Next, get the cvs version of X-Moto. If that's your first access to that version, you need to do a full checkout:
 
cvs -d:pserver:anonymous@xmoto.cvs.sourceforge.net:/cvsroot/xmoto login
 
cvs -z3 -d:pserver:anonymous@xmoto.cvs.sourceforge.net:/cvsroot/xmoto co -P xmoto
 
If you're asked for a password, simply hit return.
 
 
 
If you already have got an older cvs version of X-Moto lying on your hard disc, you can simply go into the directory and type
 
cvs update
 
 
 
== Configure ==
 
cd into the directory "xmoto" and configure it:
 
sh ./bootstrap
 
./configure --prefix=/Users/foo/bar --with-apple-opengl-framework --with-enable-www=1 --with-enable-zoom=1 CPPFLAGS="-I/sw/include" LDFLAGS="-L/sw/lib"
 
where --prefix= is optional and can be omitted if you are sure you want to install xmoto into the root directory. I would suggest using a prefix such as /Users/your_username/xmoto/ in order to be able to remove the whole xmoto tree with one command and to not interfere with Mac OS X files and directories.
 
 
 
The next step is needed on my iBook G4 running Mac OS X 10.4, but maybe it works for you without it. If it does, please append the output of "fink list -i gettext" and "uname -p" to this section.
 
 
 
== Hack a Makefile to work around a gettext-related bug ==
 
Apparently there is a problem that the configure-script doesn't quite recognize how to link correctly with libgettext, although it claims it does. So, what you have to do is: Open src/Makefile in your favorite text editor, find the line that says
 
LIBS = -lcurl -lode -llualib -llua -lSDL_mixer -lbz2 -lpng -ljpeg -lz
 
and append ${LIBINTL} so the updated line looks like
 
LIBS = -lcurl -lode -llualib -llua -lSDL_mixer -lbz2 -lpng -ljpeg -lz ${LIBINTL}
 
 
 
Save the file.
 
 
 
== Make and install ==
 
This step is the same as in the MacPorts/Compilation part:
 
make && make install
 
 
 
This should work flawlessly now. If you get a linker error ("ld error") saying something about "intl" oder "gettext", you probably skipped the src/Makefile editing step.
 
 
 
After this command has finished (it may take some time), you should have a working cvs-version of X-Moto installed and should be able to start it from the shell with <prefix>/bin/xmoto.
 
 
 
== Script model to build universal builds ==
 
 
 
#!/bin/bash
 
 
#
 
# Script that helps to build universal binary programs
 
#
 
 
# pass the directory where the source is
 
if [[ $# -eq 0 ]]; then echo "missing directory"; exit 1; else cd $1; fi
 
 
NCPU=`sysctl -n hw.ncpu`
 
BUILD_PATH="/tmp/build"
 
GENERIC_FLAGS="-Os -pipe -fomit-frame-pointer -ffast-math"
 
CONFIGURE_GENERIC="--prefix=${BUILD_PATH} --enable-cross-compile"
 
LDFLAGS_GENERIC=""
 
 
CONFIGURE_PPC="--build=`uname -p`-apple-darwin --host=powerpc-apple-darwin"
 
FLAGS_PPC="-mcpu=powerpc ${GENERIC_FLAGS}"
 
CC_PPC="gcc-4.0 -arch ppc"
 
CXX_PPC="g++-4.0 -arch ppc"
 
CPPFLAGS_PPC=""
 
LDFLAGS_PPC="${LDFLAGS_GENERIC} -isysroot /Developer/SDKs/MacOSX10.4u.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch ppc"
 
 
CONFIGURE_X86="--build=`uname -p`-apple-darwin --host=i386-apple-darwin"
 
FLAGS_X86="-march=pentium-m -mtune=pentium-m -mfpmath=sse ${GENERIC_FLAGS}"
 
CC_X86="gcc-4.0 -arch i386"
 
CXX_X86="g++-4.0 -arch i386"
 
CPPFLAGS_X86=""
 
LDFLAGS_X86="${LDFLAGS_GENERIC} -isysroot /Developer/SDKs/MacOSX10.4u.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386"
 
 
#### PPC BUILD ####
 
echo "./configure ppc"
 
ctest=`./configure $CONFIGURE_GENERIC $CONFIGURE_PPC CC="${CC_PPC}" CXX="${CXX_PPC}" CFLAGS="${FLAGS_PPC}" LDFLAGS="${LDFLAGS_PPC}" 1>/dev/null; echo $?`
 
if [[ $ctest -ne 0 ]]; then
 
echo "./configure failed"
 
exit 1
 
fi
 
 
echo "Compilation started"
 
ctest=`make -j$NCPU &>compilation.log; echo $?`
 
 
if [[ $ctest -ne 0 ]]; then
 
echo "An error happen, see compilation.log"
 
exit 1
 
fi
 
 
make install
 
mv -f ${BUILD_PATH} ${BUILD_PATH}.ppc
 
 
make clean
 
 
#### INTEL BUILD ####
 
echo "./configure x86"
 
ctest=`./configure $CONFIGURE_GENERIC $CONFIGURE_X86 CC="${CC_X86}" CXX="${CXX_X86}" CFLAGS="${FLAGS_X86}" LDFLAGS="${LDFLAGS_X86}" 1>/dev/null; echo $?`
 
if [[ $ctest -ne 0 ]]; then
 
echo "./configure failed"
 
exit 1
 
fi
 
 
echo "Compilation started"
 
ctest=`make -j$NCPU &>compilation.log; echo $?`
 
 
if [[ $ctest -ne 0 ]]; then
 
echo "An error happen, see compilation.log"
 
exit 1
 
fi
 
 
make install
 
mv -f ${BUILD_PATH} ${BUILD_PATH}.x86
 
 
 
= [[Vasi's Mac packaging]] =
 
 
 
The linked article has documentation on my build process for X-Moto, which deals properly with SDKs and such.
 

Revision as of 18:16, 14 April 2007

Català - Español

Using MacPorts (old DarwinPorts)

Install dependencies

Libpng

sudo port install -c libpng 

Libjpeg

sudo port install -c jpeg


FLAGS

export CPPFLAGS="-I/opt/local/include -I/usr/X11R6/include"
export LDFLAGS="-framework OpenGL -framework Cocoa -L/opt/local/lib -lstdc   -lSDLmain -lSDL -lSDL_mixer"

Compile

./configure [--prefix=/path_to_install for example: --prefix=/usr/local/xmoto
make

Install

make install

Test

cd /usr/local/xmoto/bin
./xmoto

Building XMoto using Fink

Install dependencies needed

sudo apt-get -y install bzip2
sudo apt-get -y install libjpeg
sudo apt-get -y install libpng3
sudo apt-get -y install sdl
sudo apt-get -y install sdl-mixer
sudo fink -y install lua

The stable version of Fink don't have a ode port, so we have to build it:

Download the source and extract:

curl http://mesh.dl.sourceforge.net/sourceforge/opende/ode-src-0.8.zip -O
unzip ode-src-0.8.zip

Let's build it (install on tmp so it doesn't change nothing on system)

cd ode-0.8
./configure prefix=/tmp/libs
make