How to Build External Modules
-----------------------------
To build external modules, you must have a prebuilt kernel available that contains
the configuration and header files used in the build. Also, the kernel must have been
built with modules enabled.
Radix cross Linux provides a 'kernel-source' package installed here.
This kernel source not ready for build modules out-of-tree because Radix cross Linux
provides only cross-compiled packages.
To prepare kernel source you have to do following:
$ cd /usr/src/@KERNEL_SOURCE@
$ make oldconfig
$ make modules_prepare
If you are using a Radix cross Linux distribution kernel,
there will be a 'kernel-source' package for the kernel you are running provided by
Radix cross Linux distribution.
This will make sure the kernel contains the information required. The target exists
solely as a simple way to prepare a kernel source tree for building external modules.
NOTE: 'modules_prepare' will not build Module.symvers even if CONFIG_MODVERSIONS is set;
therefore, a full kernel build needs to be executed to make module versioning work.
Command Syntax
--------------
The command to build an external module is:
$ make -C <path_to_kernel_src> M=$PWD
The kbuild system knows that an external module is being built due to the 'M=<dir>'
option given in the command.
To build against the running kernel use:
$ make -C /lib/modules/`uname -r`/build M=$PWD
Then to install the module(s) just built, add the target 'modules_install' to the command:
$ make -C /lib/modules/`uname -r`/build M=$PWD modules_install
For mode details please look at
https://www.kernel.org/doc/html/latest/kbuild/modules.html
page.