How to make disk image with darktable application bundle (64 bit Intel only):

1). Build darktable (and make sure it works) using instructions found in this blog post:
    http://www.darktable.org/2012/08/bringing-current-darktable-to-os-x/
    Macports will need some tuning though, so before you build anything add these lines to /opt/local/etc/macports/macports.conf:
     buildfromsource always
     macosx_deployment_target 10.6
    (practice showed that support for versions older than 10.6 isn't viable)
    And edit /opt/local/share/macports/Tcl/port1.0/portconfigure.tcl - change
     default configure.ldflags   {-L${prefix}/lib}
    to
     default configure.ldflags   {"-L${prefix}/lib -Wl,-headerpad_max_install_names"}
    Be aware that this change will be lost after upgrading to new macports version,
    so pay attention to "sudo port selfupdate" command output and re-edit this file when it happens.
    Also some versions of OS X have a bug making PTHREAD_RECURSIVE_MUTEX_INITIALIZER invalid, so gettext needs to be patched:
     $ mkdir -p ~/ports/devel
     $ cp -R /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/devel/gettext ~/ports/devel/
     $ curl -o ~/ports/devel/gettext/files/gettext-mutex-fix.patch https://raw.github.com/darktable-org/darktable/master/packaging/macosx/gettext-mutex-fix.patch
    then add gettext-mutex-fix.patch to patchfiles line in ~/ports/devel/gettext/Portfile and run
     $ portindex ~/ports
    Add "file:///Users/<username>/ports" (change <username> to your actual login) to /opt/local/etc/macports/sources.conf before [default] line.
    To have working OpenMP (at least partly, only for C source files) you will also need gcc46:
     sudo port install gcc46
    Configure darktable with this command instead of just "cmake ..":
     CC=gcc-mp-4.6 cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=10.6

2). Download, patch and install gtk-mac-bundler (assuming darktable was cloned into ~/src directory):
     $ cd ~/src
     $ curl -O http://ftp.gnome.org/pub/gnome/sources/gtk-mac-bundler/0.6/gtk-mac-bundler-0.6.1.tar.bz2
     $ tar -xf gtk-mac-bundler-0.6.1.tar.bz2
     $ cd gtk-mac-bundler-0.6.1
     $ patch -p1 < ../darktable/packaging/macosx/gtk-mac-bundler-0.6.1.patch
     $ make install

3). You will need to rebuild gtk2 with custom configure flag. Copy gtk2 Portfile to your local overlay:
     $ mkdir ~/ports/gnome
     $ cp -R /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/gnome/gtk2 ~/ports/gnome/
    Add these lines to ~/ports/gnome/gtk2/Portfile:
     variant bundle {
         configure.args-append --enable-quartz-relocation
     }
    Update index file and reinstall gtk2:
     $ portindex ~/ports
     $ sudo port install gtk2 +bundle
    The problem is that with this flag gtk2 works reliably only when included in bundle, so if you need working system gtk2 you will need to revert this change
    after you're done with bundle creation. To do that you can just run this command:
     $ sudo port install gtk2 -bundle

4). Now preparation is done, run image creating script, it should create darktable.dmg in current (packaging/macosx) directory:
     $ cd ~/src/darktable/packaging/macosx
     $ ./make-app-bundle
