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