BuildingMacOSX

From Mumble Wiki
Revision as of 16:33, 27 April 2008 by MKrautz (talk | contribs) (Change identification for MySQL dylibs)
Jump to: navigation, search

Introduction

This guide describes the method to get a fully working and redistributable version of Mumble and Murmur that works across both Tiger (10.4) and Leopard (10.5) both on Intel and PowerPC Macs. These are the steps used to build the official Mumble releases on Mac OS X.

This means that the instructions are a little more complicated than they would be if you were just building for, say, Leopard x86. What it boils down to is this:

* We build all libraries as Universal Binaries for both i386 and ppc.
* We build against the 10.4 (Tiger) SDK, even on Leopard, to make sure our binaries run on Tiger, as well as Leopard.

If you are just interested in building an optimized binary for your exact architecture and operating system, many of the instructions below can be greatly simplified:

* Do not pass custom CFLAGS or LDFLAGS to the configure scripts of the various dependencies.
* Do not set the MAC_OSX_DEPLOYMENT_TARGET.
* Do not pass the '-sdk' or '-universal' parameters to Qt's configure script.

Also, by default Mumble expects its build environment on Mac OS X to be universal. If you're not building universal binaries, pass CONFIG+='no-universal' to qmake when building Mumble.

Dependencies

To build Mumble you will need:

Installing or building pkg-config

This is just a build tool, so you do not have to build it as universal binary.

If you have MacPorts installed, you probably already have pkg-config as well. If not, you can install it by doing

sudo port install pkgconfig

In case you want to compile it yourself, you'll have to download and unpack pkg-config.

sudo mkdir /usr/lib/pkgconfig (choose a path you like)
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
./configure && make && sudo make install 

To make the path permanent add the following line to your ~/.profile file:

export PKG_CONFIG_PATH=/usr/lib/pkgconfig

Also add a path entry to the pkg-config binary to this file:

export PATH=$PATH:/usr/local/bin

Building Expat

DBus depends on an XML parser, and fails to build with the libxml library included with Mac OS X, so we use Expat instead.

Grab version 2.0.1 from SourceForge: http://sourceforge.net/project/showfiles.php?group_id=10127 and unpack it.

To build it:

export MACOSX_DEPLOYMENT_TARGET="10.4"
export OSX_SDK="/Developer/SDKs/MacOSX10.4u.sdk"
export OSX_CFLAGS="-isysroot $OSX_SDK -arch ppc -arch i386"
export OSX_LDFLAGS="-Wl,-syslibroot,$OSX_SDK -arch ppc -arch i386"
CFLAGS="$OSX_CFLAGS" LDFLAGS="$OSX_LDFLAGS" ./configure --prefix=/opt/mumble/expat/
make
sudo make install

Building DBus

Grab the latest release of DBus from http://dbus.freedesktop.org/. As of this writing that is version 1.2.1.

Unpack it, and build it:

export MACOSX_DEPLOYMENT_TARGET="10.4"
export OSX_SDK="/Developer/SDKs/MacOSX10.4u.sdk"
export OSX_CFLAGS="-isysroot $OSX_SDK -arch ppc -arch i386"
export OSX_LDFLAGS="-Wl,-syslibroot,$OSX_SDK -arch ppc -arch i386"
CFLAGS="$OSX_CFLAGS -I/opt/mumble/expat/include/" LDFLAGS="$OSX_LDFLAGS -L/opt/mumble/expat/lib/" ./configure --prefix=/opt/mumble/dbus/ --without-x --with-xml=expat
make
sudo make install

After building and install DBus, you should make sure the /opt/mumble/dbus/lib/pkgconfig/ directory is in your PKG_CONFIG_PATH, so Qt is able to pick it up.

Installing MySQL

We want users to be able to use a MySQL database with their Murmur installation, but we also want to make sure they can do that without too much hassle. Therefore we link against MySQL's official 10.4 universal binaries, so people can just use the official MySQL packages to get their database set up.

Grab the latest Universal .tar.gz package for 10.4 from MySQL's website: http://dev.mysql.com/downloads/mysql/5.0.html#macosx

To install it:

cd /opt/mumble/
sudo tar -zxf path/to/mysql-5.0.51a-osx10.4-universal.tar.gz
sudo ln -sf mysql-5.0.51a-osx10.4-universal mysql
cd mysql/lib/
d=`pwd`; for i in `ls *.dylib`; do install_name_tool -id $d/$i $i; done

Building Qt

Download an unpack Qt.

Since we want our build to be as compatible as possible, we will build against the 10.4 (Tiger) SDK (even on Leopard). To build Qt, run:

export MACOSX_DEPLOYMENT_TARGET="10.4"
./configure -universal -qt-sql-sqlite -qt-sql-mysql -qt-libpng -sdk /Developer/SDKs/MacOSX10.4u.sdk -prefix /opt/mumble/qt-4.3.4/ -I /opt/mumble/mysql/include/ -L /opt/mumble/mysql/lib/

in the Qt directory. If configure runs sucessfully, continue by executing:

make
sudo make install

To make the Qt tools visible add the following line to your ~/.profile file:

export PATH=$PATH:/opt/mumble/qt-4.3.4/bin/

Installing Boost

As Mumble only uses some Boost headers you do not have to build Boost from scratch - you just need to unpack it.

It is advisible to unpack Boost to /usr/local/include/, so the Boost headers will be available in /usr/local/include/boost-1_34_1/, since Mumble will look for the headers in this place by default.

If you have MacPorts installed, you can install Boost by executing

sudo port install boost

Mumble will also look for the headers in /opt/local/include/boost-1_34_1/ - the default install location for MacPorts.

Building PortAudio

Download and extract the latest nightly PortAudio snapshot:

http://portaudio.com/archives/pa_snapshot.tar.gz

Build and install it:

export MACOSX_DEPLOYMENT_TARGET="10.4"
export OSX_SDK="/Developer/SDKs/MacOSX10.4u.sdk"
export OSX_CFLAGS="-isysroot $OSX_SDK -arch ppc -arch i386"
export OSX_LDFLAGS="-Wl,-syslibroot,$OSX_SDK -arch ppc -arch i386"
CFLAGS="-O2 -g $OSX_CFLAGS" LDFLAGS="$OSX_LDFLAGS" ./configure --disable-mac-universal --disable-dependency-tracking --prefix=/opt/mumble/portaudio/
make
sudo make install

Building Mumble

Fetch the Mumble source from SVN.

To build the client, execute:

export PKG_CONFIG_PATH=/opt/mumble/portaudio/lib/pkgconfig/:$PKG_CONFIG_PATH
qmake main.pro CONFIG+='release'
make

Note: If you didn't install Boost in the advised directory or through MacPorts, you should add your own include path to src/mumble/mumble.pro (search for boost).

If everything went well, you should now have a Mumble.app application bundle in the release directory of the root of the source tree.

Distributing Mumble

If you wish to create a proper redistributable Mumble application bundle, please refer to the osxdist.sh script in the scripts directory. This will help you clean up your application bundle, include the needed dependencies, resources etc., and create a compressed disk image - ready to redistribute!

The script expects you to be in the root of the source tree. After executing, it will spit out a .dmg of your Mumble build in the release folder.

Please note that the script currently is tuned for creating real redistributable versions of Mumble, and as such only works on universal (x86, ppc) release builds!