linux系统如果想在系统配置界面make menuconfig时增加自定义配置及代码,基本步骤是:
1.找到相应增加代码路径下的Kconfig文件;
2.按需求添加配置选项;
3.找到相应路径下的Makefile文件,将自己代码的.o文件添加进去,使其可以编译到内核;
4.kernel目录下 执行 make menuconfig,找到自己添加的菜单进行选择;
步骤及每步含义如下,拿intel i210网卡驱动为例:
-
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时,界面显示的配置选项 -
在相应目录下Makefile里边添加编译语句:与Kconfig同目录
obj- ( C O N F I G