4

I'm using the Linux kernel's configuration tool Kconfig to manage the configuration of my own project.

(Please could someone with sufficient rep add "Kconfig" tag or whatever tag would be more appropriate). I didn't tag as "linux" or as "kernel" since my actual project is not the Linux kernel.

Given the following configuration:

mainmenu "Select/choice interaction test"

# Selectable menu granting access to multiple potentially independent config vars
menuconfig MULTICHOICE
        bool "Multichoice"

config MULTICHOICE_A
        bool "A"
        depends on MULTICHOICE

config MULTICHOICE_B
        bool "B"
        depends on MULTICHOICE

config MULTICHOICE_C
        bool "C"
        depends on MULTICHOICE

# Choose exactly one item
choice CHOICE
        prompt "Choice"

config CHOICE_A
        bool "A"

config CHOICE_B
        bool "B"

config CHOICE_C
        bool "C"


endchoice

# Booleans which restrict/select other options from the previous sections

config SET_A
        bool "Select A"
        select CHOICE_A
        select MULTICHOICE
        select MULTICHOICE_A

config SET_B
        bool "Select B"
        select CHOICE_B
        select MULTICHOICE
        select MULTICHOICE_B

config SET_C
        bool "Select C"
        select CHOICE_C
        select MULTICHOICE
        select MULTICHOICE_C

Selecting items in a menuconfig works as expected. But setting the value of the choice does not work.

I can understand a potential problem (conflict) here - what if multiple options from the choice were selected implicitly by other configuration variables?

But in the sane case of only one choice option being implicitly selected by others, the value of the choice does not change.

For example, open that configuration file above with nconfig/menuconfig/gconfig/xconfig then select exactly one of SET_A/SET_B/SET_C. The value of CHOICE does not change at all.

Is there some other way of ensuring that only one option from a set is selected, but also forcing it to a certain value if other configuration variables are set a particular way?

1 Answers1

2

As I can't reply, Ciro Santilli is not exactly right.

To quote the answer from there:

It is not possible to use select for non booleans according to > kernel docs v4.15

https://github.com/torvalds/linux/blob/v4.15/Documentation/kbuild/kconfig-language.txt#L104 says:

- reverse dependencies: "select" <symbol> ["if" <expr>] 
  [...]
  Reverse dependencies can only be used with boolean or tristate symbols.

However this question is actually about booleans, so in that light, should be possible. Sadly, I found this question as I was looking for the answer as well.

  • While not an answer, thanks for citing the actual docs. I don't recall having seen that before which probably means I didn't RTFM enough back when I was working on this problem. (Solution chosen: new configuration system instead of Kconfig) – Mark K Cowan Jan 20 '19 at 17:39