More people have asked for including the GD module in this documentation set. So I finally had the time to research this and write it up and give this to you.

First download the source code from the Freshmeat libjpeg project. I’ve used the source file jpegsrc.v6b.tar.gz.

First unpack the source code and then go into the folder “jpeg-6b” for the source and execute the following commands:

cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .

Which will copy these files to the current directory. They are required for the configuration fase of this installation.

Next for 64 bits systems use:

export MACOSX_DEPLOYMENT_TARGET=10.5
CFLAGS="-arch x86_64" \
CXXFLAGS="-arch x86_64" \
LDFLAGS="-arch x86_64" \
./configure --enable-shared

For 32 bits systems use:

export MACOSX_DEPLOYMENT_TARGET=10.5
./configure --enable-shared

For all use

make

To compile and

sudo make install

To install the library.

Next step is to recompile the php installation as described on these two pages:
Compiling PHP in 32 bits mode on Leopard
Compiling PHP in 64 bits mode on Leopard

The only change you need to make is to add:

--with-gd \
--with-jpeg-dir=/usr/local/lib \
--with-png-dir=/usr/X11R6 \
--with-freetype-dir=/usr/X11R6 \
--with-xpm-dir=/usr/X11R6 \

To the configure statement and it will include this library for you.

For example:

./configure --prefix=/usr/local/php5 \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/etc \
--with-zlib \
--with-zlib-dir=/usr \
--with-openssl \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-mbregex \
--enable-sockets \
--with-gd \
--with-jpeg-dir=/usr/local/lib \
--with-png-dir=/usr/X11R6 \
--with-freetype-dir=/usr/X11R6 \
--with-xpm-dir=/usr/X11R6 \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-apxs2=/usr/local/apache2/bin/apxs