• Home
  • Raw
  • Download

Lines Matching +full:target +full:- +full:module

5 This document describes how to build an out-of-tree kernel module.
13 both in-tree and out-of-tree is provided. The method for building
15 out-of-tree.
18 in building out-of-tree (or "external") modules. The author of an
19 external module should supply a makefile that hides most of the
20 complexity, so one only has to type "make" to build the module. This is
22 section `Creating a Kbuild File for an External Module`_.
34 An alternative is to use the "make" target "modules_prepare." This will
35 make sure the kernel contains the information required. The target
39 NOTE: "modules_prepare" will not build Module.symvers even if
41 executed to make module versioning work.
44 --------------
46 The command to build an external module is::
48 $ make -C <path_to_kernel_dir> M=$PWD
50 The kbuild system knows that an external module is being built
55 $ make -C /lib/modules/`uname -r`/build M=$PWD
57 Then to install the module(s) just built, add the target
60 $ make -C /lib/modules/`uname -r`/build M=$PWD modules_install
63 -------
69 make -C $KDIR M=$PWD
71 -C $KDIR
73 artifacts used for building an external module.
78 Informs kbuild that an external module is being built.
80 directory where the external module (kbuild file) is
84 -------
86 When building an external module, only a subset of the "make"
89 make -C $KDIR M=$PWD [target]
91 The default will build the module(s) located in the current
92 directory, so a target does not need to be specified. All
99 The default target for external modules. It has the
100 same functionality as if no target was specified. See
104 Install the external module(s). The default location is
107 `Module Installation`_).
114 Remove all generated files in the module directory only.
120 -----------------------
122 It is possible to build single files that are part of a module.
123 This works equally well for the kernel, a module, and even for
126 Example (The module foo.ko, consist of bar.o and baz.o)::
128 make -C $KDIR M=$PWD bar.lst
129 make -C $KDIR M=$PWD baz.o
130 make -C $KDIR M=$PWD foo.ko
131 make -C $KDIR M=$PWD ./
134 Creating a Kbuild File for an External Module
137 In the last section we saw the command to build a module for the
138 running kernel. The module is not actually built, however, because a
140 the module(s) being built, along with the list of requisite source
143 obj-m := <module_name>.o
146 and, after linking, will result in the kernel module <module_name>.ko.
148 When the module is built from multiple sources, an additional line is
151 <module_name>-y := <src1>.o <src2>.o ...
157 module 8123.ko, which is built from the following files::
164 ---------------
166 An external module always includes a wrapper makefile that
167 supports building the module using "make" with no arguments.
168 This target is not used by kbuild; it is only for convenience.
175 --> filename: Makefile
178 obj-m := 8123.o
179 8123-y := 8123_if.o 8123_pci.o
183 KDIR ?= /lib/modules/`uname -r`/build
186 $(MAKE) -C $(KDIR) M=$$PWD
196 initiated by the parameterized "make" in the default target.
199 ---------------------------------
207 --> filename: Kbuild
208 obj-m := 8123.o
209 8123-y := 8123_if.o 8123_pci.o
211 --> filename: Makefile
212 KDIR ?= /lib/modules/`uname -r`/build
215 $(MAKE) -C $(KDIR) M=$$PWD
223 -------------------------
229 obj-m := foo.o bar.o
230 foo-y := <foo_srcs>
231 bar-y := <bar_srcs>
243 module, then the file is placed in the same directory as the
256 ---------------
261 #include <linux/module.h>
267 -------------------
272 directory, use either ccflags-y or CFLAGS_<filename>.o.
278 --> filename: Kbuild
279 obj-m := 8123.o
281 ccflags-y := -I $(src)/include
282 8123-y := 8123_if.o 8123_pci.o
285 ----------------------
300 To build the module complex.ko, we then need the following
303 --> filename: Kbuild
304 obj-m := complex.o
305 complex-y := src/complex_main.o
306 complex-y += src/hal/hardwareif.o
308 ccflags-y := -I$(src)/include
309 ccflags-y += -I$(src)/src/hal/include
318 root of the kernel tree (the argument to "-C") and therefore an
324 -------------------------
327 fashion to the in-tree counterpart drivers. kbuild supports
328 running headers_install target in an out-of-tree. The location
335 Module Installation
348 ----------------
359 calling "make." This has effect when installing both in-tree
360 and out-of-tree modules.
363 ---------------
371 $ make INSTALL_MOD_DIR=gandalf -C $KDIR \
376 Module Versioning
379 Module versioning is enabled by the CONFIG_MODVERSIONS tag, and is used
381 for an exported symbol is created. When a module is loaded/used, the
383 the module; if they are not equal, the kernel refuses to load the
384 module.
386 Module.symvers contains a list of all exported symbols from a kernel
390 -------------------------------------------
392 During a kernel build, a file named Module.symvers will be
393 generated. Module.symvers contains all exported symbols from
397 The syntax of the Module.symvers file is::
399 <CRC> <Symbol> <Module> <Export Type> <Namespace>
401 0xe1cc2a05 usb_stor_suspend drivers/usb/storage/usb-storage EXPORT_SYMBOL_GPL USB_STORAGE
409 Module.symvers serves two purposes:
415 ---------------------------
425 CRC stored in the __versions section of the importing module. This
431 section as a series of concatenated, null-terminated strings. CRCs for
435 ----------------------------
437 When building an external module, the build system needs access
440 the symbols by reading Module.symvers from the kernel source
441 tree. During the MODPOST step, a new Module.symvers file will be
442 written containing all exported symbols from that external module.
444 Symbols From Another External Module
445 ------------------------------------
447 Sometimes, an external module uses exported symbols from
448 another external module. Kbuild needs to have full knowledge of
452 NOTE: The method with a top-level kbuild file is recommended
455 Use a top-level kbuild file
458 common top-level kbuild file so both modules are
465 The top-level kbuild file would then look like::
468 obj-m := foo/ bar/
472 $ make -C $KDIR M=$PWD
475 full knowledge of symbols from either module.
478 If it is impractical to add a top-level kbuild file,
489 --------------------------
492 decide if a specific feature is included in the module. In
497 obj-$(CONFIG_EXT2_FS) += ext2.o
499 ext2-y := balloc.o bitmap.o dir.o
500 ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o