I have this post written up so it can be linked to when users have problem building modules with my released kernel. A few users have got around a minor problem caused by apt-get and/or dpkg to build modules successfully. Below is a more detailed explanation.
In general, here is what we need to do to build modules. I'm using linux-headers-5.2.9-kirkwood-tld-2 kernel as an example.
Now at this point, the kernel header has been installed:
ls -l /usr/src
Note that the build folder is not created by apt-get install command above. This is a quirk with apt-get/dpkg. The build folder will be created only if you install the kernel and headers at the same time.
For example, this command will install both kernel and headers, and then create a symlink to the headers folder at the same time.
But when you install the kernel only, and then install the headers later, it will not create that symlink. So we have to do it manually:
Double check it:
ls -l /lib/modules/5.2.9-kirkwood-tld-2/
At this point you can proceed and build modules. The build enviroment has been set up properly.
When you build a particular module, that will also have its own build environment setup requirements. Things such as makefile or scripts, will be specific to that source code. If the build fails, you will need to investigate that particular source and its makefile/script to see if the build paths were set up propoerly.
In general, here is what we need to do to build modules. I'm using linux-headers-5.2.9-kirkwood-tld-2 kernel as an example.
apt-get install build-essential apt-get install linux-headers-5.2.9-kirkwood-tld-2_2.0_armel.deb
Now at this point, the kernel header has been installed:
ls -l /usr/src
drwxr-xr-x 23 root root 4096 Sep 2 19:25 linux-headers-5.2.9-kirkwood-tld-2
Note that the build folder is not created by apt-get install command above. This is a quirk with apt-get/dpkg. The build folder will be created only if you install the kernel and headers at the same time.
For example, this command will install both kernel and headers, and then create a symlink to the headers folder at the same time.
dpkg -i linux-image-5.2.9-kirkwood-tld-1_1.0_armel.deb linux-headers-5.2.9-kirkwood-tld-2_2.0_armel.deb
But when you install the kernel only, and then install the headers later, it will not create that symlink. So we have to do it manually:
ln -s /usr/src/linux-headers-5.2.9-kirkwood-tld-2/ /lib/modules/5.2.9-kirkwood-tld-2/build
Double check it:
ls -l /lib/modules/5.2.9-kirkwood-tld-2/
lrwxrwxrwx 1 root root 44 Sep 2 19:28 build -> /usr/src/linux-headers-5.2.9-kirkwood-tld-2/
At this point you can proceed and build modules. The build enviroment has been set up properly.
When you build a particular module, that will also have its own build environment setup requirements. Things such as makefile or scripts, will be specific to that source code. If the build fails, you will need to investigate that particular source and its makefile/script to see if the build paths were set up propoerly.