Compiling GTK+ 2.x

I decided to compile GTK+ 2.8.12 — it seemed like a good idea at the time; I had my reasons (this bug and no root access).

So I downloaded the source and some of the dependencies and tried to follow the install guide. Then I hunted out a couple more dependencies. The GTK+ people do provide a lot more help than many projects, so this is not intended as a gripe. But it took me rather longer than I was hoping, just because there’s so much to compile.

The following script worked for me on 2006-02-21. But URLs and version numbers will change, and other systems will be different. So it will quit on the first (inevitable) error (that’s what set -e does). Not the best way of doing things, but maybe seeing the steps explicitly might help someone else. It’s a record for me anyway.

#!/bin/bash

set -e

PREFIX=/home/iam23/opt/gtk

if [ \! -e "$PREFIX" ] ; then mkdirhier "$PREFIX" ; fi

# Main GTK+-maintained libraries
wget ftp://ftp.gtk.org/pub/gtk/v2.8/atk-1.10.3.tar.bz2
wget ftp://ftp.gtk.org/pub/gtk/v2.8/glib-2.8.6.tar.bz2
wget ftp://ftp.gtk.org/pub/gtk/v2.8/gtk+-2.8.12.tar.bz2
wget ftp://ftp.gtk.org/pub/gtk/v2.8/pango-1.10.2.tar.bz2

# Other dependencies
wget ftp://ftp.gtk.org/pub/gtk/v2.8/dependencies/cairo-1.0.2.tar.gz
wget ftp://ftp.gtk.org/pub/gtk/v2.8/dependencies/jpegsrc.v6b.tar.gz
wget ftp://ftp.gtk.org/pub/gtk/v2.8/dependencies/libpng-1.2.8.tar.bz2
wget ftp://ftp.gtk.org/pub/gtk/v2.8/dependencies/pkg-config-0.20.tar.gz
wget ftp://ftp.gtk.org/pub/gtk/v2.8/dependencies/tiff-3.7.4.tar.gz

wget http://switch.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.10.tar.bz2 
wget 'http://fontconfig.org/release/fontconfig-2.3.2.tar.gz'
# Note that when cairo winges about freetype it might be because fontconfig is missing
# 

# My untar script http://homepages.inf.ed.ac.uk/imurray2/code/hacks/untar
untar *tar*

export CPPFLAGS="-I$PREFIX/include"
export LDFLAGS="-L$PREFIX/lib"
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig"
export LD_LIBRARY_PATH="$PREFIX/lib"
export PATH="$PREFIX/bin:$PATH"
# This one wasn't in the instructions, but I needed it:
export PKG_CONFIG="$PREFIX/bin/pkg-config"
# This one was for "good measure", probably unnecessary:
export LD_RUN_PATH="$PREFIX/lib"

# GAH! This took a while to pin down. I was getting errors about immodules in
# another GTK setup at install time.
unset GTK_PATH
# Checking your distro hasn't tucked anything else bad into your env is a good idea too.

# # GAH must hack makefile for libpng manually!
echo Gah libpng has to be different to the others. Please sort out its Makefile and install it
echo then press enter
read

# *** Things I got away with
# I had GNU make, libiconv and libintl, you may not
# Cairo must support Xlib backend, so make sure have development libraries for that.
# "locate Intrinsic.h", will tell you if you do (it's what the cairo configure script does)

for a in pkg-config-0.20 jpeg-6b tiff-3.7.4 freetype-2.1.10 fontconfig-2.3.2 cairo-1.0.2 glib-2.8.6 pango-1.10.2 atk-1.10.3 gtk+-2.8.12; do
    cd "$a"
    ./configure --prefix="$PREFIX"
    make
    make install
    cd ..
done