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