Building a kernel module separately

I just found out how to build a single Linux kernel module from the tarball, without building the entire kernel, while using the settings of the current kernel. This can be useful if you want to patch one module to quickly try something out or debug an issue:
make -C /lib/modules/`uname -r`/build M=`pwd`  drivers/platform/x86/acer-wmi.ko
This assumes that you have the neccesary linux-headers package installed. After a shitload of "no symbol version for module_layout" errors while trying various workarounds, this was a relief.
Written on May 19, 2010
Filed under