Difference between revisions of "Vasi's Mac packaging"

From X-Moto
Jump to: navigation, search
(Dependencies)
(i has a script!)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Hi, I'm Vasi. I'm one of the leaders of the [http://finkproject.org/ Fink project], so I know some things about porting to OS X. Here are my notes and instructions for building a X-Moto binary for Mac OS X.
+
Hi, I'm Vasi. I'm part of the core team of the [http://finkproject.org/ Fink project], so I know some things about porting to OS X. I finally wrote a script for building and packaging X-Moto on Mac OS X.
  
Eventually it might be nice to build a script out of this, but my last script became obsolete pretty quickly...
+
Just open a terminal and run these commands:
 
 
== SDKs ==
 
 
 
When you build binaries for OS X, by default they will only work with the current version of the OS. For example, if you compile on 10.4, your apps won't run on 10.3. The fix for this problem is to build against the SDKs available in /Developer/SDKs; see [http://developer.apple.com/documentation/DeveloperTools/Conceptual/cross_development/index.html Apple's documentation] for more information.
 
 
 
We should try to only distribute binaries that work on 10.3 and higher, both Intel and PPC.
 
 
 
== Building ==
 
 
 
=== Data ===
 
 
 
Get all the data you need to build xmoto. First, grab my build setup from SVN:
 
 
 
<pre>
 
svn co http://vasi.dyndns.org:3128/svn/xmoto/branches/manual xmoto
 
cd xmoto
 
export BASEDIR="`pwd`"
 
</pre>
 
 
 
Then download all the tarballs you'll need, listed in Downloads.txt. An easy way to do so is the following:
 
 
 
<pre>
 
cd $BASEDIR; mkdir download; cd download
 
xargs -n1 curl -L -O < ../Downloads.txt
 
</pre>
 
 
 
Extract each source file into $BASEDIR/src, using tar and unzip.
 
 
 
Finally, get the [http://www.libsdl.org/download-1.2.php SDL] and [http://www.libsdl.org/projects/SDL_mixer/ SDL_mixer] frameworks and put them in ~/Library/Frameworks/.
 
 
 
Now you're ready to build!
 
 
 
=== Targets ===
 
 
 
I have setup three targets for building X-Moto:
 
 
 
* i386: Builds for 10.4+ with GCC 4.0
 
* ppc: Builds for 10.3+ with GCC 4.0
 
* 10.2: Builds for PPC 10.2+, with GCC 3.3. This builds xmoto without optimizations, since GCC 3.3 causes breakage if optimization is on.
 
 
 
You can build an application bundle for just one target, or combine multiple targets into one app.
 
 
 
=== Target setup ===
 
 
 
First setup the environment (assuming $TARGET is the target you wish to build):
 
  
 
<pre>
 
<pre>
cd $BASEDIR
+
$ svn co http://vasi.dyndns.org:3128/svn/xmoto/trunk xmoto-build
. envsetup.sh $TARGET
+
$ cd xmoto-build
 +
$ ./build.sh
 +
# Wait 15 minutes on a fast Mac...
 
</pre>
 
</pre>
  
Then make a build dir:
+
When the build is done, a .app and a .dmg will be in the ''build'' directory. Please read the [http://vasi.dyndns.org:3128/trac/browser/xmoto/trunk/README.txt README] for more information.
 
 
<pre>
 
mkdir -p build/target
 
cd build/target
 
</pre>
 
 
 
=== Dependencies ===
 
 
 
Now you have to build the dependencies for this target:
 
* curl (10.2 only)
 
* devel-lite
 
* jpeg
 
* png
 
* lua
 
* ode
 
* gettext-runtime
 
* gettext-tools (native arch only)
 
* xmoto
 
 
 
The build commands are in Build.txt. For each dependency, create an empty build directory, and then cd into it (some require that you instead copy the source directory, as noted in Build.txt). Then just paste the build commands. All the deliverables will go into the $PREFIX directory ($BASEDIR/prefix/$TARGET).
 
 
 
Don't forget to follow any notes in Build.txt about patching particular dependencies!
 
 
 
==== SVN ====
 
 
 
When building from SVN, you need additional dependencies:
 
* automake (native arch only)
 
* autoconf (native arch only)
 
* sqlite3
 
 
 
You also must bootstrap the xmoto source before compiling, see xmoto-svn in Build.txt
 
 
 
=== Application bundle ===
 
 
 
Once you have one or more targets built, you can create an application bundle. Go into the build directory of a native target, and run the commands in Build.txt under dotapp-data and dotapp-code.
 
 
 
=== Combining targets ===
 
 
 
==== Universal ====
 
 
 
To add a target from a different arch to your app bundle, use lipo on each of the files in X-Moto.app/Contents/MacOS and X-Moto.app/Contents/MacOS/Libraries . For example:
 
 
 
<pre>
 
lipo -create -output X-Moto.app/Contents/Libraries/ode.dylib \
 
X-Moto.app/Contents/Libraries/ode.dylib $BASEDIR/prefix/i386/lib/ode.dylib
 
lipo -create -output X-Moto.app/Contents/Libraries/png.dylib \
 
X-Moto.app/Contents/Libraries/png.dylib $BASEDIR/prefix/i386/lib/png.dylib
 
...
 
lipo -create -output X-Moto.app/Contents/MacOS/ \
 
X-Moto.app/Contents/Libraries/ode.dylib $BASEDIR/prefix/i386/lib/ode.dylib
 
</pre>
 
 
 
==== SDLMainJaguar ====
 
 
 
It may also be useful to put both the 10.2+ and 10.3+ targets into the same bundle, so that users on 10.3+ can run the optimized code. I've created SDLMainJaguar.m for this. It detects the version of OS X at runtime. Depending on the version it continues with 10.2+ code, switches to 10.3+ code, or tells the user to upgrade.
 
 
 
To use it, compile SDLMainJaguar.m instead of SDLMain.m when building devel-lite for the 10.2 target. Then build a universal 10.2/i386 application normally. Finally, copy the xmoto executable from the ppc (10.3) target to X-Moto.app/Contents/MacOS/xmoto-10.3 and the associated libraries to X-Moto.app/Contents/Libraries/10.3/. Don't forget to adjust the install_names!
 

Latest revision as of 22:37, 25 December 2008

Hi, I'm Vasi. I'm part of the core team of the Fink project, so I know some things about porting to OS X. I finally wrote a script for building and packaging X-Moto on Mac OS X.

Just open a terminal and run these commands:

$ svn co http://vasi.dyndns.org:3128/svn/xmoto/trunk xmoto-build
$ cd xmoto-build
$ ./build.sh
# Wait 15 minutes on a fast Mac...

When the build is done, a .app and a .dmg will be in the build directory. Please read the README for more information.