The problem (I found) with the built in bundled gd library working in MacOS X is related not having access to the libpng (etc) library. For instance, if you have Fink and have NOT installed gd, this works fine...
--with-gd --with-jpeg-dir=/sw --with-png-dir=/sw --with-freetype-dir=/sw --with-t1lib=/sw
assuming you've installed the libjpeg, libpng, libfreetype and libt1lib.
As for GIF write support, other than patching GD, you can also try using imagemagick extension which is part of the PEAR/PECL library
curl --remote-name http://pear.php.net/get/imagick-0.9.5.tgz
unpack and install in your php/ext
run ./buildconf before ./configure
NOTE: AFAIK, you cannnot follow the regular build instructions for building ImageMagick as a shared extension because PHP4 on Mac OS X does not support dynamic loading of extensions (a real shame). PHP 5 does do this, however. :-)
Also, you need to compile imagemagick, and thus --with-imagick=/sw ;-)