mac os xMac OS X

This page is out of date!
It is kept here for historical reasons and because it is a good reference, but you should be using these instructions instead.



dependenciesRequirements

  • A Mac OS X system running version 10.5 or later (both x86 and PowerPC are supported)
  • gcc-4.2:
    gcc-4.2 -v
  • Developer SDK:
    ls -ld /Developer/SDKs/MacOSX10.5.sdk
  • git
Note: there are some known issues with MacPorts, you may want to follow these instructions as a separate user or at least remove the macport paths from your environment.
We are building a 32-bit binary only.

gnomejhbuild

First, download the latest gtk-osx-build-setup.sh script and run it to setup the build environment:

curl --insecure -O https://git.gnome.org/browse/gtk-osx/plain/gtk-osx-build-setup.sh
sh gtk-osx-build-setup.sh

(it is unfortunate that git.gnome.org uses a certificate that is not trusted by OSX)


As per the script's warning, you must update your PATH:
export PATH=$PATH:~/.local/bin/

The rest of the instructions will either be jhbuild commands or run from the jhbuild environment by first starting the jhbuild shell:
jhbuild shell

gtkgtk-osx

Modify the configuration file to use a specific (and more recent) version of Python and GStreamer:
sed -i -e 's/^setup_sdk/#setup_sdk/g' .jhbuildrc-custom
cat << EOF >> .jhbuildrc-custom
_gtk_osx_use_jhbuild_python = True
branches["python"] = "http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz"
module_autogenargs['cairo'] = '--enable-ft=no'
setup_sdk(target="10.5", sdk_version="10.5", architectures=["i386"])
os.environ["CC"] = "/usr/bin/gcc-4.2"
os.environ["DYLD_LIBRARY_PATH"] = ""
build_policy = "updated-deps"
modules = [ "python",
	"meta-gtk-osx-bootstrap", "meta-gtk-osx-core",
	"libcroco", "librsvg",
	"meta-gtk-osx-python", "meta-gtk-osx-themes",
	"gtk-quartz-engine",
	"gtk-mac-integration-python" ]
EOF
You must replace i386 with ppc if that is your build platform.
If you want to use Python 2.6, change the URL to: http://www.python.org/ftp/python/2.6.7/Python-2.6.7.tar.bz2
To get rid of some annoying pygobject warnings, you may want to use this patch
This will build the native version of (Py)GTK for OSX (skipping libiconv to fix library problems on Lion):
jhbuild bootstrap --skip=libiconv
jhbuild build
If you get an error with MakeMaker being too old:
sudo cpan -i ExtUtils::MakeMaker

gtk x264/vpx/webp/theora/vorbis Video and Sound Encoding Support (for both Xpra and GStreamer)

First we need yasm:
curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar -zxf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure --prefix=${JHBUILD_PREFIX}
make && make install
cd ..
nasm:
curl -O http://www.nasm.us/pub/nasm/releasebuilds/2.11.02/nasm-2.11.02.tar.bz2
tar -zxf nasm-2.11.02.tar.bz2
cd nasm-2.11.02
./configure --prefix=${JHBUILD_PREFIX}
make && make install
cd ..

And the ORC CPU optimization library orc:
curl -O http://code.entropywave.com/download/orc/orc-0.4.18.tar.gz
tar -zxf orc-0.4.18.tar.gz
cd orc-0.4.18
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

Ogg sound encoding:
curl -O http://downloads.xiph.org/releases/ogg/libogg-1.3.1.tar.gz
tar -zxf libogg-1.3.1.tar.gz
cd libogg-1.3.1
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

Theora video encoding:
curl -O http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2
tar -jxf libtheora-1.1.1.tar.bz2
cd libtheora-1.1.1
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

Vorbis sound encoding:
curl -O http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.gz
tar -zxf libvorbis-1.3.4.tar.gz
cd libvorbis-1.3.4
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

Lame mp3:
curl -O http://winswitch.org/src/lame-3.99.5.tar.gz
tar -zxf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

Twolame mp3:
curl -O http://winswitch.org/src/twolame-0.3.13.tar.gz
tar -zxf twolame-0.3.13.tar.gz
cd twolame-0.3.13
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

mad mp3 encoder:
curl -O http://winswitch.org/src/libmad-0.15.1b.tar.gz
tar -zxf libmad-0.15.1b.tar.gz
cd libmad-0.15.1b
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

When building on a 64-bit system, you must use:

./configure CC="gcc -arch i386" CXX="g++ -arch i386" \
	--prefix ${JHBUILD_PREFIX}

aac audio encoder:
curl -O http://winswitch.org/src/faac-1.28.tar.bz2
tar -jxf faac-1.28.tar.bz2
cd faac-1.28
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

aac audio decoder:
curl -O http://winswitch.org/src/faad2-2.7.tar.bz2
tar -jxf faad2-2.7.tar.bz2
cd faad2-2.7
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

flac audio codec:
curl -O http://downloads.xiph.org/releases/flac/flac-1.3.0.tar.gz
tar -zxf flac-1.3.0.tar.gz
cd flac-1.3.0
./configure --prefix ${JHBUILD_PREFIX} --disable-asm-optimizations
make && make install
cd ..

speex audio codec:
curl -O http://downloads.xiph.org/releases/speex/speex-1.2rc1.tar.gz
tar -zxf speex-1.2rc1.tar.gz
cd speex-1.2rc1
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

wavpack audio codec:
curl -O http://www.wavpack.com/wavpack-4.70.0.tar.bz2
tar -jxf wavpack-4.70.0.tar.bz2
cd wavpack-4.70.0
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

VPX:
curl -O https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
tar -jxf libvpx-v1.3.0.tar.bz2
cd libvpx-v1.3.0
./configure --prefix=${JHBUILD_PREFIX} \
	--enable-vp8 --enable-vp9 --enable-pic --enable-static --target=x86-darwin8-gcc \
	--disable-install-docs --enable-realtime-only \
	--enable-runtime-cpu-detect
make && make install
cd ..

(substitute x86-darwin-gcc with ppc32-darwin8-gcc on PowerPC - you may have to disable vpx if you get errors building, this seems to be the case on x86_64 and ppc.. For x86_64, you may succeed by using the x86_64-darwin9-gcc target) )


x264:
curl -O http://download.videolan.org/pub/x264/snapshots/last_stable_x264.tar.bz2
tar -jxf last_stable_x264.tar.bz2
cd x264-snapshot-*
./configure --prefix=${JHBUILD_PREFIX} \
	--enable-pic --enable-shared --enable-static
make && make install
cd ..

When building on a 64-bit system, you must add --host=i386-apple-darwin to the configure step.
Versions newer than January 2014 may have problems building on older versions of Xcode.


webp:
curl -O https://webp.googlecode.com/files/libwebp-0.4.0.tar.gz
tar -zxf libwebp-0.4.0.tar.gz
cd libwebp-0.4.0
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

ffmpeg:
curl -O http://www.ffmpeg.org/releases/ffmpeg-2.1.4.tar.bz2
tar -jxf ffmpeg-2.1.4.tar.bz2
cd ffmpeg-2.1.4
./configure --prefix=${JHBUILD_PREFIX} \
	--cpu=i686 --enable-runtime-cpudetect \
	--enable-static --enable-shared --enable-gpl \
	--enable-memalign-hack \
	--enable-swscale \
	--enable-libx264 --enable-decoder=h264 \
	--enable-libvpx --enable-decoder=vp8 --enable-decoder=vp9 \
	--enable-decoder=hevc
make && make install
cd ..

(do not use libav instead of ffmpeg)


For a more limited ffmpeg build, useful for xpra but too limited for winswitch, use:
curl -O http://www.ffmpeg.org/releases/ffmpeg-2.1.4.tar.bz2
tar -jxf ffmpeg-2.1.4.tar.bz2
cd ffmpeg-2.1.4
./configure --prefix=${JHBUILD_PREFIX} \
	--cpu=i686 --enable-runtime-cpudetect \
	--enable-static --enable-shared --enable-gpl \
	--enable-memalign-hack \
	--disable-avdevice --disable-decoders --disable-dxva2 --disable-encoders \
	--disable-devices --disable-muxers --disable-demuxers \
	--disable-postproc --disable-avfilter  --disable-filters --disable-protocols \
	--disable-bsfs --disable-parsers  \
	--enable-swscale \
	--enable-libx264 --enable-decoder=h264 \
	--enable-libvpx --enable-decoder=vp8 --enable-decoder=vp9 \
	--enable-decoder=hevc
make && make install
cd ..

gtkGStreamer 0.10 plugins

Now we can build GStreamer and its modules.
First we enable some modules currently disabled by default:
sed -i -e 's/--disable-x --disable-xvideo//g' ~/Source/jhbuild/modulesets/gtk-osx-gstreamer.modules
Then we can start building GStreamer and its plugins:
jhbuild buildone gstreamer
jhbuild buildone gst-plugins-base
jhbuild buildone gst-plugins-good

(add --enable-introspection=no if gstreamer gets stuck on GEN Gst-0.10.gir)


And then the plugins which are not available via a gtk-osx module, starting with their dependencies:
curl -O http://www.libsdl.org/release/SDL-1.2.15.tar.gz
tar -zxf SDL-1.2.15.tar.gz
cd SDL-1.2.15
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

GStreamer "bad" plugins:
curl -O http://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-0.10.22.tar.bz2
tar -jxf gst-plugins-bad-0.10.22.tar.bz2
cd gst-plugins-bad-0.10.22
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..
(do not use 0.10.23 which fails to compile on OSX)
GStreamer "ugly" plugins:
curl -O http://gstreamer.freedesktop.org/src/gst-plugins-ugly/gst-plugins-ugly-0.10.18.tar.bz2
tar -jxf gst-plugins-ugly-0.10.18.tar.bz2
cd gst-plugins-ugly-0.10.18
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..
(do not use 0.10.19 which fails to compile on OSX)
And the python bindings:
curl -O http://gstreamer.freedesktop.org/src/gst-python/gst-python-0.10.22.tar.bz2
tar -jxf gst-python-0.10.22.tar.bz2
cd gst-python-0.10.22
./configure --prefix ${JHBUILD_PREFIX}
make && make install
cd ..

Note: later versions of bad and ugly plugins have build errors.

osxige-mac-bundler

ige-mac-bundler will be used to generate the standalone osx application bundle.
Download and install it:
curl -O http://ftp.gnome.org/pub/gnome/sources/gtk-mac-bundler/0.7/gtk-mac-bundler-0.7.3.tar.xz
xz -d gtk-mac-bundler-0.7.3.tar.xz
tar -xf gtk-mac-bundler-0.7.3.tar
cd gtk-mac-bundler-0.7.3
make install
Then you need to apply this patch on top. (no need to run make install again - install doesn't actually install the files anywhere..)

For more information on the process of bundling, why it is necessary and how it affects the shared libraries on OSX, see Dynamic Libraries, RPATH, and Mac OS and Porting to Mac/ige-mac-bundler

pythonPython dependencies

First we install some libraries used by pycrypto - this is optional (provides fastmath)
curl -O ftp://ftp.gmplib.org/pub/gmp-5.1.3/gmp-5.1.3.tar.bz2
tar -jxf gmp-5.1.3.tar.bz2
cd gmp-5.1.3
./configure --prefix ${JHBUILD_PREFIX} --build=i386-darwin
make && make install
cd ..

curl -O http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.bz2
tar -jxf mpfr-3.1.2.tar.bz2
cd mpfr-3.1.2
./configure --prefix ${JHBUILD_PREFIX} --build=i386-darwin
make && make install
cd ..

(substitute i386-darwin with ppc-darwin on PowerPC)


Install setuptools:
curl -k -O https://pypi.python.org/packages/source/s/setuptools/setuptools-3.1.tar.gz
tar -zxf setuptools-3.1.tar.gz
cd setuptools-3.1
python ./setup.py install
cd ..

And use it to install the following python tools and libraries:
easy_install -Z netifaces pam pycrypto pyasn1 pillow py2app cython numpy lz4

See this setuptools bug if you have problems installing numpy.
When building on a 64-bit system, you must use: ARCHFLAGS="-arch i386" easy_install ...
If you have problems with numpy, skip it an install it manually..

easy_install -U -Z twisted==12.0

(there is a conflict between gtk on OSX and Twisted version 12.1)

openglOpenGL

This is optional, it speeds up xpra's rendering.
Start by installing the Python OpenGL components:
easy_install -U -Z PyOpenGL PyOpenGL_accelerate
Then follow this ticket for the (py)gtkglext part (comment 5 onwards).

(you may need to use version 3.0 to workaround Cython compilation bugs in {{{OpenGL_accelerate}}})

xpraXpra dependencies

Xpra dependencies need for clipboard support: PyObjC:
curl -O -k https://pypi.python.org/packages/source/p/pyobjc-core/pyobjc-core-2.5.1.tar.gz
tar -zxf pyobjc-core-2.5.1.tar.gz
cd pyobjc-core-2.5.1
python ./setup.py install

curl -O -k https://pypi.python.org/packages/source/p/pyobjc-framework-Cocoa/pyobjc-framework-Cocoa-2.5.1.tar.gz
tar -zxf pyobjc-framework-Cocoa-2.5.1.tar.gz
cd pyobjc-framework-Cocoa-2.5.1
python ./setup.py install

curl -O https://pypi.python.org/packages/source/p/pyobjc-framework-Quartz/pyobjc-framework-Quartz-2.5.1.tar.gz
tar -zxf pyobjc-framework-Quartz-2.5.1.tar.gz
cd pyobjc-framework-Quartz-2.5.1
python ./setup.py install

desktopBuild Protocol Support

  • xpra:
    curl -O http://xpra.org/src/xpra-0.11.6.tar.bz2
    tar -jxf xpra-0.11.6.tar.bz2
    cd xpra-0.11.6
    python setup.py install
    cd ..
  • RDesktop:
    curl -O http://winswitch.org/src/rdesktop-1.8.1.tar.gz
    tar -zxf rdesktop-1.8.1.tar.gz
    cd rdesktop-1.8.1
    ./configure --prefix ${JHBUILD_PREFIX} --disable-credssp --disable-smartcard
    make && make install
    cd ..
  • TigerVNC:
    curl -O http://winswitch.org/src/tigervnc-1.1.0.tar.gz
    tar -zxf tigervnc-1.1.0.tar.gz
    cd tigervnc-1.1.0
    ./configure --prefix ${JHBUILD_PREFIX}
    sed -i -e 's+-lXext -lX11+-lXext -lX11 -lintl -lgettextlib -L/usr/X11/lib/+g' unix/vncviewer/Makefile
    make && make install
    cd ..
  • NX:
    curl -O http://winswitch.org/src/nxcomp-3.5.0-2.tar.gz
    curl -O http://winswitch.org/src/nxcomp.patch
    curl -O http://winswitch.org/src/nxproxy-3.5.0-1.tar.gz
    tar -zxf nxcomp-3.5.0-2.tar.gz
    cd nxcomp
    ./configure
    patch -p1 < ../nxcomp.patch
    sed -i -e 's+-bundle+-dynamiclib+g' Makefile
    make
    cp -Rp libXcomp.so* ${JHBUILD_PREFIX}/lib/
    cd ..
    tar -zxf nxproxy-3.5.0-1.tar.gz
    cd nxproxy
    ./configure --prefix ${JHBUILD_PREFIX}
    sed -i -e 's/-lXcomp/-lXcomp -lpng -ljpeg -lz/' Makefile
    make && make install
    cd ..

setup-installerBuilding the standalone application

curl -O http://winswitch.org/src/winswitch-0.12.20.src.tar.bz2
tar -jxf winswitch-0.12.20.src.tar.bz2
cd winswitch-0.12.20
# Add the osx specific bits:
curl -O http://winswitch.org/src/winswitch-osx-0.12.20.src.tar.bz2
tar -jxf winswitch-osx-0.12.20.src.tar.bz2
ln  -sf winswitch-osx-0.12.20 osx

PYTHONPATH=.:$PYTHONPATH ./setup.py install
./setup.py py2app
cd osx/bundle
./make-app.sh

The resulting application bundle will be copied to the desktop.

Building a DMG disk image is currently a manual process. (see bug #76 for more details)


The error: IOError: [Errno 2] No such file or directory: '~/gtk/inst/lib/python2.7/site-packages/py2app-0.5.2-py2.7.egg/py2app/apptemplate/prebuilt/main-i386'
can be solved by:
cp ~/gtk/inst/lib/python2.7/site-packages/py2app-0.5.2-py2.7.egg/py2app/apptemplate/prebuilt/main-intel ~/gtk/inst/lib/python2.7/site-packages/py2app-0.5.2-py2.7.egg/py2app/apptemplate/prebuilt/main-i386

subversionOptional: Build subversion 1.8.x

If you want to have version information from trunk... you will need a recent build of subversion...
So either install one you downloaded, or try this:
curl -O http://download.oracle.com/berkeley-db/db-6.0.30.tar.gz
tar -zxf db-6.0.30.tar.gz
cd db-6.0.30
./dist/configure --prefix=${JHBUILD_PREFIX}
make && make install
cd ..

curl -O http://www.eu.apache.org/dist/apr/apr-1.5.0.tar.bz2
tar -jxvf apr-1.5.0.tar.bz2
cd apr-1.5.0
./configure --prefix=${JHBUILD_PREFIX}
make && make install
cd ..

curl -O http://www.eu.apache.org/dist/apr/apr-util-1.5.3.tar.bz2
tar -jxvf apr-util-1.5.3.tar.bz2
cd apr-util-1.5.3
./configure --prefix=${JHBUILD_PREFIX} \
	--with-berkeley-db=${HOME}/db-6.0.30 \
	--with-apr=${JHBUILD_PREFIX}/bin/apr-1-config
make && make install
cd ..

curl -O http://www.eu.apache.org/dist/subversion/subversion-1.8.8.tar.bz2
tar -jxf subversion-1.8.8.tar.bz2
cd subversion-1.8.8
#sqlite:
curl -O https://sqlite.org/2014/sqlite-amalgamation-3080400.zip
unzip sqlite-amalgamation-3080400.zip
ln -sf ../sqlite-amalgamation-3080400 ./sqlite-amalgamation
#serf:
./get-deps.sh serf
pushd serf
./configure --prefix ${JHBUILD_PREFIX} 
make && make install
popd
./configure --prefix=${JHBUILD_PREFIX} \
	--disable-keychain --disable-nls --enable-bdb6 \
	--without-apxs \
	--with-apr=${JHBUILD_PREFIX}/bin/apr-1-config \
	--with-apr-util=${JHBUILD_PREFIX}/bin/apu-1-config \
	--with-serf=${JHBUILD_PREFIX}
make && make install
cd ..

gdbOptional: GDB

If you ever need to debug anything on OSX with gdb, the versions shipped with xcode are well out of date. You can easily build a more recent gdb in the jhbuild shell though:
curl -O http://ftp.gnu.org/gnu/gdb/gdb-7.7.tar.bz2
tar -jxf gdb-7.7.tar.bz2
cd gdb-7.7
./configure --prefix=${JHBUILD_PREFIX}
make && make install
#fix "Unable to find Mach task port for process-id" error:
sudo chgrp procmod ${JHBUILD_PREFIX}/bin/gdb
sudo chmod g+s ${JHBUILD_PREFIX}/bin/gdb