I've got nearly the same problem, except that i'm trying to compile php4.0.3pl1 with gd1.8.3-support on Redhat 6.2 and the compiler is getting trouble a little bit earlier in gd.c:
gd.c: In function php_if_imagecreatefromgif':
gd.c:552:gdImageCreateFromGif' undeclared (first use in this function)
gd.c:552: (Each undeclared identifier is reported only once
gd.c:552: for each function it appears in.)
gd.c: In function php_if_imagegif':
gd.c:709:gdImageGif' undeclared (first use in this function)
make[3]: [gd.lo] Error 1
make[3]: Leaving directory /usr/local/src/php-4.0.3pl1/ext/gd'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory/usr/local/src/php-4.0.3pl1/ext/gd'
make[1]: [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/php-4.0.3pl1/ext'
make: *** [all-recursive] Error 1
I think the problem is that the gif-image format is not supported anymore in gd 1.8.3 (only png)... somebody knows a solution?
Thanks a lot...