Purpose: Many times you will be in a situation where you need to compile out-of-tree kernel modules, meaning that the kernel you are currently running does not have the required module in it (say squashfs, ndiswrapper, etc). In such a situation, one typically needs to download sources from somewhere else and then compile them against running kernel. In this post we are not going to talk about how to do the entire process, rather I will highlight some tips and tricks that will allow you to overcome some of the common error messages that you will get while compiling the out-of-tree module.
Some common error messages that you get when you try to give the make command are as follows:
scripts/genksyms/genksyms: No such file or directory
/bin/sh: scripts/mod/modpost: not found
Kernel configuration is invalid. include/linux/autoconf.h or include/config/auto.conf are missing. Run ‘make oldconfig && make prepare’ on kernel src to fix it.
WARNING: Symbol version dump /usr/src/linux-2.6.29/Module.symvers is missing; module will have no dependencies and modversions.
Before you proceed, make sure you have the kernel sources installed against which you are going to build the modules.
In order to resolve any or all of the above error messages do the following:
# cd /lib/modules/2.6.29-1-686/
# ln -s /usr/src/linux-source-2.6.29 build
# cd /usr/src/linux-source-2.6.29
# make mrproper
# cp /boot/config-$(uname -r) .config
# make oldconfig
# make prepare
# make scripts
and then finally go to the directory where your sources resides (not the kernel sources) and give the make command:
# cd /usr/src/my-graphics-kernel-module-source/
# make clean
Note: Here we are assuming that you are trying to build the kernel module against the kernel that you are running. For example, suppose you are running kernel version 2.6.29-1-686 and you are trying to build the module for this running kernel.
Also if you do have kernel headers package installed for your running kernel then mostly likely you won’t be required to perform the above steps. Moreover, if you do have kernel headers installed then you do not need to have kernel sources installed. The kernel headers package is just a subset of the kernel source package.