How to build GIMP on mac OS X

Building GIMP and all its dependencies from source takes quite a bit of time (at least a few hours), but fortunately it's generally not difficult.

Simone has created an alternative way to GIMP.app for creating a GIMP Package on your Mac. The trick is to compile all the MacPorts stuff under a special location, /tmp/slk/, and then the Gimp.app launch scripts just recreate /tmp/slk as a symlink before launching. Thus you can move the app wherever you want, it will just re-create the symlink accordingly and still work. This has the result that no shell-variables have to be set like in the former GIMP.app. That makes your Gimp less vulnerable to errors.

You will also need to install Developer Tools from Apple (or your OS X install disk) if not already done. Make sure to update to the latest version (for instance Xcode 2.2 is known to have problems that are fixed by upgrading to 2.5).

What needs to be done once

Install MacPorts

The first step is to build a special copy of macports with the new location built-in. Before doing this, be very careful to remove/move any references to any older macports install you had (e.g. sudo mv /opt/local /opt/local-disabled) otherwise you might find yourself in the uneasy situation where what you install is a mix and match of libraries from both locations. (If you have installed lots of stuff in /usr/local it might be a good idea to do the same with that prefix too, and not move them back until the very end of the build.) It might also be a good idea to remove ~/.macports so you really have a clean install.

First of all create a folder src/macports in your home-folder and untar the MacPorts Source into it.

mkdir -p ~/src/macports
cd ~/src/macports
mkdir Gimp.app
Then we create the symlink that bridge everything. Note we are creating it in /tmp, this means that if you log out or shut down your computer it will be erased. If you need to interrupt the build and shut your computer, you will need to re-create it next time, before you can continue building.

The GIMP portfile will be located at this location, should we ever need to manually update it to a newer version (always check the forum to know whether such a manual update is necessary. there will usually be a thread associated with each GIMP release)
~/src/macports/Gimp.app/Contents/Resources/var/macports/sources/rsync.macports.org/release/ports/graphics/gimp2

Warning : do not open an existing GIMP application while macports is building stuff, doing so will change the symlink and mess up your build.

Possible problem

If you meet the following problem :

---> Activating p5-getopt-long 2.37_0
Error: Target org.macports.activate returned: Image error: /tmp/skl/Gimp.app/Contents/Resources/lib/perl5/5.8.8/Getopt/Long.pm is being used by the active perl5.8 port. Please deactivate this port first, or use the -f flag to force the activation.
Warning: the following items did not execute (for p5-getopt-long): org.macports.activate

run the following command :
sudo ~/src/macports/Gimp.app/Contents/Resources/bin/port -f activate p5-getopt-long
then run the gimp2 +x11 one again and you should be able to continue your build. Alternatively, it was reported that just issuing the gimp2 +x11 command repeatedly eventually got it to work.

Ghostscript

Macports has a nasty tendency of screwing up ghostscript (what reads poscript/eps files) so before continuing we will test its installation, and on failure fix it manually

Issue this command on the terminal :

/tmp/skl/Gimp.app/Contents/Resources/bin/gs --version

If it prints the current version number as expected, your installation is fine and you can continue to the next step. If, however, it fails because of some missing or incompatible library, you'll need to manually fix ghostscript.

Download the ghostscript source code here (e.g. GPL Ghostscript 8.62), then build and install it using the commands below. Before continuing, make sure your /tmp/skl symlink is still properly setup.

Packaging

Now the output directory is ready, we'll let the script finish the packaging.

cd output
./gimpguts.sh

The script will copy all the files from your Macports Installation into the Gimp-skeleton. Then it's time to make a dmg.

cd ..
sh make_dmg.sh

Done

Your Gimp-build is done and ready to run. The resulting binary will be located in the output directory. A dmg will have been generated in the skeleton directory. This DMG is ready to be uploaded and distributed (just replace VERSION in its name with the current GIMP version). Feel free to contact us at our website.