For a long time now linux has been making a symlink /lib/modules/`uname -r`/build when doing the make modules_install step. Most of the time you indeed build modules for the currently running kernel so using this link is the right way then since this saves you from manually administering anything like the /usr/src/linux symlink. However currently gentoo policy is to force modules to use /usr/src/linux. The only time where you can not to build verses the running kernel is when you need an external module to boot your system in which case you are usually forced to use initrd. The other case where you preferably build verses a non-running kernel is when you rely on an external module to get network (eg. nvnet users) In my experience you more often build for the running kernel then for some other, hence utilising the kernels very own symlink seems most oppropriate to me. Now, during instalation things should not grow even more complicated then it already is which could happen if the policy changes to use the build symlink. A pretty decent solution could be to search for the /lib/modules/`uname -r`/build build symlink first, and if it is not available revert to using /usr/src/linux in ebuilds. If an ebuild falls back to /usr/src/linux it could display a warning. If /usr/src/linux is not the running kernel (easily found if you parse the easily parsable include/linux/version.h) then the ebuild probably should warn the user. If a user wants to force an ebuild to build for another kernel an environment variable could tell the ebuild where to use kernel sources from. Reproducible: Always Steps to Reproduce:
Was explained too many time the reason why gentoo uses the target kernel and not the running kernel for external modules. Please search bugzilla or the mailing list -dev/-user for further explanations. to make short explanation shorter, that way works, otherways would not.