Jee*_*tel 21 c linux makefile linux-kernel
我理解的意思
obj-$(CONFIG_USB) += usb.o
Run Code Online (Sandbox Code Playgroud)
如果CONFIG_USB是y,那么usb.o将被编译.那么现在该如何理解这一点
obj-y += something/
Run Code Online (Sandbox Code Playgroud)
Pet*_*ter 43
内核Makefile是kbuild系统的一部分,记录在Web上的各个位置,例如http://lwn.net/Articles/21835/.相关摘录如下:
Run Code Online (Sandbox Code Playgroud)--- 3.1 Goal definitions目标定义是kbuild Makefile的主要部分(核心).这些行定义要构建的文件,任何特殊编译选项以及递归输入的所有子目录.
最简单的kbuild makefile包含一行:
示例:obj-y + = foo.o
这告诉kbuild该目录中有一个名为foo.o的对象.foo.o将从foo.c或foo.S构建.
如果将foo.o构建为模块,则使用变量obj-m.因此,经常使用以下模式:
示例:obj - $(CONFIG_FOO)+ = foo.o
$(CONFIG_FOO)计算为y(对于内置)或m(对于模块).如果CONFIG_FOO既不是y也不是m,那么该文件将不会被编译也不会被链接.
所以m意味着模块,y是指内置(代表在内核配置过程是),和$(CONFIG_FOO)是直接从正常的配置过程中的正确答案.
小智 8
obj-y + =某事/
这意味着kbuild应该进入"某事"目录.一旦它移动到这个目录,它会在"某事物"中查看Makefile以决定应该构建哪些对象.
这类似于说 - 去目录"某事"并执行"make"
您的问题似乎是将整个目录添加为目标的原因,KConfig文档的相关部分是:
--- 3.6 Descending down in directories
A Makefile is only responsible for building objects in its own
directory. Files in subdirectories should be taken care of by
Makefiles in these subdirs. The build system will automatically
invoke make recursively in subdirectories, provided you let it know of
them.
To do so obj-y and obj-m are used.
ext2 lives in a separate directory, and the Makefile present in fs/
tells kbuild to descend down using the following assignment.
Example:
#fs/Makefile
obj-$(CONfIG_EXT2_FS) += ext2/
If CONFIG_EXT2_FS is set to either 'y' (built-in) or 'm' (modular)
the corresponding obj- variable will be set, and kbuild will descend
down in the ext2 directory.
Kbuild only uses this information to decide that it needs to visit
the directory, it is the Makefile in the subdirectory that
specifies what is modules and what is built-in.
It is good practice to use a CONFIG_ variable when assigning directory
names. This allows kbuild to totally skip the directory if the
corresponding CONFIG_ option is neither 'y' nor 'm'.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25321 次 |
| 最近记录: |