makefile 会根据当前目录的Kconfig来条件编译当前目录文件。
一。分析Makefile:
摘取一个Makefile如下
#
# Makefile for the i2c core.
#
obj-$(
CONFIG_I2C_BOARDINFO) += i2c-boardinfo.o
obj-$(CONFIG_I2C) += i2c-core.o
obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o
obj-y += busses/ chips/ algos/
ifeq ($(CONFIG_I2C_DEBUG_CORE),y)
EXTRA_CFLAGS += -DDEBUG
endif 看到
CONFIG_I2C_BOARDINFO这个会在Kconfig中定义,如果定义为了
config I2C_BOARDINFO
boolean
default y
表示默认编译这个文件到内核中,有3中情况:
分别表示了模块和静态编译,不编译3中,静态要编译进内核,Vmlinuz就出现这个模块。
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
其实想明白了就很简单的理解上去了,一句话:
Makefile根据Kconfig来选择性的编译当前目录的文件。
在Makefile中还有一种编译项:obj -y += busses/ chips/ algos/
表示直接无条件编译到内核。
Kconfig中
menuconfig I2C //执行make menuconfig 出现的条件菜单
tristate
"I2C support"
depends on HAS_IOMEM
---help---
I2C (pronounce: I-square-C)
is a slow serial bus protocol used
in
many micro controller applications and developed by Philips. SMBus,
or System Management Bus
is a subset of the I2C protocol. More
information
is contained
in the directory
,
especially
in the file called
"summary" there.
Both I2C and SMBus are supported here. You will need
this for
hardware sensors support, and also
for Video For Linux support.
If you want I2C support, you should say Y here and also to the
specific driver
for your bus adapter(s) below.
This I2C support can also be built
as a module. If so, the module
will be called i2c-core.
if I2C
config I2C_BOARDINFO
boolean
default y
config I2C_COMPAT
boolean
"Enable compatibility bits for old user-space"
default y
help
Say Y here
if you intend to run lm-sensors 3.1.1 or older, or any
other user-space package which expects i2c adapters to be
class
devices. If you don
't know, say Y.
config I2C_CHARDEV
tristate "I2C device interface"
help
Say Y here to use i2c-* device files, usually found in the /dev
directory on your system. They make it possible to have user-space
programs use the I2C bus. Information on how to do this is
contained in the file .
This support is also available as a module. If so, the module
will be called i2c-dev.
config I2C_HELPER_AUTO
bool "Autoselect pertinent helper modules"
default y
help
Some I2C bus drivers require so-called "I2C algorithm" modules
to work. These are basically software-only abstractions of generic
I2C interfaces. This option will autoselect them so that you don't
have to care.
Unselect
this only
if you need to enable additional helper
modules,
for example
for use with external I2C bus drivers.
In doubt, say Y.
source drivers/i2c/algos/Kconfig
source drivers/i2c/busses/Kconfig
source drivers/i2c/chips/Kconfig
config I2C_DEBUG_CORE
bool "I2C Core debugging messages"
help
Say Y here
if you want the I2C core to produce a bunch of debug
messages to the system log. Select
this if you are having a
problem with I2C support and want to see more of what
is going on.
config I2C_DEBUG_ALGO
bool "I2C Algorithm debugging messages"
help
Say Y here
if you want the I2C algorithm drivers to produce a bunch
of debug messages to the system log. Select
this if you are having
a problem with I2C support and want to see more of what
is going
on.
config I2C_DEBUG_BUS
bool "I2C Bus debugging messages"
help
Say Y here
if you want the I2C bus drivers to produce a bunch of
debug messages to the system log. Select
this if you are having
a problem with I2C support and want to see more of what
is going
on.
config I2C_DEBUG_CHIP
bool "I2C Chip debugging messages"
help
Say Y here
if you want the I2C chip drivers to produce a bunch of
debug messages to the system log. Select
this if you are having
a problem with I2C support and want to see more of what
is going
on.
endif # I2C
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
阅读(2237) | 评论(0) | 转发(0) |