I think I know the solution as well. It seems at some point either /etc/profile.env or /etc/env.d/ is being read sometime after QTDIR is being set to the working qt-3 dir. So that QTDIR is pointing to /usr/qt/2 which caused qt-3 not to compile at all. My solution was to comment all instances of QTDIR out of environment files.. but I think it should be done int he ebuild.
I can't reproduce it. I export QTDIR=${S} (S being the working directory) in the ebuild. I don't see where it could have been overridden, but let's try to locate it. I've now added an export QTDIR=${S} line before every major action in the ebuild. (It may be upto 30 minutes before it's on rsync). Please restore your env.d settings (I hope you've kept them!) and try this new ebuild. If it works, we'll remove these lines one by one, until it stops working. That is, if you don't mind compiling qt so many times :-)
Ok.. So I got qt installed by useing the method I described (namely commenting out QTDIR= lines in the conf.d/ file.. Qt 3 is installed now, I just tried to merge the ebuild that you changed, and it still fails. So that seems odd even with all the export QTDIR lines qtfails to build.
Please try it with the recently unmasked new portage-1.8.9_pre32 and tell me if it works. This portage has so many new updates, it might have fixed this.
Well I tried it with the latest pre of portage, and that didn't fix my problem. Now it seems to be worse though. I've gone back to the stable release of portage, and the new release 3.0.3 of qt won't compile (same problem looking in /usr/qt/2) even when I comment out the lines from the /etc/env.d/50qt2 file.
Ah.. But if I comment out the QTDIR entry in the profile.env file, then it seems to work..
That last is because profile.env is auto-generated from the files in env.d after every run of emerge. You can generate it manually using env-update. This is really wierd, especially since noone else reported anything like it. I'll have to think about it.
Sorry. But I can't reproduce it or think of anything that might be causing it, and no one else reported anything of the sort.