The answer depends on the VERISON of GD that you want.
PHP comes standard with GD built-in.
Use the "--with-gd" option on the "configure" line (along with whatever other options you want) -
./configure --with-gd [other-options]
then
make
then
make install