Reverse dependencies can only be used with boolean or tristate
symbols.
Note:
- select is evil.... select will by brute force set a symbol
- equal to 'y' without visiting the dependencies. So abusing
- select you are able to select a symbol FOO even if FOO depends
- on BAR that is not set. In general use select only for
- non-visible symbols (no prompts anywhere) and for symbols with
- no dependencies. That will limit the usefulness but on the
- other hand avoid the illegal configurations all over. kconfig
- should one day warn about such things.
+ select should be used with care. select will force
+ a symbol to a value without visiting the dependencies.
+ By abusing select you are able to select a symbol FOO even
+ if FOO depends on BAR that is not set.
+ In general use select only for non-visible symbols
+ (no prompts anywhere) and for symbols with no dependencies.
+ That will limit the usefulness but on the other hand avoid
+ the illegal configurations all over.
+ kconfig should one day warn about such things.
- numerical ranges: "range" <symbol> <symbol> ["if" <expr>]
This allows to limit the range of possible input values for int
first glance and most of which have become idioms in several Kconfig
files.
-Build as module only
-~~~~~~~~~~~~~~~~~~~~
-To restrict a component build to module-only, qualify its config symbol
-with "depends on m". E.g.:
+Adding common features and make the usage configurable
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+It is a common idiom to implement a feature/functionality that are
+relevant for some architectures but not all.
+The recommended way to do so is to use a config variable named HAVE_*
+that is defined in a common Kconfig file and selected by the relevant
+architectures.
+An example is the generic IOMAP functionality.
-config FOO
- depends on BAR && m
+We would in lib/Kconfig see:
-limits FOO to module (=m) or disabled (=n).
+# Generic IOMAP is used to ...
+config HAVE_GENERIC_IOMAP
+
+config GENERIC_IOMAP
+ depends on HAVE_GENERIC_IOMAP && FOO
+And in lib/Makefile we would see:
+obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
-Build limited by a third config symbol which may be =y or =m
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-A common idiom that we see (and sometimes have problems with) is this:
+For each architecture using the generic IOMAP functionality we would see:
-When option C in B (module or subsystem) uses interfaces from A (module
-or subsystem), and both A and B are tristate (could be =y or =m if they
-were independent of each other, but they aren't), then we need to limit
-C such that it cannot be built statically if A is built as a loadable
-module. (C already depends on B, so there is no dependency issue to
-take care of here.)
+config X86
+ select ...
+ select HAVE_GENERIC_IOMAP
+ select ...
-If A is linked statically into the kernel image, C can be built
-statically or as loadable module(s). However, if A is built as loadable
-module(s), then C must be restricted to loadable module(s) also. This
-can be expressed in kconfig language as:
+Note: we use the existing config option and avoid creating a new
+config variable to select HAVE_GENERIC_IOMAP.
-config C
- depends on A = y || A = B
+Note: the use of the internal config variable HAVE_GENERIC_IOMAP, it is
+introduced to overcome the limitation of select which will force a
+config option to 'y' no matter the dependencies.
+The dependencies are moved to the symbol GENERIC_IOMAP and we avoid the
+situation where select forces a symbol equals to 'y'.
-or for real examples, use this command in a kernel tree:
+Build as module only
+~~~~~~~~~~~~~~~~~~~~
+To restrict a component build to module-only, qualify its config symbol
+with "depends on m". E.g.:
-$ find . -name Kconfig\* | xargs grep -ns "depends on.*=.*||.*=" | grep -v orig
+config FOO
+ depends on BAR && m
+
+limits FOO to module (=m) or disabled (=n).