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