modules.txt

来自「Linux Kernel 2.6.9 for OMAP1710」· 文本 代码 · 共 69 行

TXT
69
字号
For now this is a raw copy from the old Documentation/kbuild/modules.txt,which was removed in 2.6.0-test5.The information herein is correct but not complete.Installing modules in a non-standard location---------------------------------------------When the modules needs to be installed under another directorythe INSTALL_MOD_PATH can be used to prefix "/lib/modules" as seenin the following example:make INSTALL_MOD_PATH=/frodo modules_installThis will install the modules in the directory /frodo/lib/modules./frodo can be a NFS mounted filesystem on another machine, allowingout-of-the-box support for installation on remote machines.Compiling modules outside the official kernel---------------------------------------------Often modules are developed outside the official kernel.  To keep upwith changes in the build system the most portable way to compile amodule outside the kernel is to use the kernel build system,kbuild. Use the following command-line:make -C path/to/kernel/src M=$PWD modulesThis requires that a makefile exits made in accordance toDocumentation/kbuild/makefiles.txt. Read that file for more details onthe build system.The following is a short summary of how to write your Makefile to getyou up and running fast. Assuming your module will be calledyourmodule.ko, your code should be in yourmodule.c and your Makefileshould includeobj-m := yourmodule.oIf the code for your module is in multiple files that need to belinked, you need to tell the build system which files to compile. Inthe case of multiple files, none of these files can be namedyourmodule.c because doing so would cause a problem with the linkingstep. Assuming your code exists in file1.c, file2.c, and file3.c andyou want to build yourmodule.ko from them, your Makefile shouldincludeobj-m := yourmodule.oyourmodule-objs := file1.o file2.o file3.oNow for a final example to put it all together. Assuming theKERNEL_SOURCE environment variable is set to the directory where youcompiled the kernel, a simple Makefile that builds yourmodule.ko asdescribed above would look like# Tells the build system to build yourmodule.ko.obj-m := yourmodule.o# Tells the build system to build these object files and link them as# yourmodule.o, before building yourmodule.ko. This line can be left# out if all the code for your module is in one file, yourmodule.c. If# you are using multiple files, none of these files can be named# yourmodule.c.yourmodule-objs := file1.o file2.o file3.o# Invokes the kernel build system to come back to the current# directory and build yourmodule.ko.default:	make -C ${KERNEL_SOURCE} M=`pwd` modules

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?