Thanks for your help. I ended up getting gcc, make, m4, autoconf, bison and flex installed successfully by downloading binary packages from sunfreeware.com. I have also set CC to point to gcc so hopefully I am now properly set up to configure and install Apache and PHP directly from the source code.