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