5

in defconfig files, you can set kernel options as such:

CONFIG_<optionName>=y
CONFIG_<optionName>=m
CONFIG_<optionName>=n
# CONFIG_<optionName> is not set

I understand the first 2.

What I would like to understand is the difference between #3 & #4, and when to use each - especially given that the kernel sources may use #ifdef CONFIG_ { ... } and sometimes, #if CONFIG_ { ... }

In my specific case, I want to decidedly say that optionName is not available.

Thanks

user3342339
  • 349
  • 1
  • 5
  • 19
  • It's been a while since I looked into this, but the actual definitions of the macro `CONFIG_xxx` should be in `autoconf.h`, a header file that's generated based on your config file. So `CONFIG_xxx is not set` and `CONFIG_xxx=n` should be equivalent. – Ram Jan 31 '17 at 00:46

2 Answers2

2

CONFIG_<optionName>=n is not valid. That's just not how Kconfig options are specified. # CONFIG_<optionName> is not set is how you specify that an option is not set.

1

CONFIG_<optionName>=n It means that you are explicitly disabling this config item from your defconfig file. So in your .config file it will show like # CONFIG_ is not set.

# CONFIG_<optionName> is not set In this case also you are explicitly disabling this config. So generated config file (.config) will show like # CONFIG_<optionName> is not set.

However with Any of these options you can disable the config item; but as per @ Alexandre comment it seems that "not set" is the proper way.

You can refer to the below link for more detail about the .config and defconfig file:

What exactly does Linux kernel's `make defconfig` do?

tleb
  • 4,395
  • 3
  • 25
  • 33
vinod maverick
  • 670
  • 4
  • 14
  • 2
    No, the proper way to disable an option is to use "is not set". 'n' should not be used (and is never used in the kernel apart from unicore32 and those date from 2011). – Alexandre Belloni Jan 31 '17 at 09:16
  • @AlexandreBelloni, this seems to be the right answer now that i look at more configs and more distros – user3342339 Feb 01 '17 at 00:24
  • @AlexandreBelloni What is the idea behind having comment in form of "CONFIG_FEATURE is not set" rather than "CONFIG_FEATURE=n"? Is it somewhere documented? – o_ndra Sep 02 '20 at 14:58
  • In linux 1.0, the main Makefile would do include .config. If you had CONFIG_FEATURE=n, then ifdef CONFIG_FEATURE would be true which would not be very convenient as this was the simplest way to test for a feature. – Alexandre Belloni Sep 02 '20 at 23:03
  • @AlexandreBelloni asked exactly what i was also asking myself. Why disabling an option in the shape of a comment ? – Angelo Dureghello Oct 23 '22 at 07:33
  • This is not true anymore: https://lore.kernel.org/all/20220226123755.85213-1-masahiroy@kernel.org/ – Alexandre Belloni Oct 24 '22 at 12:52