diff options
-rw-r--r-- | Documentation/kbuild/kconfig-language.txt | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt index a43fcc68e171..649cb8799890 100644 --- a/Documentation/kbuild/kconfig-language.txt +++ b/Documentation/kbuild/kconfig-language.txt | |||
@@ -330,6 +330,42 @@ 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 | 330 | first glance and most of which have become idioms in several Kconfig |
331 | files. | 331 | files. |
332 | 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 | |||
333 | Build as module only | 369 | Build as module only |
334 | ~~~~~~~~~~~~~~~~~~~~ | 370 | ~~~~~~~~~~~~~~~~~~~~ |
335 | To restrict a component build to module-only, qualify its config symbol | 371 | To restrict a component build to module-only, qualify its config symbol |