<ARM嵌入式Linux系统开发详解>清华大学出版社
又一本清華大學出版社的垃圾....
在網路上可以找到一字不差的內容,例如:
https://wenku.baidu.com/view/3c1097d5b9f3f90f76c61b15.html?re=view是翻譯自一份陳舊的 kernel 文件:
https://lwn.net/Articles/21835/ Kbuild recognises objects used for composite objects by the suffix
-objs, and the suffix -y. This allows the Makefiles to use
the value of a CONFIG_ symbol to determine if an object is part
of a composite object.
Example:
#fs/ext2/Makefile
obj-$(CONFIG_EXT2_FS) += ext2.o
ext2-y := balloc.o bitmap.o
ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o
In this example xattr.o is only 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,
the syntax above will also work. So, if you have CONFIG_EXT2_FS=y,
kbuild will build an ext2.o file for you out of the individual
parts and then link this into built-in.o, as you would expect.
正確的翻譯如下(請容許我多用繁體用語):
Kbuild 是使用後綴 -objs 及 -y 來識別哪些目的檔將作為合成目的檔。
這使 Makefile 能夠藉由 CONFIG_ 符號值,來判定某目的檔是否是合成目的檔的一部分。
在這項範例裡,若 $(CONFIG_EXT2_FS_XATTR) 為 'y',
xattr.o 才會成為合成目的檔 ext2.o 的一部分。
注意:當然,若你是將目的檔組建至內核裡,前述語法也同樣有效。
所以,如果你使用 CONFIG_EXT2_FS=y,kbuild 便會將多個部分組建成一個 ext2.o
並連結至 built-in.o,正如你所期待的結果。
至於最新的原文文件在此:
https://www.kernel.org/doc/Documentation/kbuild/makefiles.txt Due to kbuild recognizing $(<module_name>-y) for composite objects,
you can use the value of a CONFIG_ symbol to optionally include an
object file as part of a composite object.
Example:
#fs/ext2/Makefile
obj-$(CONFIG_EXT2_FS) += ext2.o
ext2-y := balloc.o dir.o file.o ialloc.o inode.o ioctl.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, xattr_user.o and xattr_trusted.o are only
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,
the syntax above will also work. So, if you have CONFIG_EXT2_FS=y,
kbuild will build an ext2.o file for you out of the individual
parts and then link this into built-in.o, as you would expect.
對應翻譯如下:
由於 kbuild 會透過 $(<module_name>-y) 來識別合成目的檔,
所以你可以使用 CONFIG_ 符號值,來選擇性的指定某個目的檔,
是否將作為合成目的檔的一部分。
在這項範例裡,只有當 $(CONFIG_EXT2_FS_XATTR) 為 'y' 時,
xattr.o、xattr_user.o 及 xattr_trusted.o 才會成為 ext2.o 合成目的檔的一部分。
注意:當然,若你是將目的檔組建至內核裡,前述語法也同樣有效。
所以,如果你使用 CONFIG_EXT2_FS=y,kbuild 便會將多個部分組建成一個 ext2.o
並連結至 built-in.o,正如你所期待的結果。