Skip to content

Commit 803d505

Browse files
committed
kbuild: doc: drop section numbering, use references in modules.rst
Do similar to commit 1a4c1c9 ("docs/kbuild/makefiles: drop section numbering, use references"). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 7813cd6 commit 803d505

File tree

1 file changed

+51
-50
lines changed

1 file changed

+51
-50
lines changed

Documentation/kbuild/modules.rst

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Building External Modules
44

55
This document describes how to build an out-of-tree kernel module.
66

7-
1. Introduction
8-
===============
7+
Introduction
8+
============
99

1010
"kbuild" is the build system used by the Linux kernel. Modules must use
1111
kbuild to stay compatible with changes in the build infrastructure and
@@ -19,11 +19,11 @@ in building out-of-tree (or "external") modules. The author of an
1919
external module should supply a makefile that hides most of the
2020
complexity, so one only has to type "make" to build the module. This is
2121
easily accomplished, and a complete example will be presented in
22-
section 3.
22+
section `Creating a Kbuild File for an External Module`_.
2323

2424

25-
2. How to Build External Modules
26-
================================
25+
How to Build External Modules
26+
=============================
2727

2828
To build external modules, you must have a prebuilt kernel available
2929
that contains the configuration and header files used in the build.
@@ -40,8 +40,8 @@ NOTE: "modules_prepare" will not build Module.symvers even if
4040
CONFIG_MODVERSIONS is set; therefore, a full kernel build needs to be
4141
executed to make module versioning work.
4242

43-
2.1 Command Syntax
44-
==================
43+
Command Syntax
44+
--------------
4545

4646
The command to build an external module is::
4747

@@ -59,8 +59,8 @@ executed to make module versioning work.
5959

6060
$ make -C /lib/modules/`uname -r`/build M=$PWD modules_install
6161

62-
2.2 Options
63-
===========
62+
Options
63+
-------
6464

6565
($KDIR refers to the path of the kernel source directory.)
6666

@@ -77,8 +77,8 @@ executed to make module versioning work.
7777
directory where the external module (kbuild file) is
7878
located.
7979

80-
2.3 Targets
81-
===========
80+
Targets
81+
-------
8282

8383
When building an external module, only a subset of the "make"
8484
targets are available.
@@ -100,16 +100,17 @@ executed to make module versioning work.
100100
modules_install
101101
Install the external module(s). The default location is
102102
/lib/modules/<kernel_release>/updates/, but a prefix may
103-
be added with INSTALL_MOD_PATH (discussed in section 5).
103+
be added with INSTALL_MOD_PATH (discussed in section
104+
`Module Installation`_).
104105

105106
clean
106107
Remove all generated files in the module directory only.
107108

108109
help
109110
List the available targets for external modules.
110111

111-
2.4 Building Separate Files
112-
===========================
112+
Building Separate Files
113+
-----------------------
113114

114115
It is possible to build single files that are part of a module.
115116
This works equally well for the kernel, a module, and even for
@@ -123,8 +124,8 @@ executed to make module versioning work.
123124
make -C $KDIR M=$PWD ./
124125

125126

126-
3. Creating a Kbuild File for an External Module
127-
================================================
127+
Creating a Kbuild File for an External Module
128+
=============================================
128129

129130
In the last section we saw the command to build a module for the
130131
running kernel. The module is not actually built, however, because a
@@ -153,8 +154,8 @@ module 8123.ko, which is built from the following files::
153154
8123_pci.c
154155
8123_bin.o_shipped <= Binary blob
155156

156-
3.1 Shared Makefile
157-
-------------------
157+
Shared Makefile
158+
---------------
158159

159160
An external module always includes a wrapper makefile that
160161
supports building the module using "make" with no arguments.
@@ -192,8 +193,8 @@ module 8123.ko, which is built from the following files::
192193
line; the second pass is by the kbuild system, which is
193194
initiated by the parameterized "make" in the default target.
194195

195-
3.2 Separate Kbuild File and Makefile
196-
-------------------------------------
196+
Separate Kbuild File and Makefile
197+
---------------------------------
197198

198199
Kbuild will first look for a file named "Kbuild", and if it is not
199200
found, it will then look for "Makefile". Utilizing a "Kbuild" file
@@ -220,8 +221,8 @@ module 8123.ko, which is built from the following files::
220221
consisting of several hundred lines, and here it really pays
221222
off to separate the kbuild part from the rest.
222223

223-
3.3 Binary Blobs
224-
----------------
224+
Binary Blobs
225+
------------
225226

226227
Some external modules need to include an object file as a blob.
227228
kbuild has support for this, but requires the blob file to be
@@ -240,8 +241,8 @@ module 8123.ko, which is built from the following files::
240241
files and the binary file, kbuild will pick up different rules
241242
when creating the object file for the module.
242243

243-
3.4 Building Multiple Modules
244-
=============================
244+
Building Multiple Modules
245+
-------------------------
245246

246247
kbuild supports building multiple modules with a single build
247248
file. For example, if you wanted to build two modules, foo.ko
@@ -254,8 +255,8 @@ module 8123.ko, which is built from the following files::
254255
It is that simple!
255256

256257

257-
4. Include Files
258-
================
258+
Include Files
259+
=============
259260

260261
Within the kernel, header files are kept in standard locations
261262
according to the following rule:
@@ -273,8 +274,8 @@ according to the following rule:
273274
include/scsi; and architecture specific headers are located
274275
under arch/$(SRCARCH)/include/.
275276

276-
4.1 Kernel Includes
277-
-------------------
277+
Kernel Includes
278+
---------------
278279

279280
To include a header file located under include/linux/, simply
280281
use::
@@ -284,8 +285,8 @@ according to the following rule:
284285
kbuild will add options to "gcc" so the relevant directories
285286
are searched.
286287

287-
4.2 Single Subdirectory
288-
-----------------------
288+
Single Subdirectory
289+
-------------------
289290

290291
External modules tend to place header files in a separate
291292
include/ directory where their source is located, although this
@@ -302,8 +303,8 @@ according to the following rule:
302303
ccflags-y := -I $(src)/include
303304
8123-y := 8123_if.o 8123_pci.o 8123_bin.o
304305

305-
4.3 Several Subdirectories
306-
--------------------------
306+
Several Subdirectories
307+
----------------------
307308

308309
kbuild can handle files that are spread over several directories.
309310
Consider the following example::
@@ -342,8 +343,8 @@ according to the following rule:
342343
file is located.
343344

344345

345-
5. Module Installation
346-
======================
346+
Module Installation
347+
===================
347348

348349
Modules which are included in the kernel are installed in the
349350
directory:
@@ -354,8 +355,8 @@ And external modules are installed in:
354355

355356
/lib/modules/$(KERNELRELEASE)/updates/
356357

357-
5.1 INSTALL_MOD_PATH
358-
--------------------
358+
INSTALL_MOD_PATH
359+
----------------
359360

360361
Above are the default directories but as always some level of
361362
customization is possible. A prefix can be added to the
@@ -369,8 +370,8 @@ And external modules are installed in:
369370
calling "make." This has effect when installing both in-tree
370371
and out-of-tree modules.
371372

372-
5.2 INSTALL_MOD_DIR
373-
-------------------
373+
INSTALL_MOD_DIR
374+
---------------
374375

375376
External modules are by default installed to a directory under
376377
/lib/modules/$(KERNELRELEASE)/updates/, but you may wish to
@@ -383,8 +384,8 @@ And external modules are installed in:
383384
=> Install dir: /lib/modules/$(KERNELRELEASE)/gandalf/
384385

385386

386-
6. Module Versioning
387-
====================
387+
Module Versioning
388+
=================
388389

389390
Module versioning is enabled by the CONFIG_MODVERSIONS tag, and is used
390391
as a simple ABI consistency check. A CRC value of the full prototype
@@ -396,8 +397,8 @@ module.
396397
Module.symvers contains a list of all exported symbols from a kernel
397398
build.
398399

399-
6.1 Symbols From the Kernel (vmlinux + modules)
400-
-----------------------------------------------
400+
Symbols From the Kernel (vmlinux + modules)
401+
-------------------------------------------
401402

402403
During a kernel build, a file named Module.symvers will be
403404
generated. Module.symvers contains all exported symbols from
@@ -421,8 +422,8 @@ build.
421422
1) It lists all exported symbols from vmlinux and all modules.
422423
2) It lists the CRC if CONFIG_MODVERSIONS is enabled.
423424

424-
6.2 Symbols and External Modules
425-
--------------------------------
425+
Symbols and External Modules
426+
----------------------------
426427

427428
When building an external module, the build system needs access
428429
to the symbols from the kernel to check if all external symbols
@@ -431,8 +432,8 @@ build.
431432
tree. During the MODPOST step, a new Module.symvers file will be
432433
written containing all exported symbols from that external module.
433434

434-
6.3 Symbols From Another External Module
435-
----------------------------------------
435+
Symbols From Another External Module
436+
------------------------------------
436437

437438
Sometimes, an external module uses exported symbols from
438439
another external module. Kbuild needs to have full knowledge of
@@ -472,11 +473,11 @@ build.
472473
initialization of its symbol tables.
473474

474475

475-
7. Tips & Tricks
476-
================
476+
Tips & Tricks
477+
=============
477478

478-
7.1 Testing for CONFIG_FOO_BAR
479-
------------------------------
479+
Testing for CONFIG_FOO_BAR
480+
--------------------------
480481

481482
Modules often need to check for certain `CONFIG_` options to
482483
decide if a specific feature is included in the module. In

0 commit comments

Comments
 (0)