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