Part of build log: [ 37%] Building CXX object kdeui/CMakeFiles/kdeui.dir/util/knotificationrestrictions.o In file included from /var/tmp/portage/kde-base/kdelibs-4.1.2/work/kdelibs-4.1.2/kdeui/util/knotificationrestrictions.cpp:32: /usr/include/X11/extensions/XTest.h:50:35: error: X11/extensions/XInput.h: No such file or directory I'm not really sure what version of xinput is required, but 1.3.0 does fine.
qfile /usr/include/X11/extensions/XInput.h x11-proto/inputproto (/usr/include/X11/extensions/XInput.h) kde-base/kdelibs/kdelibs-4.1.2.ebuild: COMMONDEPEND=" ... x11-libs/libX11 ..." x11-libs/libX11/libX11-1.1.5.ebuild DEPEND="${RDEPEND} ... x11-proto/inputproto ..." So this bug is invalid. Make sure you have all your world deps installed.
My bad, of course it requires x11-proto/inputproto not x11-misc/xinput. But the matter is following: if you make 'emerge --depclean --with-bdeps=n' it will remove x11-proto/inputproto as it is only a build-time dependency. But then making 'emerge --deep kdelibs:4.1' won't pull in x11-proto/inputproto as it is not marked as build-time dependency of kde-base/kdelibs and therefore the build will fail.
*** This bug has been marked as a duplicate of bug 227583 ***