PHP 5.2.12 has a bug that will stop your installation:

/bin/sh /Users/kelvin/phpsource/php-5.2.12/libtool --silent --preserve-dup-deps --mode=compile gcc  ...includes redacted...  -no-cpp-precomp  -I/usr/local/php5/include -g -O2  -c /Users/kelvin/phpsource/php-5.2.12/ext/standard/dns.c -o ext/standard/dns.lo 
In file included from /usr/include/arpa/nameser.h:59,
                 from /Users/kelvin/phpsource/php-5.2.12/ext/standard/dns.c:62:
/usr/include/arpa/nameser8_compat.h:304: error: conflicting types for ‘HEADER’
/usr/include/arpa/nameser_compat.h:99: error: previous declaration of ‘HEADER’ was here
make: *** [ext/standard/dns.lo] Error 1
Trinity:~ kelvin$ 

Two header files (nameser8_compat.h & nameser_compat.h) both try to define a struct named HEADER. No can do. According to the PHP bug tracker, “NEVER ever include nameser_compat.h, it’s included in various ways in different OSes by nameser.h if needed

Doh!

So how do we go about fixing this? The easiest thing to do is to install the older PHP 5.2.11 or the HEAD from the 5.2 branch. If you are adventurous or obsessive-compulsive you can also replace these two files with the patched copies:

  1. ~/php-5.2.12/configure.innotes
  2. ~/php-5.2.12/ext/standard/dns.cnotes