Syntax to get the value of environment variable in Kconfig file

linux-kernel

Solution

As per the kconfig docs:

<expr> ::= <symbol>                             (1)
           <symbol> '=' <symbol>                (2)
           <symbol> '!=' <symbol>               (3)
           '(' <expr> ')'                       (4)
           '!' <expr>                           (5)
           <expr> '&&' <expr>                   (6)
           <expr> '||' <expr>                   (7)


- misc options: "option" <symbol>[=<value>]

  - "env"=<value>
  This imports the environment variable into Kconfig.

if:

    "if" <expr>
    <if block>
    "endif"

This defines an if block. The dependency expression <expr> is appended
to all enclosed menu entries.

source:

    "source" <prompt>

This reads the specified configuration file. This file is always parsed.

So I'd try

option env="YOURVAR"
if YOURVAR=foo
    source "somefile"
endif
if YOURVAR!=foo
    source "someotherfile"
endif

Problem

Can anyone provide me the syntax of obtaining the value of environment variable in Kconfig file? Based on the value of environment variable I need to conditionally source another Kconfig file.

Original source