1*4882a593Smuzhiyun================ 2*4882a593SmuzhiyunKconfig Language 3*4882a593Smuzhiyun================ 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunIntroduction 6*4882a593Smuzhiyun------------ 7*4882a593Smuzhiyun 8*4882a593SmuzhiyunThe configuration database is a collection of configuration options 9*4882a593Smuzhiyunorganized in a tree structure:: 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun +- Code maturity level options 12*4882a593Smuzhiyun | +- Prompt for development and/or incomplete code/drivers 13*4882a593Smuzhiyun +- General setup 14*4882a593Smuzhiyun | +- Networking support 15*4882a593Smuzhiyun | +- System V IPC 16*4882a593Smuzhiyun | +- BSD Process Accounting 17*4882a593Smuzhiyun | +- Sysctl support 18*4882a593Smuzhiyun +- Loadable module support 19*4882a593Smuzhiyun | +- Enable loadable module support 20*4882a593Smuzhiyun | +- Set version information on all module symbols 21*4882a593Smuzhiyun | +- Kernel module loader 22*4882a593Smuzhiyun +- ... 23*4882a593Smuzhiyun 24*4882a593SmuzhiyunEvery entry has its own dependencies. These dependencies are used 25*4882a593Smuzhiyunto determine the visibility of an entry. Any child entry is only 26*4882a593Smuzhiyunvisible if its parent entry is also visible. 27*4882a593Smuzhiyun 28*4882a593SmuzhiyunMenu entries 29*4882a593Smuzhiyun------------ 30*4882a593Smuzhiyun 31*4882a593SmuzhiyunMost entries define a config option; all other entries help to organize 32*4882a593Smuzhiyunthem. A single configuration option is defined like this:: 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun config MODVERSIONS 35*4882a593Smuzhiyun bool "Set version information on all module symbols" 36*4882a593Smuzhiyun depends on MODULES 37*4882a593Smuzhiyun help 38*4882a593Smuzhiyun Usually, modules have to be recompiled whenever you switch to a new 39*4882a593Smuzhiyun kernel. ... 40*4882a593Smuzhiyun 41*4882a593SmuzhiyunEvery line starts with a key word and can be followed by multiple 42*4882a593Smuzhiyunarguments. "config" starts a new config entry. The following lines 43*4882a593Smuzhiyundefine attributes for this config option. Attributes can be the type of 44*4882a593Smuzhiyunthe config option, input prompt, dependencies, help text and default 45*4882a593Smuzhiyunvalues. A config option can be defined multiple times with the same 46*4882a593Smuzhiyunname, but every definition can have only a single input prompt and the 47*4882a593Smuzhiyuntype must not conflict. 48*4882a593Smuzhiyun 49*4882a593SmuzhiyunMenu attributes 50*4882a593Smuzhiyun--------------- 51*4882a593Smuzhiyun 52*4882a593SmuzhiyunA menu entry can have a number of attributes. Not all of them are 53*4882a593Smuzhiyunapplicable everywhere (see syntax). 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun- type definition: "bool"/"tristate"/"string"/"hex"/"int" 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun Every config option must have a type. There are only two basic types: 58*4882a593Smuzhiyun tristate and string; the other types are based on these two. The type 59*4882a593Smuzhiyun definition optionally accepts an input prompt, so these two examples 60*4882a593Smuzhiyun are equivalent:: 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun bool "Networking support" 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun and:: 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun bool 67*4882a593Smuzhiyun prompt "Networking support" 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun- input prompt: "prompt" <prompt> ["if" <expr>] 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun Every menu entry can have at most one prompt, which is used to display 72*4882a593Smuzhiyun to the user. Optionally dependencies only for this prompt can be added 73*4882a593Smuzhiyun with "if". 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun- default value: "default" <expr> ["if" <expr>] 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun A config option can have any number of default values. If multiple 78*4882a593Smuzhiyun default values are visible, only the first defined one is active. 79*4882a593Smuzhiyun Default values are not limited to the menu entry where they are 80*4882a593Smuzhiyun defined. This means the default can be defined somewhere else or be 81*4882a593Smuzhiyun overridden by an earlier definition. 82*4882a593Smuzhiyun The default value is only assigned to the config symbol if no other 83*4882a593Smuzhiyun value was set by the user (via the input prompt above). If an input 84*4882a593Smuzhiyun prompt is visible the default value is presented to the user and can 85*4882a593Smuzhiyun be overridden by him. 86*4882a593Smuzhiyun Optionally, dependencies only for this default value can be added with 87*4882a593Smuzhiyun "if". 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun The default value deliberately defaults to 'n' in order to avoid bloating the 90*4882a593Smuzhiyun build. With few exceptions, new config options should not change this. The 91*4882a593Smuzhiyun intent is for "make oldconfig" to add as little as possible to the config from 92*4882a593Smuzhiyun release to release. 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun Note: 95*4882a593Smuzhiyun Things that merit "default y/m" include: 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun a) A new Kconfig option for something that used to always be built 98*4882a593Smuzhiyun should be "default y". 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun b) A new gatekeeping Kconfig option that hides/shows other Kconfig 101*4882a593Smuzhiyun options (but does not generate any code of its own), should be 102*4882a593Smuzhiyun "default y" so people will see those other options. 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun c) Sub-driver behavior or similar options for a driver that is 105*4882a593Smuzhiyun "default n". This allows you to provide sane defaults. 106*4882a593Smuzhiyun 107*4882a593Smuzhiyun d) Hardware or infrastructure that everybody expects, such as CONFIG_NET 108*4882a593Smuzhiyun or CONFIG_BLOCK. These are rare exceptions. 109*4882a593Smuzhiyun 110*4882a593Smuzhiyun- type definition + default value:: 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun "def_bool"/"def_tristate" <expr> ["if" <expr>] 113*4882a593Smuzhiyun 114*4882a593Smuzhiyun This is a shorthand notation for a type definition plus a value. 115*4882a593Smuzhiyun Optionally dependencies for this default value can be added with "if". 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun- dependencies: "depends on" <expr> 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun This defines a dependency for this menu entry. If multiple 120*4882a593Smuzhiyun dependencies are defined, they are connected with '&&'. Dependencies 121*4882a593Smuzhiyun are applied to all other options within this menu entry (which also 122*4882a593Smuzhiyun accept an "if" expression), so these two examples are equivalent:: 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun bool "foo" if BAR 125*4882a593Smuzhiyun default y if BAR 126*4882a593Smuzhiyun 127*4882a593Smuzhiyun and:: 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun depends on BAR 130*4882a593Smuzhiyun bool "foo" 131*4882a593Smuzhiyun default y 132*4882a593Smuzhiyun 133*4882a593Smuzhiyun- reverse dependencies: "select" <symbol> ["if" <expr>] 134*4882a593Smuzhiyun 135*4882a593Smuzhiyun While normal dependencies reduce the upper limit of a symbol (see 136*4882a593Smuzhiyun below), reverse dependencies can be used to force a lower limit of 137*4882a593Smuzhiyun another symbol. The value of the current menu symbol is used as the 138*4882a593Smuzhiyun minimal value <symbol> can be set to. If <symbol> is selected multiple 139*4882a593Smuzhiyun times, the limit is set to the largest selection. 140*4882a593Smuzhiyun Reverse dependencies can only be used with boolean or tristate 141*4882a593Smuzhiyun symbols. 142*4882a593Smuzhiyun 143*4882a593Smuzhiyun Note: 144*4882a593Smuzhiyun select should be used with care. select will force 145*4882a593Smuzhiyun a symbol to a value without visiting the dependencies. 146*4882a593Smuzhiyun By abusing select you are able to select a symbol FOO even 147*4882a593Smuzhiyun if FOO depends on BAR that is not set. 148*4882a593Smuzhiyun In general use select only for non-visible symbols 149*4882a593Smuzhiyun (no prompts anywhere) and for symbols with no dependencies. 150*4882a593Smuzhiyun That will limit the usefulness but on the other hand avoid 151*4882a593Smuzhiyun the illegal configurations all over. 152*4882a593Smuzhiyun 153*4882a593Smuzhiyun- weak reverse dependencies: "imply" <symbol> ["if" <expr>] 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun This is similar to "select" as it enforces a lower limit on another 156*4882a593Smuzhiyun symbol except that the "implied" symbol's value may still be set to n 157*4882a593Smuzhiyun from a direct dependency or with a visible prompt. 158*4882a593Smuzhiyun 159*4882a593Smuzhiyun Given the following example:: 160*4882a593Smuzhiyun 161*4882a593Smuzhiyun config FOO 162*4882a593Smuzhiyun tristate "foo" 163*4882a593Smuzhiyun imply BAZ 164*4882a593Smuzhiyun 165*4882a593Smuzhiyun config BAZ 166*4882a593Smuzhiyun tristate "baz" 167*4882a593Smuzhiyun depends on BAR 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun The following values are possible: 170*4882a593Smuzhiyun 171*4882a593Smuzhiyun === === ============= ============== 172*4882a593Smuzhiyun FOO BAR BAZ's default choice for BAZ 173*4882a593Smuzhiyun === === ============= ============== 174*4882a593Smuzhiyun n y n N/m/y 175*4882a593Smuzhiyun m y m M/y/n 176*4882a593Smuzhiyun y y y Y/m/n 177*4882a593Smuzhiyun n m n N/m 178*4882a593Smuzhiyun m m m M/n 179*4882a593Smuzhiyun y m n M/n 180*4882a593Smuzhiyun y n * N 181*4882a593Smuzhiyun === === ============= ============== 182*4882a593Smuzhiyun 183*4882a593Smuzhiyun This is useful e.g. with multiple drivers that want to indicate their 184*4882a593Smuzhiyun ability to hook into a secondary subsystem while allowing the user to 185*4882a593Smuzhiyun configure that subsystem out without also having to unset these drivers. 186*4882a593Smuzhiyun 187*4882a593Smuzhiyun Note: If the combination of FOO=y and BAR=m causes a link error, 188*4882a593Smuzhiyun you can guard the function call with IS_REACHABLE():: 189*4882a593Smuzhiyun 190*4882a593Smuzhiyun foo_init() 191*4882a593Smuzhiyun { 192*4882a593Smuzhiyun if (IS_REACHABLE(CONFIG_BAZ)) 193*4882a593Smuzhiyun baz_register(&foo); 194*4882a593Smuzhiyun ... 195*4882a593Smuzhiyun } 196*4882a593Smuzhiyun 197*4882a593Smuzhiyun Note: If the feature provided by BAZ is highly desirable for FOO, 198*4882a593Smuzhiyun FOO should imply not only BAZ, but also its dependency BAR:: 199*4882a593Smuzhiyun 200*4882a593Smuzhiyun config FOO 201*4882a593Smuzhiyun tristate "foo" 202*4882a593Smuzhiyun imply BAR 203*4882a593Smuzhiyun imply BAZ 204*4882a593Smuzhiyun 205*4882a593Smuzhiyun- limiting menu display: "visible if" <expr> 206*4882a593Smuzhiyun 207*4882a593Smuzhiyun This attribute is only applicable to menu blocks, if the condition is 208*4882a593Smuzhiyun false, the menu block is not displayed to the user (the symbols 209*4882a593Smuzhiyun contained there can still be selected by other symbols, though). It is 210*4882a593Smuzhiyun similar to a conditional "prompt" attribute for individual menu 211*4882a593Smuzhiyun entries. Default value of "visible" is true. 212*4882a593Smuzhiyun 213*4882a593Smuzhiyun- numerical ranges: "range" <symbol> <symbol> ["if" <expr>] 214*4882a593Smuzhiyun 215*4882a593Smuzhiyun This allows to limit the range of possible input values for int 216*4882a593Smuzhiyun and hex symbols. The user can only input a value which is larger than 217*4882a593Smuzhiyun or equal to the first symbol and smaller than or equal to the second 218*4882a593Smuzhiyun symbol. 219*4882a593Smuzhiyun 220*4882a593Smuzhiyun- help text: "help" 221*4882a593Smuzhiyun 222*4882a593Smuzhiyun This defines a help text. The end of the help text is determined by 223*4882a593Smuzhiyun the indentation level, this means it ends at the first line which has 224*4882a593Smuzhiyun a smaller indentation than the first line of the help text. 225*4882a593Smuzhiyun 226*4882a593Smuzhiyun- misc options: "option" <symbol>[=<value>] 227*4882a593Smuzhiyun 228*4882a593Smuzhiyun Various less common options can be defined via this option syntax, 229*4882a593Smuzhiyun which can modify the behaviour of the menu entry and its config 230*4882a593Smuzhiyun symbol. These options are currently possible: 231*4882a593Smuzhiyun 232*4882a593Smuzhiyun - "defconfig_list" 233*4882a593Smuzhiyun This declares a list of default entries which can be used when 234*4882a593Smuzhiyun looking for the default configuration (which is used when the main 235*4882a593Smuzhiyun .config doesn't exists yet.) 236*4882a593Smuzhiyun 237*4882a593Smuzhiyun - "modules" 238*4882a593Smuzhiyun This declares the symbol to be used as the MODULES symbol, which 239*4882a593Smuzhiyun enables the third modular state for all config symbols. 240*4882a593Smuzhiyun At most one symbol may have the "modules" option set. 241*4882a593Smuzhiyun 242*4882a593Smuzhiyun - "allnoconfig_y" 243*4882a593Smuzhiyun This declares the symbol as one that should have the value y when 244*4882a593Smuzhiyun using "allnoconfig". Used for symbols that hide other symbols. 245*4882a593Smuzhiyun 246*4882a593SmuzhiyunMenu dependencies 247*4882a593Smuzhiyun----------------- 248*4882a593Smuzhiyun 249*4882a593SmuzhiyunDependencies define the visibility of a menu entry and can also reduce 250*4882a593Smuzhiyunthe input range of tristate symbols. The tristate logic used in the 251*4882a593Smuzhiyunexpressions uses one more state than normal boolean logic to express the 252*4882a593Smuzhiyunmodule state. Dependency expressions have the following syntax:: 253*4882a593Smuzhiyun 254*4882a593Smuzhiyun <expr> ::= <symbol> (1) 255*4882a593Smuzhiyun <symbol> '=' <symbol> (2) 256*4882a593Smuzhiyun <symbol> '!=' <symbol> (3) 257*4882a593Smuzhiyun <symbol1> '<' <symbol2> (4) 258*4882a593Smuzhiyun <symbol1> '>' <symbol2> (4) 259*4882a593Smuzhiyun <symbol1> '<=' <symbol2> (4) 260*4882a593Smuzhiyun <symbol1> '>=' <symbol2> (4) 261*4882a593Smuzhiyun '(' <expr> ')' (5) 262*4882a593Smuzhiyun '!' <expr> (6) 263*4882a593Smuzhiyun <expr> '&&' <expr> (7) 264*4882a593Smuzhiyun <expr> '||' <expr> (8) 265*4882a593Smuzhiyun 266*4882a593SmuzhiyunExpressions are listed in decreasing order of precedence. 267*4882a593Smuzhiyun 268*4882a593Smuzhiyun(1) Convert the symbol into an expression. Boolean and tristate symbols 269*4882a593Smuzhiyun are simply converted into the respective expression values. All 270*4882a593Smuzhiyun other symbol types result in 'n'. 271*4882a593Smuzhiyun(2) If the values of both symbols are equal, it returns 'y', 272*4882a593Smuzhiyun otherwise 'n'. 273*4882a593Smuzhiyun(3) If the values of both symbols are equal, it returns 'n', 274*4882a593Smuzhiyun otherwise 'y'. 275*4882a593Smuzhiyun(4) If value of <symbol1> is respectively lower, greater, lower-or-equal, 276*4882a593Smuzhiyun or greater-or-equal than value of <symbol2>, it returns 'y', 277*4882a593Smuzhiyun otherwise 'n'. 278*4882a593Smuzhiyun(5) Returns the value of the expression. Used to override precedence. 279*4882a593Smuzhiyun(6) Returns the result of (2-/expr/). 280*4882a593Smuzhiyun(7) Returns the result of min(/expr/, /expr/). 281*4882a593Smuzhiyun(8) Returns the result of max(/expr/, /expr/). 282*4882a593Smuzhiyun 283*4882a593SmuzhiyunAn expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 284*4882a593Smuzhiyunrespectively for calculations). A menu entry becomes visible when its 285*4882a593Smuzhiyunexpression evaluates to 'm' or 'y'. 286*4882a593Smuzhiyun 287*4882a593SmuzhiyunThere are two types of symbols: constant and non-constant symbols. 288*4882a593SmuzhiyunNon-constant symbols are the most common ones and are defined with the 289*4882a593Smuzhiyun'config' statement. Non-constant symbols consist entirely of alphanumeric 290*4882a593Smuzhiyuncharacters or underscores. 291*4882a593SmuzhiyunConstant symbols are only part of expressions. Constant symbols are 292*4882a593Smuzhiyunalways surrounded by single or double quotes. Within the quote, any 293*4882a593Smuzhiyunother character is allowed and the quotes can be escaped using '\'. 294*4882a593Smuzhiyun 295*4882a593SmuzhiyunMenu structure 296*4882a593Smuzhiyun-------------- 297*4882a593Smuzhiyun 298*4882a593SmuzhiyunThe position of a menu entry in the tree is determined in two ways. First 299*4882a593Smuzhiyunit can be specified explicitly:: 300*4882a593Smuzhiyun 301*4882a593Smuzhiyun menu "Network device support" 302*4882a593Smuzhiyun depends on NET 303*4882a593Smuzhiyun 304*4882a593Smuzhiyun config NETDEVICES 305*4882a593Smuzhiyun ... 306*4882a593Smuzhiyun 307*4882a593Smuzhiyun endmenu 308*4882a593Smuzhiyun 309*4882a593SmuzhiyunAll entries within the "menu" ... "endmenu" block become a submenu of 310*4882a593Smuzhiyun"Network device support". All subentries inherit the dependencies from 311*4882a593Smuzhiyunthe menu entry, e.g. this means the dependency "NET" is added to the 312*4882a593Smuzhiyundependency list of the config option NETDEVICES. 313*4882a593Smuzhiyun 314*4882a593SmuzhiyunThe other way to generate the menu structure is done by analyzing the 315*4882a593Smuzhiyundependencies. If a menu entry somehow depends on the previous entry, it 316*4882a593Smuzhiyuncan be made a submenu of it. First, the previous (parent) symbol must 317*4882a593Smuzhiyunbe part of the dependency list and then one of these two conditions 318*4882a593Smuzhiyunmust be true: 319*4882a593Smuzhiyun 320*4882a593Smuzhiyun- the child entry must become invisible, if the parent is set to 'n' 321*4882a593Smuzhiyun- the child entry must only be visible, if the parent is visible:: 322*4882a593Smuzhiyun 323*4882a593Smuzhiyun config MODULES 324*4882a593Smuzhiyun bool "Enable loadable module support" 325*4882a593Smuzhiyun 326*4882a593Smuzhiyun config MODVERSIONS 327*4882a593Smuzhiyun bool "Set version information on all module symbols" 328*4882a593Smuzhiyun depends on MODULES 329*4882a593Smuzhiyun 330*4882a593Smuzhiyun comment "module support disabled" 331*4882a593Smuzhiyun depends on !MODULES 332*4882a593Smuzhiyun 333*4882a593SmuzhiyunMODVERSIONS directly depends on MODULES, this means it's only visible if 334*4882a593SmuzhiyunMODULES is different from 'n'. The comment on the other hand is only 335*4882a593Smuzhiyunvisible when MODULES is set to 'n'. 336*4882a593Smuzhiyun 337*4882a593Smuzhiyun 338*4882a593SmuzhiyunKconfig syntax 339*4882a593Smuzhiyun-------------- 340*4882a593Smuzhiyun 341*4882a593SmuzhiyunThe configuration file describes a series of menu entries, where every 342*4882a593Smuzhiyunline starts with a keyword (except help texts). The following keywords 343*4882a593Smuzhiyunend a menu entry: 344*4882a593Smuzhiyun 345*4882a593Smuzhiyun- config 346*4882a593Smuzhiyun- menuconfig 347*4882a593Smuzhiyun- choice/endchoice 348*4882a593Smuzhiyun- comment 349*4882a593Smuzhiyun- menu/endmenu 350*4882a593Smuzhiyun- if/endif 351*4882a593Smuzhiyun- source 352*4882a593Smuzhiyun 353*4882a593SmuzhiyunThe first five also start the definition of a menu entry. 354*4882a593Smuzhiyun 355*4882a593Smuzhiyunconfig:: 356*4882a593Smuzhiyun 357*4882a593Smuzhiyun "config" <symbol> 358*4882a593Smuzhiyun <config options> 359*4882a593Smuzhiyun 360*4882a593SmuzhiyunThis defines a config symbol <symbol> and accepts any of above 361*4882a593Smuzhiyunattributes as options. 362*4882a593Smuzhiyun 363*4882a593Smuzhiyunmenuconfig:: 364*4882a593Smuzhiyun 365*4882a593Smuzhiyun "menuconfig" <symbol> 366*4882a593Smuzhiyun <config options> 367*4882a593Smuzhiyun 368*4882a593SmuzhiyunThis is similar to the simple config entry above, but it also gives a 369*4882a593Smuzhiyunhint to front ends, that all suboptions should be displayed as a 370*4882a593Smuzhiyunseparate list of options. To make sure all the suboptions will really 371*4882a593Smuzhiyunshow up under the menuconfig entry and not outside of it, every item 372*4882a593Smuzhiyunfrom the <config options> list must depend on the menuconfig symbol. 373*4882a593SmuzhiyunIn practice, this is achieved by using one of the next two constructs:: 374*4882a593Smuzhiyun 375*4882a593Smuzhiyun (1): 376*4882a593Smuzhiyun menuconfig M 377*4882a593Smuzhiyun if M 378*4882a593Smuzhiyun config C1 379*4882a593Smuzhiyun config C2 380*4882a593Smuzhiyun endif 381*4882a593Smuzhiyun 382*4882a593Smuzhiyun (2): 383*4882a593Smuzhiyun menuconfig M 384*4882a593Smuzhiyun config C1 385*4882a593Smuzhiyun depends on M 386*4882a593Smuzhiyun config C2 387*4882a593Smuzhiyun depends on M 388*4882a593Smuzhiyun 389*4882a593SmuzhiyunIn the following examples (3) and (4), C1 and C2 still have the M 390*4882a593Smuzhiyundependency, but will not appear under menuconfig M anymore, because 391*4882a593Smuzhiyunof C0, which doesn't depend on M:: 392*4882a593Smuzhiyun 393*4882a593Smuzhiyun (3): 394*4882a593Smuzhiyun menuconfig M 395*4882a593Smuzhiyun config C0 396*4882a593Smuzhiyun if M 397*4882a593Smuzhiyun config C1 398*4882a593Smuzhiyun config C2 399*4882a593Smuzhiyun endif 400*4882a593Smuzhiyun 401*4882a593Smuzhiyun (4): 402*4882a593Smuzhiyun menuconfig M 403*4882a593Smuzhiyun config C0 404*4882a593Smuzhiyun config C1 405*4882a593Smuzhiyun depends on M 406*4882a593Smuzhiyun config C2 407*4882a593Smuzhiyun depends on M 408*4882a593Smuzhiyun 409*4882a593Smuzhiyunchoices:: 410*4882a593Smuzhiyun 411*4882a593Smuzhiyun "choice" [symbol] 412*4882a593Smuzhiyun <choice options> 413*4882a593Smuzhiyun <choice block> 414*4882a593Smuzhiyun "endchoice" 415*4882a593Smuzhiyun 416*4882a593SmuzhiyunThis defines a choice group and accepts any of the above attributes as 417*4882a593Smuzhiyunoptions. A choice can only be of type bool or tristate. If no type is 418*4882a593Smuzhiyunspecified for a choice, its type will be determined by the type of 419*4882a593Smuzhiyunthe first choice element in the group or remain unknown if none of the 420*4882a593Smuzhiyunchoice elements have a type specified, as well. 421*4882a593Smuzhiyun 422*4882a593SmuzhiyunWhile a boolean choice only allows a single config entry to be 423*4882a593Smuzhiyunselected, a tristate choice also allows any number of config entries 424*4882a593Smuzhiyunto be set to 'm'. This can be used if multiple drivers for a single 425*4882a593Smuzhiyunhardware exists and only a single driver can be compiled/loaded into 426*4882a593Smuzhiyunthe kernel, but all drivers can be compiled as modules. 427*4882a593Smuzhiyun 428*4882a593SmuzhiyunA choice accepts another option "optional", which allows to set the 429*4882a593Smuzhiyunchoice to 'n' and no entry needs to be selected. 430*4882a593SmuzhiyunIf no [symbol] is associated with a choice, then you can not have multiple 431*4882a593Smuzhiyundefinitions of that choice. If a [symbol] is associated to the choice, 432*4882a593Smuzhiyunthen you may define the same choice (i.e. with the same entries) in another 433*4882a593Smuzhiyunplace. 434*4882a593Smuzhiyun 435*4882a593Smuzhiyuncomment:: 436*4882a593Smuzhiyun 437*4882a593Smuzhiyun "comment" <prompt> 438*4882a593Smuzhiyun <comment options> 439*4882a593Smuzhiyun 440*4882a593SmuzhiyunThis defines a comment which is displayed to the user during the 441*4882a593Smuzhiyunconfiguration process and is also echoed to the output files. The only 442*4882a593Smuzhiyunpossible options are dependencies. 443*4882a593Smuzhiyun 444*4882a593Smuzhiyunmenu:: 445*4882a593Smuzhiyun 446*4882a593Smuzhiyun "menu" <prompt> 447*4882a593Smuzhiyun <menu options> 448*4882a593Smuzhiyun <menu block> 449*4882a593Smuzhiyun "endmenu" 450*4882a593Smuzhiyun 451*4882a593SmuzhiyunThis defines a menu block, see "Menu structure" above for more 452*4882a593Smuzhiyuninformation. The only possible options are dependencies and "visible" 453*4882a593Smuzhiyunattributes. 454*4882a593Smuzhiyun 455*4882a593Smuzhiyunif:: 456*4882a593Smuzhiyun 457*4882a593Smuzhiyun "if" <expr> 458*4882a593Smuzhiyun <if block> 459*4882a593Smuzhiyun "endif" 460*4882a593Smuzhiyun 461*4882a593SmuzhiyunThis defines an if block. The dependency expression <expr> is appended 462*4882a593Smuzhiyunto all enclosed menu entries. 463*4882a593Smuzhiyun 464*4882a593Smuzhiyunsource:: 465*4882a593Smuzhiyun 466*4882a593Smuzhiyun "source" <prompt> 467*4882a593Smuzhiyun 468*4882a593SmuzhiyunThis reads the specified configuration file. This file is always parsed. 469*4882a593Smuzhiyun 470*4882a593Smuzhiyunmainmenu:: 471*4882a593Smuzhiyun 472*4882a593Smuzhiyun "mainmenu" <prompt> 473*4882a593Smuzhiyun 474*4882a593SmuzhiyunThis sets the config program's title bar if the config program chooses 475*4882a593Smuzhiyunto use it. It should be placed at the top of the configuration, before any 476*4882a593Smuzhiyunother statement. 477*4882a593Smuzhiyun 478*4882a593Smuzhiyun'#' Kconfig source file comment: 479*4882a593Smuzhiyun 480*4882a593SmuzhiyunAn unquoted '#' character anywhere in a source file line indicates 481*4882a593Smuzhiyunthe beginning of a source file comment. The remainder of that line 482*4882a593Smuzhiyunis a comment. 483*4882a593Smuzhiyun 484*4882a593Smuzhiyun 485*4882a593SmuzhiyunKconfig hints 486*4882a593Smuzhiyun------------- 487*4882a593SmuzhiyunThis is a collection of Kconfig tips, most of which aren't obvious at 488*4882a593Smuzhiyunfirst glance and most of which have become idioms in several Kconfig 489*4882a593Smuzhiyunfiles. 490*4882a593Smuzhiyun 491*4882a593SmuzhiyunAdding common features and make the usage configurable 492*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 493*4882a593SmuzhiyunIt is a common idiom to implement a feature/functionality that are 494*4882a593Smuzhiyunrelevant for some architectures but not all. 495*4882a593SmuzhiyunThe recommended way to do so is to use a config variable named HAVE_* 496*4882a593Smuzhiyunthat is defined in a common Kconfig file and selected by the relevant 497*4882a593Smuzhiyunarchitectures. 498*4882a593SmuzhiyunAn example is the generic IOMAP functionality. 499*4882a593Smuzhiyun 500*4882a593SmuzhiyunWe would in lib/Kconfig see:: 501*4882a593Smuzhiyun 502*4882a593Smuzhiyun # Generic IOMAP is used to ... 503*4882a593Smuzhiyun config HAVE_GENERIC_IOMAP 504*4882a593Smuzhiyun 505*4882a593Smuzhiyun config GENERIC_IOMAP 506*4882a593Smuzhiyun depends on HAVE_GENERIC_IOMAP && FOO 507*4882a593Smuzhiyun 508*4882a593SmuzhiyunAnd in lib/Makefile we would see:: 509*4882a593Smuzhiyun 510*4882a593Smuzhiyun obj-$(CONFIG_GENERIC_IOMAP) += iomap.o 511*4882a593Smuzhiyun 512*4882a593SmuzhiyunFor each architecture using the generic IOMAP functionality we would see:: 513*4882a593Smuzhiyun 514*4882a593Smuzhiyun config X86 515*4882a593Smuzhiyun select ... 516*4882a593Smuzhiyun select HAVE_GENERIC_IOMAP 517*4882a593Smuzhiyun select ... 518*4882a593Smuzhiyun 519*4882a593SmuzhiyunNote: we use the existing config option and avoid creating a new 520*4882a593Smuzhiyunconfig variable to select HAVE_GENERIC_IOMAP. 521*4882a593Smuzhiyun 522*4882a593SmuzhiyunNote: the use of the internal config variable HAVE_GENERIC_IOMAP, it is 523*4882a593Smuzhiyunintroduced to overcome the limitation of select which will force a 524*4882a593Smuzhiyunconfig option to 'y' no matter the dependencies. 525*4882a593SmuzhiyunThe dependencies are moved to the symbol GENERIC_IOMAP and we avoid the 526*4882a593Smuzhiyunsituation where select forces a symbol equals to 'y'. 527*4882a593Smuzhiyun 528*4882a593SmuzhiyunAdding features that need compiler support 529*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 530*4882a593Smuzhiyun 531*4882a593SmuzhiyunThere are several features that need compiler support. The recommended way 532*4882a593Smuzhiyunto describe the dependency on the compiler feature is to use "depends on" 533*4882a593Smuzhiyunfollowed by a test macro:: 534*4882a593Smuzhiyun 535*4882a593Smuzhiyun config STACKPROTECTOR 536*4882a593Smuzhiyun bool "Stack Protector buffer overflow detection" 537*4882a593Smuzhiyun depends on $(cc-option,-fstack-protector) 538*4882a593Smuzhiyun ... 539*4882a593Smuzhiyun 540*4882a593SmuzhiyunIf you need to expose a compiler capability to makefiles and/or C source files, 541*4882a593Smuzhiyun`CC_HAS_` is the recommended prefix for the config option:: 542*4882a593Smuzhiyun 543*4882a593Smuzhiyun config CC_HAS_ASM_GOTO 544*4882a593Smuzhiyun def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) 545*4882a593Smuzhiyun 546*4882a593SmuzhiyunBuild as module only 547*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~ 548*4882a593SmuzhiyunTo restrict a component build to module-only, qualify its config symbol 549*4882a593Smuzhiyunwith "depends on m". E.g.:: 550*4882a593Smuzhiyun 551*4882a593Smuzhiyun config FOO 552*4882a593Smuzhiyun depends on BAR && m 553*4882a593Smuzhiyun 554*4882a593Smuzhiyunlimits FOO to module (=m) or disabled (=n). 555*4882a593Smuzhiyun 556*4882a593SmuzhiyunKconfig recursive dependency limitations 557*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 558*4882a593Smuzhiyun 559*4882a593SmuzhiyunIf you've hit the Kconfig error: "recursive dependency detected" you've run 560*4882a593Smuzhiyuninto a recursive dependency issue with Kconfig, a recursive dependency can be 561*4882a593Smuzhiyunsummarized as a circular dependency. The kconfig tools need to ensure that 562*4882a593SmuzhiyunKconfig files comply with specified configuration requirements. In order to do 563*4882a593Smuzhiyunthat kconfig must determine the values that are possible for all Kconfig 564*4882a593Smuzhiyunsymbols, this is currently not possible if there is a circular relation 565*4882a593Smuzhiyunbetween two or more Kconfig symbols. For more details refer to the "Simple 566*4882a593SmuzhiyunKconfig recursive issue" subsection below. Kconfig does not do recursive 567*4882a593Smuzhiyundependency resolution; this has a few implications for Kconfig file writers. 568*4882a593SmuzhiyunWe'll first explain why this issues exists and then provide an example 569*4882a593Smuzhiyuntechnical limitation which this brings upon Kconfig developers. Eager 570*4882a593Smuzhiyundevelopers wishing to try to address this limitation should read the next 571*4882a593Smuzhiyunsubsections. 572*4882a593Smuzhiyun 573*4882a593SmuzhiyunSimple Kconfig recursive issue 574*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 575*4882a593Smuzhiyun 576*4882a593SmuzhiyunRead: Documentation/kbuild/Kconfig.recursion-issue-01 577*4882a593Smuzhiyun 578*4882a593SmuzhiyunTest with:: 579*4882a593Smuzhiyun 580*4882a593Smuzhiyun make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-01 allnoconfig 581*4882a593Smuzhiyun 582*4882a593SmuzhiyunCumulative Kconfig recursive issue 583*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 584*4882a593Smuzhiyun 585*4882a593SmuzhiyunRead: Documentation/kbuild/Kconfig.recursion-issue-02 586*4882a593Smuzhiyun 587*4882a593SmuzhiyunTest with:: 588*4882a593Smuzhiyun 589*4882a593Smuzhiyun make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 allnoconfig 590*4882a593Smuzhiyun 591*4882a593SmuzhiyunPractical solutions to kconfig recursive issue 592*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 593*4882a593Smuzhiyun 594*4882a593SmuzhiyunDevelopers who run into the recursive Kconfig issue have two options 595*4882a593Smuzhiyunat their disposal. We document them below and also provide a list of 596*4882a593Smuzhiyunhistorical issues resolved through these different solutions. 597*4882a593Smuzhiyun 598*4882a593Smuzhiyun a) Remove any superfluous "select FOO" or "depends on FOO" 599*4882a593Smuzhiyun b) Match dependency semantics: 600*4882a593Smuzhiyun 601*4882a593Smuzhiyun b1) Swap all "select FOO" to "depends on FOO" or, 602*4882a593Smuzhiyun 603*4882a593Smuzhiyun b2) Swap all "depends on FOO" to "select FOO" 604*4882a593Smuzhiyun 605*4882a593SmuzhiyunThe resolution to a) can be tested with the sample Kconfig file 606*4882a593SmuzhiyunDocumentation/kbuild/Kconfig.recursion-issue-01 through the removal 607*4882a593Smuzhiyunof the "select CORE" from CORE_BELL_A_ADVANCED as that is implicit already 608*4882a593Smuzhiyunsince CORE_BELL_A depends on CORE. At times it may not be possible to remove 609*4882a593Smuzhiyunsome dependency criteria, for such cases you can work with solution b). 610*4882a593Smuzhiyun 611*4882a593SmuzhiyunThe two different resolutions for b) can be tested in the sample Kconfig file 612*4882a593SmuzhiyunDocumentation/kbuild/Kconfig.recursion-issue-02. 613*4882a593Smuzhiyun 614*4882a593SmuzhiyunBelow is a list of examples of prior fixes for these types of recursive issues; 615*4882a593Smuzhiyunall errors appear to involve one or more "select" statements and one or more 616*4882a593Smuzhiyun"depends on". 617*4882a593Smuzhiyun 618*4882a593Smuzhiyun============ =================================== 619*4882a593Smuzhiyuncommit fix 620*4882a593Smuzhiyun============ =================================== 621*4882a593Smuzhiyun06b718c01208 select A -> depends on A 622*4882a593Smuzhiyunc22eacfe82f9 depends on A -> depends on B 623*4882a593Smuzhiyun6a91e854442c select A -> depends on A 624*4882a593Smuzhiyun118c565a8f2e select A -> select B 625*4882a593Smuzhiyunf004e5594705 select A -> depends on A 626*4882a593Smuzhiyunc7861f37b4c6 depends on A -> (null) 627*4882a593Smuzhiyun80c69915e5fb select A -> (null) (1) 628*4882a593Smuzhiyunc2218e26c0d0 select A -> depends on A (1) 629*4882a593Smuzhiyund6ae99d04e1c select A -> depends on A 630*4882a593Smuzhiyun95ca19cf8cbf select A -> depends on A 631*4882a593Smuzhiyun8f057d7bca54 depends on A -> (null) 632*4882a593Smuzhiyun8f057d7bca54 depends on A -> select A 633*4882a593Smuzhiyuna0701f04846e select A -> depends on A 634*4882a593Smuzhiyun0c8b92f7f259 depends on A -> (null) 635*4882a593Smuzhiyune4e9e0540928 select A -> depends on A (2) 636*4882a593Smuzhiyun7453ea886e87 depends on A > (null) (1) 637*4882a593Smuzhiyun7b1fff7e4fdf select A -> depends on A 638*4882a593Smuzhiyun86c747d2a4f0 select A -> depends on A 639*4882a593Smuzhiyund9f9ab51e55e select A -> depends on A 640*4882a593Smuzhiyun0c51a4d8abd6 depends on A -> select A (3) 641*4882a593Smuzhiyune98062ed6dc4 select A -> depends on A (3) 642*4882a593Smuzhiyun91e5d284a7f1 select A -> (null) 643*4882a593Smuzhiyun============ =================================== 644*4882a593Smuzhiyun 645*4882a593Smuzhiyun(1) Partial (or no) quote of error. 646*4882a593Smuzhiyun(2) That seems to be the gist of that fix. 647*4882a593Smuzhiyun(3) Same error. 648*4882a593Smuzhiyun 649*4882a593SmuzhiyunFuture kconfig work 650*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~ 651*4882a593Smuzhiyun 652*4882a593SmuzhiyunWork on kconfig is welcomed on both areas of clarifying semantics and on 653*4882a593Smuzhiyunevaluating the use of a full SAT solver for it. A full SAT solver can be 654*4882a593Smuzhiyundesirable to enable more complex dependency mappings and / or queries, 655*4882a593Smuzhiyunfor instance on possible use case for a SAT solver could be that of handling 656*4882a593Smuzhiyunthe current known recursive dependency issues. It is not known if this would 657*4882a593Smuzhiyunaddress such issues but such evaluation is desirable. If support for a full SAT 658*4882a593Smuzhiyunsolver proves too complex or that it cannot address recursive dependency issues 659*4882a593SmuzhiyunKconfig should have at least clear and well defined semantics which also 660*4882a593Smuzhiyunaddresses and documents limitations or requirements such as the ones dealing 661*4882a593Smuzhiyunwith recursive dependencies. 662*4882a593Smuzhiyun 663*4882a593SmuzhiyunFurther work on both of these areas is welcomed on Kconfig. We elaborate 664*4882a593Smuzhiyunon both of these in the next two subsections. 665*4882a593Smuzhiyun 666*4882a593SmuzhiyunSemantics of Kconfig 667*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~ 668*4882a593Smuzhiyun 669*4882a593SmuzhiyunThe use of Kconfig is broad, Linux is now only one of Kconfig's users: 670*4882a593Smuzhiyunone study has completed a broad analysis of Kconfig use in 12 projects [0]_. 671*4882a593SmuzhiyunDespite its widespread use, and although this document does a reasonable job 672*4882a593Smuzhiyunin documenting basic Kconfig syntax a more precise definition of Kconfig 673*4882a593Smuzhiyunsemantics is welcomed. One project deduced Kconfig semantics through 674*4882a593Smuzhiyunthe use of the xconfig configurator [1]_. Work should be done to confirm if 675*4882a593Smuzhiyunthe deduced semantics matches our intended Kconfig design goals. 676*4882a593Smuzhiyun 677*4882a593SmuzhiyunHaving well defined semantics can be useful for tools for practical 678*4882a593Smuzhiyunevaluation of dependencies, for instance one such case was work to 679*4882a593Smuzhiyunexpress in boolean abstraction of the inferred semantics of Kconfig to 680*4882a593Smuzhiyuntranslate Kconfig logic into boolean formulas and run a SAT solver on this to 681*4882a593Smuzhiyunfind dead code / features (always inactive), 114 dead features were found in 682*4882a593SmuzhiyunLinux using this methodology [1]_ (Section 8: Threats to validity). 683*4882a593Smuzhiyun 684*4882a593SmuzhiyunConfirming this could prove useful as Kconfig stands as one of the leading 685*4882a593Smuzhiyunindustrial variability modeling languages [1]_ [2]_. Its study would help 686*4882a593Smuzhiyunevaluate practical uses of such languages, their use was only theoretical 687*4882a593Smuzhiyunand real world requirements were not well understood. As it stands though 688*4882a593Smuzhiyunonly reverse engineering techniques have been used to deduce semantics from 689*4882a593Smuzhiyunvariability modeling languages such as Kconfig [3]_. 690*4882a593Smuzhiyun 691*4882a593Smuzhiyun.. [0] https://www.eng.uwaterloo.ca/~shshe/kconfig_semantics.pdf 692*4882a593Smuzhiyun.. [1] https://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf 693*4882a593Smuzhiyun.. [2] https://gsd.uwaterloo.ca/sites/default/files/ase241-berger_0.pdf 694*4882a593Smuzhiyun.. [3] https://gsd.uwaterloo.ca/sites/default/files/icse2011.pdf 695*4882a593Smuzhiyun 696*4882a593SmuzhiyunFull SAT solver for Kconfig 697*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~~ 698*4882a593Smuzhiyun 699*4882a593SmuzhiyunAlthough SAT solvers [4]_ haven't yet been used by Kconfig directly, as noted 700*4882a593Smuzhiyunin the previous subsection, work has been done however to express in boolean 701*4882a593Smuzhiyunabstraction the inferred semantics of Kconfig to translate Kconfig logic into 702*4882a593Smuzhiyunboolean formulas and run a SAT solver on it [5]_. Another known related project 703*4882a593Smuzhiyunis CADOS [6]_ (former VAMOS [7]_) and the tools, mainly undertaker [8]_, which 704*4882a593Smuzhiyunhas been introduced first with [9]_. The basic concept of undertaker is to 705*4882a593Smuzhiyunextract variability models from Kconfig and put them together with a 706*4882a593Smuzhiyunpropositional formula extracted from CPP #ifdefs and build-rules into a SAT 707*4882a593Smuzhiyunsolver in order to find dead code, dead files, and dead symbols. If using a SAT 708*4882a593Smuzhiyunsolver is desirable on Kconfig one approach would be to evaluate repurposing 709*4882a593Smuzhiyunsuch efforts somehow on Kconfig. There is enough interest from mentors of 710*4882a593Smuzhiyunexisting projects to not only help advise how to integrate this work upstream 711*4882a593Smuzhiyunbut also help maintain it long term. Interested developers should visit: 712*4882a593Smuzhiyun 713*4882a593Smuzhiyunhttps://kernelnewbies.org/KernelProjects/kconfig-sat 714*4882a593Smuzhiyun 715*4882a593Smuzhiyun.. [4] https://www.cs.cornell.edu/~sabhar/chapters/SATSolvers-KR-Handbook.pdf 716*4882a593Smuzhiyun.. [5] https://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf 717*4882a593Smuzhiyun.. [6] https://cados.cs.fau.de 718*4882a593Smuzhiyun.. [7] https://vamos.cs.fau.de 719*4882a593Smuzhiyun.. [8] https://undertaker.cs.fau.de 720*4882a593Smuzhiyun.. [9] https://www4.cs.fau.de/Publications/2011/tartler_11_eurosys.pdf 721