Search code examples
buildrootkbuild

How do I make buildroot packages mutually exclusive?


I'm implementing a buildroot package, foo, which can't be included together with a specific other package, bar. I'm trying to define the packages mutually exclusive by writing depends on-statements in the respective Config.in-files.

In foo/Config.in:

config BR2_PACKAGE_FOO
    depends on !BR2_PACKAGE_BAR
    ...

in bar/Config.in:

config BR2_PACKAGE_BAR
    depends on !BR2_PACKAGE_FOO
    ...

Which results in make menuconfig behaving strangely and giving the following error message:

package/foo/Config.in:1:error: recursive dependency detected!
package/foo/Config.in:1:    symbol BR2_PACKAGE_FOO depends on BR2_PACKAGE_BAR
package/bar/Config.in:1:    symbol BR2_PACKAGE_BAR depends on BR2_PACKAGE_FOO

What's the correct way of declaring such a mutually exclusive dependency?


Solution

  • As the error shows, it is not possible for two Kconfig symbols to refer to each other with depends, select or if. So you have to make sure the dependencies go in one direction.

    There is unfortunately no nice way to solve this. The simplest is to put the dependency on just one of the two symbols, so:

    config BR2_PACKAGE_FOO
        depends on !BR2_PACKAGE_BAR
    config BR2_PACKAGE_BAR
        # No depends on BR2_PACKAGE_FOO
    

    This still makes sure that only one of them can be selected, but it's asymmetrical: when you select BAR, FOO will disappear, but when you select FOO, BAR stays visible.