aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authormatt mooney <mfm@muteddisk.com>2010-10-02 00:21:55 -0400
committerMichal Marek <mmarek@suse.cz>2010-10-05 12:44:39 -0400
commit5793210cb1a431f98c85803920d5ba1440c6246e (patch)
treef4a4bc9564dd2ffd53c34a9ef4c62b09dd5c797d /Documentation
parent9f02186c236ba4ce11ba4e50d5a756c53d56c29e (diff)
Documentation/kbuild: modules.txt cleanup
A few modifications done for consistency, such as adding the shell prompt for command line examples and trailing slash for directories. Also corrects the module include header and fixes a few grammar issues that I introduced. Signed-off-by: matt mooney <mfm@muteddisk.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/kbuild/modules.txt62
1 files changed, 32 insertions, 30 deletions
diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt
index b572db3c5fee..3fb39e0116b4 100644
--- a/Documentation/kbuild/modules.txt
+++ b/Documentation/kbuild/modules.txt
@@ -1,11 +1,11 @@
1Building External Modules 1Building External Modules
2 2
3This document describes how-to build an out-of-tree kernel module. 3This document describes how to build an out-of-tree kernel module.
4 4
5=== Table of Contents 5=== Table of Contents
6 6
7 === 1 Introduction 7 === 1 Introduction
8 === 2 How-to Build External Modules 8 === 2 How to Build External Modules
9 --- 2.1 Command Syntax 9 --- 2.1 Command Syntax
10 --- 2.2 Options 10 --- 2.2 Options
11 --- 2.3 Targets 11 --- 2.3 Targets
@@ -48,9 +48,9 @@ easily accomplished, and a complete example will be presented in
48section 3. 48section 3.
49 49
50 50
51=== 2. How-to Build External Modules 51=== 2. How to Build External Modules
52 52
53To build external modules, you must have a pre-built kernel available 53To build external modules, you must have a prebuilt kernel available
54that contains the configuration and header files used in the build. 54that contains the configuration and header files used in the build.
55Also, the kernel must have been built with modules enabled. If you are 55Also, the kernel must have been built with modules enabled. If you are
56using a distribution kernel, there will be a package for the kernel you 56using a distribution kernel, there will be a package for the kernel you
@@ -69,19 +69,19 @@ executed to make module versioning work.
69 69
70 The command to build an external module is: 70 The command to build an external module is:
71 71
72 make -C <path_to_kernel_src> M=$PWD 72 $ make -C <path_to_kernel_src> M=$PWD
73 73
74 The kbuild system knows that an external module is being built 74 The kbuild system knows that an external module is being built
75 due to the "M=<dir>" option given in the command. 75 due to the "M=<dir>" option given in the command.
76 76
77 To build against the running kernel use: 77 To build against the running kernel use:
78 78
79 make -C /lib/modules/`uname -r`/build M=$PWD 79 $ make -C /lib/modules/`uname -r`/build M=$PWD
80 80
81 Then to install the module(s) just built, add the target 81 Then to install the module(s) just built, add the target
82 "modules_install" to the command: 82 "modules_install" to the command:
83 83
84 make -C /lib/modules/`uname -r`/build M=$PWD modules_install 84 $ make -C /lib/modules/`uname -r`/build M=$PWD modules_install
85 85
86--- 2.2 Options 86--- 2.2 Options
87 87
@@ -121,7 +121,7 @@ executed to make module versioning work.
121 121
122 modules_install 122 modules_install
123 Install the external module(s). The default location is 123 Install the external module(s). The default location is
124 /lib/modules/<kernel_release>/extra, but a prefix may 124 /lib/modules/<kernel_release>/extra/, but a prefix may
125 be added with INSTALL_MOD_PATH (discussed in section 5). 125 be added with INSTALL_MOD_PATH (discussed in section 5).
126 126
127 clean 127 clean
@@ -164,7 +164,7 @@ needed listing the files:
164NOTE: Further documentation describing the syntax used by kbuild is 164NOTE: Further documentation describing the syntax used by kbuild is
165located in Documentation/kbuild/makefiles.txt. 165located in Documentation/kbuild/makefiles.txt.
166 166
167The examples below demonstrate how-to create a build file for the 167The examples below demonstrate how to create a build file for the
168module 8123.ko, which is built from the following files: 168module 8123.ko, which is built from the following files:
169 169
170 8123_if.c 170 8123_if.c
@@ -205,14 +205,14 @@ module 8123.ko, which is built from the following files:
205 of the makefile. In the example, kbuild will only see the two 205 of the makefile. In the example, kbuild will only see the two
206 assignments, whereas "make" will see everything except these 206 assignments, whereas "make" will see everything except these
207 two assignments. This is due to two passes made on the file: 207 two assignments. This is due to two passes made on the file:
208 the first pass is by the "make" instance run on the 208 the first pass is by the "make" instance run on the command
209 command line; the second pass is by the kbuild system, which is 209 line; the second pass is by the kbuild system, which is
210 initiated by the parameterized "make" in the default target. 210 initiated by the parameterized "make" in the default target.
211 211
212--- 3.2 Separate Kbuild File and Makefile 212--- 3.2 Separate Kbuild File and Makefile
213 213
214 In newer versions of the kernel, kbuild will first look for a 214 In newer versions of the kernel, kbuild will first look for a
215 file named "Kbuild", and only if that is not found, will it 215 file named "Kbuild," and only if that is not found, will it
216 then look for a makefile. Utilizing a "Kbuild" file allows us 216 then look for a makefile. Utilizing a "Kbuild" file allows us
217 to split up the makefile from example 1 into two files: 217 to split up the makefile from example 1 into two files:
218 218
@@ -288,8 +288,8 @@ module 8123.ko, which is built from the following files:
288--- 3.4 Building Multiple Modules 288--- 3.4 Building Multiple Modules
289 289
290 kbuild supports building multiple modules with a single build 290 kbuild supports building multiple modules with a single build
291 file. For example, if you want to build two modules, foo and 291 file. For example, if you wanted to build two modules, foo.ko
292 bar, the kbuild lines would be: 292 and bar.ko, the kbuild lines would be:
293 293
294 obj-m := foo.o bar.o 294 obj-m := foo.o bar.o
295 foo-y := <foo_srcs> 295 foo-y := <foo_srcs>
@@ -320,7 +320,7 @@ according to the following rule:
320 To include a header file located under include/linux/, simply 320 To include a header file located under include/linux/, simply
321 use: 321 use:
322 322
323 #include <linux/modules.h> 323 #include <linux/module.h>
324 324
325 kbuild will add options to "gcc" so the relevant directories 325 kbuild will add options to "gcc" so the relevant directories
326 are searched. 326 are searched.
@@ -330,7 +330,7 @@ according to the following rule:
330 External modules tend to place header files in a separate 330 External modules tend to place header files in a separate
331 include/ directory where their source is located, although this 331 include/ directory where their source is located, although this
332 is not the usual kernel style. To inform kbuild of the 332 is not the usual kernel style. To inform kbuild of the
333 directory use either ccflags-y or CFLAGS_<filename>.o. 333 directory, use either ccflags-y or CFLAGS_<filename>.o.
334 334
335 Using the example from section 3, if we moved 8123_if.h to a 335 Using the example from section 3, if we moved 8123_if.h to a
336 subdirectory named include, the resulting kbuild file would 336 subdirectory named include, the resulting kbuild file would
@@ -390,11 +390,11 @@ according to the following rule:
390Modules which are included in the kernel are installed in the 390Modules which are included in the kernel are installed in the
391directory: 391directory:
392 392
393 /lib/modules/$(KERNELRELEASE)/kernel 393 /lib/modules/$(KERNELRELEASE)/kernel/
394 394
395And external modules are installed in: 395And external modules are installed in:
396 396
397 /lib/modules/$(KERNELRELEASE)/extra 397 /lib/modules/$(KERNELRELEASE)/extra/
398 398
399--- 5.1 INSTALL_MOD_PATH 399--- 5.1 INSTALL_MOD_PATH
400 400
@@ -403,7 +403,7 @@ And external modules are installed in:
403 installation path using the variable INSTALL_MOD_PATH: 403 installation path using the variable INSTALL_MOD_PATH:
404 404
405 $ make INSTALL_MOD_PATH=/frodo modules_install 405 $ make INSTALL_MOD_PATH=/frodo modules_install
406 => Install dir: /frodo/lib/modules/$(KERNELRELEASE)/kernel 406 => Install dir: /frodo/lib/modules/$(KERNELRELEASE)/kernel/
407 407
408 INSTALL_MOD_PATH may be set as an ordinary shell variable or, 408 INSTALL_MOD_PATH may be set as an ordinary shell variable or,
409 as shown above, can be specified on the command line when 409 as shown above, can be specified on the command line when
@@ -413,14 +413,14 @@ And external modules are installed in:
413--- 5.2 INSTALL_MOD_DIR 413--- 5.2 INSTALL_MOD_DIR
414 414
415 External modules are by default installed to a directory under 415 External modules are by default installed to a directory under
416 /lib/modules/$(KERNELRELEASE)/extra, but you may wish to locate 416 /lib/modules/$(KERNELRELEASE)/extra/, but you may wish to
417 modules for a specific functionality in a separate directory. 417 locate modules for a specific functionality in a separate
418 For this purpose, use INSTALL_MOD_DIR to specify an alternative 418 directory. For this purpose, use INSTALL_MOD_DIR to specify an
419 name to "extra." 419 alternative name to "extra."
420 420
421 $ make INSTALL_MOD_DIR=gandalf -C $KDIR \ 421 $ make INSTALL_MOD_DIR=gandalf -C $KDIR \
422 M=$PWD modules_install 422 M=$PWD modules_install
423 => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf 423 => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf/
424 424
425 425
426=== 6. Module Versioning 426=== 6. Module Versioning
@@ -478,9 +478,9 @@ build.
478 478
479 Use a top-level kbuild file 479 Use a top-level kbuild file
480 If you have two modules, foo.ko and bar.ko, where 480 If you have two modules, foo.ko and bar.ko, where
481 foo.ko needs symbols from bar.ko, then you can use a 481 foo.ko needs symbols from bar.ko, you can use a
482 common top-level kbuild file so both modules are 482 common top-level kbuild file so both modules are
483 compiled in the same build. Consider following 483 compiled in the same build. Consider the following
484 directory layout: 484 directory layout:
485 485
486 ./foo/ <= contains foo.ko 486 ./foo/ <= contains foo.ko
@@ -491,10 +491,11 @@ build.
491 #./Kbuild (or ./Makefile): 491 #./Kbuild (or ./Makefile):
492 obj-y := foo/ bar/ 492 obj-y := foo/ bar/
493 493
494 And executing: 494 And executing
495
495 $ make -C $KDIR M=$PWD 496 $ make -C $KDIR M=$PWD
496 497
497 Will then do the expected and compile both modules with 498 will then do the expected and compile both modules with
498 full knowledge of symbols from either module. 499 full knowledge of symbols from either module.
499 500
500 Use an extra Module.symvers file 501 Use an extra Module.symvers file
@@ -512,10 +513,11 @@ build.
512 Use "make" variable KBUILD_EXTRA_SYMBOLS 513 Use "make" variable KBUILD_EXTRA_SYMBOLS
513 If it is impractical to copy Module.symvers from 514 If it is impractical to copy Module.symvers from
514 another module, you can assign a space separated list 515 another module, you can assign a space separated list
515 of files to KBUILD_EXTRA_SYMBOLS in your build 516 of files to KBUILD_EXTRA_SYMBOLS in your build file.
516 file. These files will be loaded by modpost during the 517 These files will be loaded by modpost during the
517 initialization of its symbol tables. 518 initialization of its symbol tables.
518 519
520
519=== 7. Tips & Tricks 521=== 7. Tips & Tricks
520 522
521--- 7.1 Testing for CONFIG_FOO_BAR 523--- 7.1 Testing for CONFIG_FOO_BAR