diff options
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/kbuild/kconfig-language.txt | 111 |
1 files changed, 105 insertions, 6 deletions
diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt index 616043a6da9..649cb879989 100644 --- a/Documentation/kbuild/kconfig-language.txt +++ b/Documentation/kbuild/kconfig-language.txt | |||
@@ -24,7 +24,7 @@ visible if its parent entry is also visible. | |||
24 | Menu entries | 24 | Menu entries |
25 | ------------ | 25 | ------------ |
26 | 26 | ||
27 | Most entries define a config option, all other entries help to organize | 27 | Most entries define a config option; all other entries help to organize |
28 | them. A single configuration option is defined like this: | 28 | them. A single configuration option is defined like this: |
29 | 29 | ||
30 | config MODVERSIONS | 30 | config MODVERSIONS |
@@ -50,7 +50,7 @@ applicable everywhere (see syntax). | |||
50 | 50 | ||
51 | - type definition: "bool"/"tristate"/"string"/"hex"/"int" | 51 | - type definition: "bool"/"tristate"/"string"/"hex"/"int" |
52 | Every config option must have a type. There are only two basic types: | 52 | Every config option must have a type. There are only two basic types: |
53 | tristate and string, the other types are based on these two. The type | 53 | tristate and string; the other types are based on these two. The type |
54 | definition optionally accepts an input prompt, so these two examples | 54 | definition optionally accepts an input prompt, so these two examples |
55 | are equivalent: | 55 | are equivalent: |
56 | 56 | ||
@@ -108,7 +108,7 @@ applicable everywhere (see syntax). | |||
108 | equal to 'y' without visiting the dependencies. So abusing | 108 | equal to 'y' without visiting the dependencies. So abusing |
109 | select you are able to select a symbol FOO even if FOO depends | 109 | select you are able to select a symbol FOO even if FOO depends |
110 | on BAR that is not set. In general use select only for | 110 | on BAR that is not set. In general use select only for |
111 | non-visible symbols (no promts anywhere) and for symbols with | 111 | non-visible symbols (no prompts anywhere) and for symbols with |
112 | no dependencies. That will limit the usefulness but on the | 112 | no dependencies. That will limit the usefulness but on the |
113 | other hand avoid the illegal configurations all over. kconfig | 113 | other hand avoid the illegal configurations all over. kconfig |
114 | should one day warn about such things. | 114 | should one day warn about such things. |
@@ -127,6 +127,27 @@ applicable everywhere (see syntax). | |||
127 | used to help visually separate configuration logic from help within | 127 | used to help visually separate configuration logic from help within |
128 | the file as an aid to developers. | 128 | the file as an aid to developers. |
129 | 129 | ||
130 | - misc options: "option" <symbol>[=<value>] | ||
131 | Various less common options can be defined via this option syntax, | ||
132 | which can modify the behaviour of the menu entry and its config | ||
133 | symbol. These options are currently possible: | ||
134 | |||
135 | - "defconfig_list" | ||
136 | This declares a list of default entries which can be used when | ||
137 | looking for the default configuration (which is used when the main | ||
138 | .config doesn't exists yet.) | ||
139 | |||
140 | - "modules" | ||
141 | This declares the symbol to be used as the MODULES symbol, which | ||
142 | enables the third modular state for all config symbols. | ||
143 | |||
144 | - "env"=<value> | ||
145 | This imports the environment variable into Kconfig. It behaves like | ||
146 | a default, except that the value comes from the environment, this | ||
147 | also means that the behaviour when mixing it with normal defaults is | ||
148 | undefined at this point. The symbol is currently not exported back | ||
149 | to the build environment (if this is desired, it can be done via | ||
150 | another symbol). | ||
130 | 151 | ||
131 | Menu dependencies | 152 | Menu dependencies |
132 | ----------------- | 153 | ----------------- |
@@ -162,9 +183,9 @@ An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 | |||
162 | respectively for calculations). A menu entry becomes visible when it's | 183 | respectively for calculations). A menu entry becomes visible when it's |
163 | expression evaluates to 'm' or 'y'. | 184 | expression evaluates to 'm' or 'y'. |
164 | 185 | ||
165 | There are two types of symbols: constant and nonconstant symbols. | 186 | There are two types of symbols: constant and non-constant symbols. |
166 | Nonconstant symbols are the most common ones and are defined with the | 187 | Non-constant symbols are the most common ones and are defined with the |
167 | 'config' statement. Nonconstant symbols consist entirely of alphanumeric | 188 | 'config' statement. Non-constant symbols consist entirely of alphanumeric |
168 | characters or underscores. | 189 | characters or underscores. |
169 | Constant symbols are only part of expressions. Constant symbols are | 190 | Constant symbols are only part of expressions. Constant symbols are |
170 | always surrounded by single or double quotes. Within the quote, any | 191 | always surrounded by single or double quotes. Within the quote, any |
@@ -301,3 +322,81 @@ mainmenu: | |||
301 | 322 | ||
302 | This sets the config program's title bar if the config program chooses | 323 | This sets the config program's title bar if the config program chooses |
303 | to use it. | 324 | to use it. |
325 | |||
326 | |||
327 | Kconfig hints | ||
328 | ------------- | ||
329 | This is a collection of Kconfig tips, most of which aren't obvious at | ||
330 | first glance and most of which have become idioms in several Kconfig | ||
331 | files. | ||
332 | |||
333 | Adding common features and make the usage configurable | ||
334 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
335 | It is a common idiom to implement a feature/functionality that are | ||
336 | relevant for some architectures but not all. | ||
337 | The recommended way to do so is to use a config variable named HAVE_* | ||
338 | that is defined in a common Kconfig file and selected by the relevant | ||
339 | architectures. | ||
340 | An example is the generic IOMAP functionality. | ||
341 | |||
342 | We would in lib/Kconfig see: | ||
343 | |||
344 | # Generic IOMAP is used to ... | ||
345 | config HAVE_GENERIC_IOMAP | ||
346 | |||
347 | config GENERIC_IOMAP | ||
348 | depends on HAVE_GENERIC_IOMAP && FOO | ||
349 | |||
350 | And in lib/Makefile we would see: | ||
351 | obj-$(CONFIG_GENERIC_IOMAP) += iomap.o | ||
352 | |||
353 | For each architecture using the generic IOMAP functionality we would see: | ||
354 | |||
355 | config X86 | ||
356 | select ... | ||
357 | select HAVE_GENERIC_IOMAP | ||
358 | select ... | ||
359 | |||
360 | Note: we use the existing config option and avoid creating a new | ||
361 | config variable to select HAVE_GENERIC_IOMAP. | ||
362 | |||
363 | Note: the use of the internal config variable HAVE_GENERIC_IOMAP, it is | ||
364 | introduced to overcome the limitation of select which will force a | ||
365 | config option to 'y' no matter the dependencies. | ||
366 | The dependencies are moved to the symbol GENERIC_IOMAP and we avoid the | ||
367 | situation where select forces a symbol equals to 'y'. | ||
368 | |||
369 | Build as module only | ||
370 | ~~~~~~~~~~~~~~~~~~~~ | ||
371 | To restrict a component build to module-only, qualify its config symbol | ||
372 | with "depends on m". E.g.: | ||
373 | |||
374 | config FOO | ||
375 | depends on BAR && m | ||
376 | |||
377 | limits FOO to module (=m) or disabled (=n). | ||
378 | |||
379 | |||
380 | Build limited by a third config symbol which may be =y or =m | ||
381 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
382 | A common idiom that we see (and sometimes have problems with) is this: | ||
383 | |||
384 | When option C in B (module or subsystem) uses interfaces from A (module | ||
385 | or subsystem), and both A and B are tristate (could be =y or =m if they | ||
386 | were independent of each other, but they aren't), then we need to limit | ||
387 | C such that it cannot be built statically if A is built as a loadable | ||
388 | module. (C already depends on B, so there is no dependency issue to | ||
389 | take care of here.) | ||
390 | |||
391 | If A is linked statically into the kernel image, C can be built | ||
392 | statically or as loadable module(s). However, if A is built as loadable | ||
393 | module(s), then C must be restricted to loadable module(s) also. This | ||
394 | can be expressed in kconfig language as: | ||
395 | |||
396 | config C | ||
397 | depends on A = y || A = B | ||
398 | |||
399 | or for real examples, use this command in a kernel tree: | ||
400 | |||
401 | $ find . -name Kconfig\* | xargs grep -ns "depends on.*=.*||.*=" | grep -v orig | ||
402 | |||