You'll need client libraries for imap and ldap. For imap, they are part of the UW-IMAP bundle, but I think they distribute it separately as well. For ldap, there must be a set included in Solaris (perhaps PHP's autoconf isn't recognizing them?) of you can get the OpenLDAP bundle that will include the client libs.
Still, it's a lot of work and a horror to maintain! I don't have any solaris guru at hand right now, but there are several packaging systems for solaris, one with GNU packages, and a ports system similar to the BSDs. Having done it myself (a lot), it's not fun to compile PHP with expat, imap, ldap, gd and the whole world every time there's a new PHP version.