Could not find a Makefile in the kernel source directory.
This is a wiki page. Be bold and improve it!
If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.
When emerging some (gentoo) packages, you might encounter the following error message:
* Could not find a Makefile in the kernel source directory.
* Please ensure that /usr/src/linux points to a complete set of Linux sources
* Unable to calculate Linux Kernel version for build, attempting to use running version
Some packages indeed require information about the configuration of the current linux kernel running on the system. The necessary
Makefile mentionned in the error message above, is generated when the linux kernel is emerged and compiled. It is also removed when the corresponding kernel package is removed from the gentoo tree.
The solution is two-fold:
1- Use this opportunity to upgrade your kernel and recompile it. (or else grab a copy of the ebuild of your currently running kernel version and recompile that one). See other, existing documentation on how to upgrade your kernel.
2- Prevent the package of a currently running kernel version from being removed, to prevent this error from occuring again. Edit
/var/lib/portage/world and add a line using the exact version of the sources installed, like this:
Packages known to require a full linux kernel source: