KDEDIR is set to /usr rather then /usr/kde/2 causing a problem to non-gentoo builds that need KDEDIR to point to the root of the KDE installation (for example looking for the header files).
I don't really see how/why this would happen, but in any case I created a new revision (r4) of kdelibs-2.2.2 recently that might well fix this problem since the chnges were pertaining to the nv.d files. Please emerge it and check if KDEDIR still isn't set correctly.
Now KDEDIR is set to /opt/kde2,1 but the problem is not with kdelibs. I think the problem is not with kdelibs but rather with kde-env-2.1-r1. It installs /etc/env.d/90kde21 which includes the line: KDEDIR=/opt/kde2.1 The problem is with the naming of the files. 90kde21 comes (alphabetically) after 90kde2.2.2 and therefore takes precedence. Is it safe to unmerge kde-base/kde-env-2.1-r1?
It is getting stranger by the minute. grep 'KDEDIR' /etc/env.d returns /etc/env.d/40kdedir-2.2.2:KDEDIR=/usr/kde/2 /etc/env.d/90kde2.2.2:KDEDIR=/usr /etc/env.d/90kde21:KDEDIR=/opt/kde2.1 Seems that the only correct one is 40kdedir-2.2.2. Case of too many cooks in the kitchen ;-)
Aha! So that's the problem! Please unmerge kde-env. It's for kde2.1 (backward support) and is very much deprecated. The only two files about kde you should have in env.d are, for kdelibs-2.2.2-r4, 70kdelibs-2.2.2 and 40kdeedir-2.2.2. Please delete everything else, wherever it may have come from. Then run env-update and that should fix all your problems. Did you emerge kde-env yourself for some reason, or was it actually pulled in by another package?
This indeed worked. I don't recall installing kde-env by myself, but then I might have :-(