1Linux 2.6.12 Documentation/kbuild/kconfig-language.txt 2 3Introduction 4------------ 5 6The configuration database is collection of configuration options 7organized in a tree structure: 8 9 +- Code maturity level options 10 | +- Prompt for development and/or incomplete code/drivers 11 +- General setup 12 | +- Networking support 13 | +- System V IPC 14 | +- BSD Process Accounting 15 | +- Sysctl support 16 +- Loadable module support 17 | +- Enable loadable module support 18 | +- Set version information on all module symbols 19 | +- Kernel module loader 20 +- ... 21 22Every entry has its own dependencies. These dependencies are used 23to determine the visibility of an entry. Any child entry is only 24visible if its parent entry is also visible. 25 26Menu entries 27------------ 28 29Most entries define a config option, all other entries help to organize 30them. A single configuration option is defined like this: 31 32config MODVERSIONS 33 bool "Set version information on all module symbols" 34 depends MODULES 35 help 36 Usually, modules have to be recompiled whenever you switch to a new 37 kernel. ... 38 39Every line starts with a key word and can be followed by multiple 40arguments. "config" starts a new config entry. The following lines 41define attributes for this config option. Attributes can be the type of 42the config option, input prompt, dependencies, help text and default 43values. A config option can be defined multiple times with the same 44name, but every definition can have only a single input prompt and the 45type must not conflict. 46 47Menu attributes 48--------------- 49 50A menu entry can have a number of attributes. Not all of them are 51applicable everywhere (see syntax). 52 53- type definition: "bool"/"tristate"/"string"/"hex"/"int" 54 Every config option must have a type. There are only two basic types: 55 tristate and string, the other types are based on these two. The type 56 definition optionally accepts an input prompt, so these two examples 57 are equivalent: 58 59 bool "Networking support" 60 and 61 bool 62 prompt "Networking support" 63 64- input prompt: "prompt" <prompt> ["if" <expr>] 65 Every menu entry can have at most one prompt, which is used to display 66 to the user. Optionally dependencies only for this prompt can be added 67 with "if". 68 69- default value: "default" <expr> ["if" <expr>] 70 A config option can have any number of default values. If multiple 71 default values are visible, only the first defined one is active. 72 Default values are not limited to the menu entry, where they are 73 defined, this means the default can be defined somewhere else or be 74 overridden by an earlier definition. 75 The default value is only assigned to the config symbol if no other 76 value was set by the user (via the input prompt above). If an input 77 prompt is visible the default value is presented to the user and can 78 be overridden by him. 79 Optionally dependencies only for this default value can be added with 80 "if". 81 82- dependencies: "depends on"/"requires" <expr> 83 This defines a dependency for this menu entry. If multiple 84 dependencies are defined they are connected with '&&'. Dependencies 85 are applied to all other options within this menu entry (which also 86 accept an "if" expression), so these two examples are equivalent: 87 88 bool "foo" if BAR 89 default y if BAR 90 and 91 depends on BAR 92 bool "foo" 93 default y 94 95- reverse dependencies: "select" <symbol> ["if" <expr>] 96 While normal dependencies reduce the upper limit of a symbol (see 97 below), reverse dependencies can be used to force a lower limit of 98 another symbol. The value of the current menu symbol is used as the 99 minimal value <symbol> can be set to. If <symbol> is selected multiple 100 times, the limit is set to the largest selection. 101 Reverse dependencies can only be used with boolean or tristate 102 symbols. 103 104- numerical ranges: "range" <symbol> <symbol> ["if" <expr>] 105 This allows to limit the range of possible input values for int 106 and hex symbols. The user can only input a value which is larger than 107 or equal to the first symbol and smaller than or equal to the second 108 symbol. 109 110- help text: "help" or "---help---" 111 This defines a help text. The end of the help text is determined by 112 the indentation level, this means it ends at the first line which has 113 a smaller indentation than the first line of the help text. 114 "---help---" and "help" do not differ in behaviour, "---help---" is 115 used to help visually seperate configuration logic from help within 116 the file as an aid to developers. 117 118 119Menu dependencies 120----------------- 121 122Dependencies define the visibility of a menu entry and can also reduce 123the input range of tristate symbols. The tristate logic used in the 124expressions uses one more state than normal boolean logic to express the 125module state. Dependency expressions have the following syntax: 126 127<expr> ::= <symbol> (1) 128 <symbol> '=' <symbol> (2) 129 <symbol> '!=' <symbol> (3) 130 '(' <expr> ')' (4) 131 '!' <expr> (5) 132 <expr> '&&' <expr> (6) 133 <expr> '||' <expr> (7) 134 135Expressions are listed in decreasing order of precedence. 136 137(1) Convert the symbol into an expression. Boolean and tristate symbols 138 are simply converted into the respective expression values. All 139 other symbol types result in 'n'. 140(2) If the values of both symbols are equal, it returns 'y', 141 otherwise 'n'. 142(3) If the values of both symbols are equal, it returns 'n', 143 otherwise 'y'. 144(4) Returns the value of the expression. Used to override precedence. 145(5) Returns the result of (2-/expr/). 146(6) Returns the result of min(/expr/, /expr/). 147(7) Returns the result of max(/expr/, /expr/). 148 149An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 150respectively for calculations). A menu entry becomes visible when it's 151expression evaluates to 'm' or 'y'. 152 153There are two types of symbols: constant and nonconstant symbols. 154Nonconstant symbols are the most common ones and are defined with the 155'config' statement. Nonconstant symbols consist entirely of alphanumeric 156characters or underscores. 157Constant symbols are only part of expressions. Constant symbols are 158always surrounded by single or double quotes. Within the quote any 159other character is allowed and the quotes can be escaped using '\'. 160 161Menu structure 162-------------- 163 164The position of a menu entry in the tree is determined in two ways. First 165it can be specified explicitly: 166 167menu "Network device support" 168 depends NET 169 170config NETDEVICES 171 ... 172 173endmenu 174 175All entries within the "menu" ... "endmenu" block become a submenu of 176"Network device support". All subentries inherit the dependencies from 177the menu entry, e.g. this means the dependency "NET" is added to the 178dependency list of the config option NETDEVICES. 179 180The other way to generate the menu structure is done by analyzing the 181dependencies. If a menu entry somehow depends on the previous entry, it 182can be made a submenu of it. First, the previous (parent) symbol must 183be part of the dependency list and then one of these two conditions 184must be true: 185- the child entry must become invisible, if the parent is set to 'n' 186- the child entry must only be visible, if the parent is visible 187 188config MODULES 189 bool "Enable loadable module support" 190 191config MODVERSIONS 192 bool "Set version information on all module symbols" 193 depends MODULES 194 195comment "module support disabled" 196 depends !MODULES 197 198MODVERSIONS directly depends on MODULES, this means it's only visible if 199MODULES is different from 'n'. The comment on the other hand is always 200visible when MODULES is visible (the (empty) dependency of MODULES is 201also part of the comment dependencies). 202 203 204Kconfig syntax 205-------------- 206 207The configuration file describes a series of menu entries, where every 208line starts with a keyword (except help texts). The following keywords 209end a menu entry: 210- config 211- menuconfig 212- choice/endchoice 213- comment 214- menu/endmenu 215- if/endif 216- source 217The first five also start the definition of a menu entry. 218 219config: 220 221 "config" <symbol> 222 <config options> 223 224This defines a config symbol <symbol> and accepts any of above 225attributes as options. 226 227menuconfig: 228 "menuconfig" <symbol> 229 <config options> 230 231This is similiar to the simple config entry above, but it also gives a 232hint to front ends, that all suboptions should be displayed as a 233separate list of options. 234 235choices: 236 237 "choice" 238 <choice options> 239 <choice block> 240 "endchoice" 241 242This defines a choice group and accepts any of above attributes as 243options. A choice can only be of type bool or tristate, while a boolean 244choice only allows a single config entry to be selected, a tristate 245choice also allows any number of config entries to be set to 'm'. This 246can be used if multiple drivers for a single hardware exists and only a 247single driver can be compiled/loaded into the kernel, but all drivers 248can be compiled as modules. 249A choice accepts another option "optional", which allows to set the 250choice to 'n' and no entry needs to be selected. 251 252comment: 253 254 "comment" <prompt> 255 <comment options> 256 257This defines a comment which is displayed to the user during the 258configuration process and is also echoed to the output files. The only 259possible options are dependencies. 260 261menu: 262 263 "menu" <prompt> 264 <menu options> 265 <menu block> 266 "endmenu" 267 268This defines a menu block, see "Menu structure" above for more 269information. The only possible options are dependencies. 270 271if: 272 273 "if" <expr> 274 <if block> 275 "endif" 276 277This defines an if block. The dependency expression <expr> is appended 278to all enclosed menu entries. 279 280source: 281 282 "source" <prompt> 283 284This reads the specified configuration file. This file is always parsed. 285