Kconfig和Makefile的编写例子

从Kconfig中读出菜单,用户选择后保存到.config的内核配置文件中。在内核编译时,主Makefile调用这个.config,就知道了用户的选择。Kconfig就是对应着内核的配置菜单。如果要想添加新的驱动到内核的源码中,可以修改Kconfig,这样就可以选择这个驱动,如果想使这个驱动被编译,要修改Makefile

代码位置:\kernel\drivers\input\touchscreen

Kconfig和Makefile的编写例子_第1张图片

#
# Touchscreen driver configuration
#
menuconfig INPUT_TOUCHSCREEN
 bool "Touchscreens"
 help                 //帮助信息,提供给用户一些提示信息
   Say Y here, and a list of supported touchscreens will be displayed.
   This option doesn't affect the kernel.

   If unsure, say Y.

if INPUT_TOUCHSCREEN

config TOUCHSCREEN_88PM860X        //在Makefile中添加:obj-$(CONFIG_TOUCHSCREEN_88PM860X) += 88pm860x-ts.o
 tristate "Marvell 88PM860x touchscreen"
 depends on MFD_88PM860X
 help                    //帮助信息,提供给用户一些提示信息
   Say Y here if you have a 88PM860x PMIC and want to enable
   support for the built-in touchscreen.

   If unsure, say N.

   To compile this driver as a module, choose M here: the
   module will be called 88pm860x-ts.

config TOUCHSCREEN_ADS7846          //在Makefile中添加:obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o
 tristate "ADS7846/TSC2046/AD7873 and AD(S)7843 based touchscreens"
 depends on SPI_MASTER
 depends on HWMON = n || HWMON
 help                       //帮助信息,提供给用户一些提示信息
   Say Y here if you have a touchscreen interface using the
   ADS7846/TSC2046/AD7873 or ADS7843/AD7843 controller,
   and your board-specific setup code includes that in its
   table of SPI devices.

   If HWMON is selected, and the driver is told the reference voltage
   on your board, you will also get hwmon interfaces for the voltage
   (and on ads7846/tsc2046/ad7873, temperature) sensors of this chip.

   If unsure, say N (but it's safe to say "Y").

   To compile this driver as a module, choose M here: the
   module will be called ads7846.

config TOUCHSCREEN_AD7877        //在Makefile中添加:  obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o
 tristate "AD7877 based touchscreens"
 depends on SPI_MASTER
 help                                       //帮助信息,提供给用户一些提示信息
   Say Y here if you have a touchscreen interface using the
   AD7877 controller, and your board-specific initialization
   code includes that in its table of SPI devices.

   If unsure, say N (but it's safe to say "Y").

   To compile this driver as a module, choose M here: the
   module will be called ad7877.

相应的Makefile文件:

/***************************************************************************************************

#
# Makefile for the touchscreen drivers.
#

# Each configuration option enables a list of files.

wm97xx-ts-y := wm97xx-core.o

obj-$(CONFIG_TOUCHSCREEN_88PM860X) += 88pm860x-ts.o
obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o
obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o
obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o

***************************************************************************************************/

你可能感兴趣的:(Module,input,interface,makefile,reference,initialization)