1
0
Fork 0

Documentation: update kbuild loadable modules goals & examples

Update section 3.3 Loadable module goals - obj-m, from $(<module_name>-objs)
to $(<module_name>-y) for easier addition of conditional objects to the
module. The examples are also updated to reflect the current state of
each Makefile used.

Signed-off-by: matt mooney <mfm@muteddisk.com>
Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
hifive-unleashed-5.1
Matt Mooney 2010-08-05 11:23:11 -07:00 committed by Linus Torvalds
parent c7825cfac6
commit 4f82728027
1 changed files with 18 additions and 17 deletions

View File

@ -187,34 +187,35 @@ more details, with real examples.
Note: In this example $(CONFIG_ISDN_PPP_BSDCOMP) evaluates to 'm' Note: In this example $(CONFIG_ISDN_PPP_BSDCOMP) evaluates to 'm'
If a kernel module is built from several source files, you specify If a kernel module is built from several source files, you specify
that you want to build a module in the same way as above. that you want to build a module in the same way as above; however,
kbuild needs to know which object files you want to build your
Kbuild needs to know which the parts that you want to build your module from, so you have to tell it by setting a $(<module_name>-y)
module from, so you have to tell it by setting an variable.
$(<module_name>-objs) variable.
Example: Example:
#drivers/isdn/i4l/Makefile #drivers/isdn/i4l/Makefile
obj-$(CONFIG_ISDN) += isdn.o obj-$(CONFIG_ISDN_I4L) += isdn.o
isdn-objs := isdn_net_lib.o isdn_v110.o isdn_common.o isdn-y := isdn_net_lib.o isdn_v110.o isdn_common.o
In this example, the module name will be isdn.o. Kbuild will In this example, the module name will be isdn.o. Kbuild will
compile the objects listed in $(isdn-objs) and then run compile the objects listed in $(isdn-y) and then run
"$(LD) -r" on the list of these files to generate isdn.o. "$(LD) -r" on the list of these files to generate isdn.o.
Kbuild recognises objects used for composite objects by the suffix Due to kbuild recognizing $(<module_name>-y) for composite objects,
-objs, and the suffix -y. This allows the Makefiles to use you can use the value of a CONFIG_ symbol to optionally include an
the value of a CONFIG_ symbol to determine if an object is part object file as part of a composite object.
of a composite object.
Example: Example:
#fs/ext2/Makefile #fs/ext2/Makefile
obj-$(CONFIG_EXT2_FS) += ext2.o obj-$(CONFIG_EXT2_FS) += ext2.o
ext2-y := balloc.o bitmap.o ext2-y := balloc.o dir.o file.o ialloc.o inode.o ioctl.o \
ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o namei.o super.o symlink.o
ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o \
xattr_trusted.o
In this example, xattr.o is only part of the composite object In this example, xattr.o, xattr_user.o and xattr_trusted.o are only
ext2.o if $(CONFIG_EXT2_FS_XATTR) evaluates to 'y'. part of the composite object ext2.o if $(CONFIG_EXT2_FS_XATTR)
evaluates to 'y'.
Note: Of course, when you are building objects into the kernel, Note: Of course, when you are building objects into the kernel,
the syntax above will also work. So, if you have CONFIG_EXT2_FS=y, the syntax above will also work. So, if you have CONFIG_EXT2_FS=y,