When I try to emerge mod_php with such flags:
+X +apache2 +berkdb +crypt +curl +doc -fdftk -firebird +flash -freetds +gd -gd-external +gdbm -gmp +imap -informix -ipv6 +java +jpeg -ldap -mcal +memlimit +mysql +nls -oci8 +odbc +pam +pdflib +png +postgres +qt +snmp +spell +ssl +tiff +truetype +xml2 -yaz
it stops after checking for IMAP, in config.log I can see, that libgssapi_krb5.a is missing, so all You have to do is to add that mit_krb5 is needed when compiling mod_php with IMAP.
Steps to Reproduce:
1. emerge unmerge mit-krb5
2. USE="...myflags(probably ssl + imap" emerge mod_php
libgssapi_krb5.a is missing (error while compiling)
find the lib and compile, compile, compile....
I thin this is not needed...
mit-krb5 will only be pulled in if USE=kerberos
After emerging mit-krb5 You need to unmerge heimdal, because while compiling mod_php you'll get multiple definition of.... (com_right and probably some more of them). I wonder why mit-krb5 is not blocked by heimdal, they share some files so it should be done...
kerberos is a system-level thing, so if you have it and stuff linked against it, without having it in your USE flags, it's your own fault things don't work.