B21 A Sample Configuration File
The syntax of the configuration files is not especially complicated as the following (slightly modified) example taken from the USB subsystem shows:
# USB device configuration
menuconfig "USB support"
bool "USB support" depends on HAS_IOMEM default y ---help---
This option adds core support for Universal Serial Bus (USB).
You will also need drivers from the following menu to make use of it.
config USB_ARCH_HAS_HCD boolean default y if USB_ARCH_HAS_OHCI default PCI
config USB_ARCH_HAS_OHCI boolean
default y if SA1111 default y if ARCH_OMAP
default y if STB03xxx default y if PPC_MPC52xx
default y if SOC_AU1X00
# more: default PCI
tristate "Support for USB" depends on USB_ARCH_HAS_HCD ---help---
Universal Serial Bus (USB) is a specification for a serial bus subsystem which offers higher speeds and more features than the traditional PC serial port. The bus supplies power to peripherals source "drivers/usb/core/Kconfig" source "drivers/usb/host/Kconfig"
comment "USB port drivers" depends on USB
tristate "USS720 parport driver" depends on USB && PARPORT ---help---
This driver is for USB parallel port adapters that use the Lucent Technologies USS-720 chip. These cables are plugged into your USB port and provide USB compatibility to peripherals designed with parallel port interfaces.
source "drivers/usb/gadget/Kconfig" endif # USB_SUPPORT
Figure B-2 illustrates how the defined tree structure is displayed on screen to enable users to select the options they want.
menuconfig generates a menu item whose heading is given as a string — in this case USB support. When users configure the kernel with make menuconfig or the graphical equivalent make xconfig or make gconfig, this item appears as the root of a new subtree. The choice is stored in a variable, in this case usb_support, and two values are possible because the choice is Boolean, as indicated by bool. If usb_support is deselected, then no further customization options will appear in the configuration tree, which is ensured by the if clause.
source enables further configuration files to be linked in (by convention, they are all named Kconfig). Their contents are interpreted as if the text they contain were held in the configuration file into which they are linked.
comment creates a comment in the list of configuration options. The comment text is displayed, but users cannot make a selection.
The actual configuration options are specified with config. There is just one entry of this kind for each option. The string following config is known as a configuration symbol and accepts the user selection. Each option requires a type to define the kind of selection that users can make. In this case, the selection type is tristate; that is, one of three options can be selected — ''compiled in,''"modular," or ''do not compile.'' Depending on the choice made, the configuration symbol is assigned the value y, m, or n. In addition to tristate, the kernel provides other selection types, which are discussed later in this section.
Configuration option dependencies are specified by depends on. Other configuration symbols are passed to the statement as parameters, and they can be linked using the logical operators used in C (&& = ''and'', || = ''or'', and ! = ''logical negation''). The menu item is not displayed unless the specified precondition is satisfied.
The - -help—2 entry indicates that the text after it is help text that users can display if they are not sure of the meaning of the configuration entry. The end of the help text is indicated by a change in indentation so that the kernel knows it is again dealing with normal configuration statements.
Two configuration options are shown in the example. The first defines the USB configuration symbol on which all other configuration entries depend. However, this choice is not displayed unless a host controller for USB can be presented. This is dependent on the usb_arch_has_hcd configuration option that may be either true or false. There are different ways of assigning a true value to the option — the following two are shown in the example:
□ Direct support is available for a host controller chipset (OHCI in the example).
□ The PCI bus is supported (the PCI symbol has a true value).
Support for the OHCI chipset is available if usb_arch_has_ohci is set. This is always the case when the PCI bus is supported. However, various systems use the chipset without PCI support. These are explicitly listed and include, for example, ARM-based machines and some PPC-based models.
The second configuration option (USS720) is dependent on two things. Support must be available not only for USB, but also for the parallel port. Otherwise, the driver option is not even displayed.
As the example shows, there may be dependencies between comments as well as between configuration options. The USB Port drivers entry is not displayed unless USB support is selected.
Generation of the configuration tree starts at arch/ arch/Kconfig, which must first be read by the configuration files. All other Kconfig files are linked in recursively from there by means of source.
Continue reading here: Menus
Was this article helpful?