1. cat ./kernel/drivers/net/ethernet/intel/Kconfig
config e1000
config关键字是一个新的配置选项的入口
tristate “intel® pro/1000 gigabit ethernet support”
三态 y n m / 如果是bool “this is a test module” 这句话显示在menuconfig菜单上,显示为[]
depends on pci
依赖的模块
—help—
this driver supports intel® pro/1000 gigabit ethernet family of
adapters.for more information on how to identify your adapter, go
to the adapter & driver id guide at:......
to compile this driver as a module, choose m here. the module
will be called e1000.
这项配置是make menuconfig时,界面显示的配置选项
2. 在相应目录下Makefile里边添加编译语句:与Kconfig同目录
obj-$(CONFIG_E1000)+= e1000/
CONFIG_E1000这个变量与.config里边是对应的,值是:y n m
相应模块源码下要有编译此些源码的规则,也就是Makefile
obj-$(CONFIG_E1000)+= e1000.o
e1000-objs := e1000_main.o e1000_hw.o e1000_ethtool.o e1000_param.o
3. 在make menuconfig 里边选择某项 y后,保存到.config然后make 编译内核时.config会把相应(y/m)变量赋值给Makefile y/m,即选择是编译到内核还是以模块形式。