Difference between revisions of "BuildingMacOSX"

From Mumble Wiki
Jump to: navigation, search
(Distributing Mumble)
(Compiling Portaudio)
Line 45: Line 45:
  
 
For the Mumble build system to find this you will have to modify the included ''portaudio-2.0.pc.in'', rename it to ''portaudio-2.0.pc'' and put it in you PKG_CONFIG_PATH.  
 
For the Mumble build system to find this you will have to modify the included ''portaudio-2.0.pc.in'', rename it to ''portaudio-2.0.pc'' and put it in you PKG_CONFIG_PATH.  
My portaudio-2.0.pc file looks like this:
+
My ''portaudio-2.0.pc'' file looks like this:
  
  FIXME: include this information
+
  prefix=/Users/username/Development/portaudio
 +
exec_prefix=${prefix}
 +
libdir=${exec_prefix}/lib
 +
includedir=${exec_prefix}/include
 +
 +
Name: PortAudio
 +
Description: Portable audio I/O
 +
Requires:
 +
Version: 19
 +
 +
Libs: -L${libdir} -lportaudio
 +
Cflags: -I${includedir}
  
 
== Building Mumble ==
 
== Building Mumble ==

Revision as of 15:26, 4 December 2007

Universal or not Universal?

If you want to build Mumble as universal binary you will first have to build all dependencies as universal binary.

Dependencies

To build Mumble you will need:

Compiling pkg-config

This is just a build tool, so you do not have to build it as universal binary. 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

Compiling QT

Download an unpack QT. Run

./configure -universal -qt-sql-sqlite -qt-libpng

in the QT dir. If configure is successful run

make && sudo make install

QT will be installed to /usr/local/Trolltech/Qt-4.3.X or similar.

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

export PATH=$PATH:/usr/local/Trolltech/Qt-4.3.X/bin

Compiling Boost

As Mumble only uses some Boost headers you do not have to build/install this. Just unpack Boost.

Compiling Portaudio

This builds universal by default. So just download, unpack and:

./configure && make

For the Mumble build system to find this you will have to modify the included portaudio-2.0.pc.in, rename it to portaudio-2.0.pc and put it in you PKG_CONFIG_PATH. My portaudio-2.0.pc file looks like this:

prefix=/Users/username/Development/portaudio
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include

Name: PortAudio
Description: Portable audio I/O
Requires:
Version: 19

Libs: -L${libdir} -lportaudio 
Cflags: -I${includedir}

Building Mumble

Fetch the Mumble source from SVN. First build speex by changing into the speexbuild subdirectory and running:

qmake speexbuild.pro && make

After that change to the src/mumble subdirectory. Here you might have to change some parameters in mumble.pro, so open it in a text editor. Change the path in the line:

INCLUDEPATH += /usr/local/include/boost-1_34/

to the path where your boost headers are located.

then run:

qmake -nocache -config release -spec macx-xcode mumble.pro

after that you can:

open mumble.xcodeproj

In XCode switch to Release target and press the build button. If this finishes without errors you have done everything right and the finished application is located in the subdir src/mumble/build/Release of the main mumble sourcedir.

Distributing Mumble

To include all the needed dependencies in the mumble application bundle you can use the following shell script:

#!/bin/bash
#
# Original version by
#     Thomas Keller (me AT thomaskeller DOT biz)
#
# adapted by Sebastian Schlingmann (sebastian dot schlingmann at users dot sourceforge dot net)

#
# INITIAL CONFIGURATION START
#

# relative path to the directory which contains the created app bundle
BIN_DIR="."
# name of the binary
BINARY_NAME="mumble"
# Qt libraries you've linked against
declare -a NEEDED_LIBS=( "QtCore" "QtGui" "QtXml" "QtOpenGL" "QtSql" "QtNetwork" )
# additional files you'd like to get copied to the final dmg
declare -a ADD_FILES=( )
# additional libs we have linked against
declare -a OTHER_LIBS=( "/usr/lib/libcrypto.0.9.7.dylib" "/usr/lib/libssl.0.9.7.dylib" "/usr/local/lib/libportaudio.0.0.19.dylib" )

#
# INITIAL CONFIGURATION END, CONTINUE AT 'OTHER CONFIGURATION'
#

bundle_dir="$BIN_DIR/$BINARY_NAME.app"
bundle_bin="$bundle_dir/Contents/MacOS/$BINARY_NAME"
framework_dir="$bundle_dir/Contents/Frameworks"
resources_dir="$bundle_dir/Contents/Resources" 

if [ -z $QTDIR ]; then
  echo "\$QTDIR environment variable not found... exiting."
  exit 1
fi

# canonicalize QtDir, unfortunately this bash has no realpath() implementation
# so we need to use perl for this
QTDIR=`perl -e "use Cwd 'realpath'; print realpath('$QTDIR');"`

if [ ! -d "$bundle_dir" ]; then
  echo "Application bundle not found in bin... exiting."
  exit 1
fi

echo "Creating Frameworks directory in application bundle..."
mkdir -p "$framework_dir"
echo "Creating Resources directory in application bundle..."
mkdir -p "$resources_dir"

libcount=${#NEEDED_LIBS[@]}
for (( i = 0 ; i < libcount ; i++ ))
do
   lib=${NEEDED_LIBS[$i]}
   echo "Processing $lib..."

   if [ ! -d "$QTDIR/lib/$lib.framework" ]; then
       echo "Couldn't find $lib.framework in $QTDIR."
       exit 1
   fi

   rm -rf "$framework_dir/$lib.framework"
   cp -fR "$QTDIR/lib/$lib.framework" "$framework_dir"
   echo "...$lib copied."

   install_name_tool \
       -id "@executable_path/../Frameworks/$lib.framework/Versions/4/$lib" \
       "$framework_dir/$lib.framework/Versions/4/$lib"

   # other Qt libs depend at least on QtCore
   if [ "$lib" != "QtCore" ]; then
       install_name_tool -change "$QTDIR/lib/QtCore.framework/Versions/4/QtCore" \
           "@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore" \
           "$framework_dir/$lib.framework/Versions/Current/$lib"
   fi

   if [ "$lib" == "QtOpenGL" ]; then
       install_name_tool -change "$QTDIR/lib/QtGui.framework/Versions/4/QtGui" \
           "@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui" \
           "$framework_dir/$lib.framework/Versions/Current/$lib"		
   fi
   
   install_name_tool -change "$QTDIR/lib/$lib.framework/Versions/4/$lib" \
       "@executable_path/../Frameworks/$lib.framework/Versions/4/$lib" \
       "$bundle_bin"
   echo "...$lib done."
done

libcount=${#OTHER_LIBS[@]}
for (( i = 0 ; i < libcount ; i++ ))
do
   lib=${OTHER_LIBS[$i]}
   lib_basename=`basename $lib` 
   echo "Processing $lib..."

   if [ ! -f "$lib" ]; then
       echo "Couldn't find $lib."
       exit 1
   fi

   rm -rf "$framework_dir/$lib"
   cp -fRL "$lib" "$framework_dir"
   echo "...$lib copied."
	
   install_name_tool \
       -id "@executable_path/../Frameworks/$lib_basename" \
       "$framework_dir/$lib_basename"
   
   install_name_tool -change "$lib" \
       "@executable_path/../Frameworks/$lib_basename" \
       "$bundle_bin"
#
# OTHER CONFIGURATION
#
# insert propper paths and filenames
#
	
   if [ "$lib_basename" == "libssl.0.9.7.dylib" ]; then
        install_name_tool -change "/usr/lib/libcrypto.0.9.7.dylib" \
        "@executable_path/../Frameworks/libcrypto.0.9.7.dylib" \
        "$framework_dir/$lib_basename"
   fi
#
# OTHER CONFIGURATION END
#	
	
   echo "...$lib done."
done

#copy icon
cp mumble.icns $resources_dir

#strip main executable
strip $bundle_bin

echo "Preparing image directory..."
tempdir="/tmp/`basename $0`.$$"
mkdir $tempdir
cp -R $bundle_dir $tempdir
echo "...Bundle copied"
fcount=${#ADD_FILES[@]}
for (( i = 0 ; i < fcount ; i++ )) do
   file=${ADD_FILES[$i]}   
   if [ ! -f "$file" ]; then
       echo "WARNING: $file not found!"
   else
       cp "$file" $tempdir
       echo "...$file copied" 
   fi
done
echo "Creating disk image..."
rm -f "$BIN_DIR/$BINARY_NAME.dmg"
# format UDBZ: bzip2 compressed (10.4+),  UDZ0: zlib compressed (default) 
hdiutil create -srcfolder $tempdir -format UDBZ -volname "$BINARY_NAME" "$BIN_DIR/$BINARY_NAME.dmg"
rm -rf $tempdir

You will have to set the QTDIR environment variable before executing the script. You will also most certainly have to change something in the INITIAL CONFIGURATION and/or the OTHER CONFIGURATION sections. The output is a nice little .dmg file with you application bundle inside.