Home > Blockchain >  GNU Make condition ifneq check at least one variable not is not empty
GNU Make condition ifneq check at least one variable not is not empty

Time:10-30

I like to check if at least on variable is not empty in a list of multiple.

for example I like to combine the following working condition into one statement:

ifneq (${VAR1},)
    ...command true for all ...
else ifneq (${V2},)
    ... same command as above...
else ifneq (${VAR3},)
    ... same command as first...
else ifneq (${V4},)
   ... same command as first...
else
    ...other command....
endif

I like to have a MAKE (not shell) condition like

ifneq (${VAR1},) || (${V2},) ||  (${VAR3},) || (${VAR3},)
   ...command true for all ...
else
   ...other command....
endif

CodePudding user response:

ifneq ($(VAR1)$(VAR2)$(VAR3),)

CodePudding user response:

Similar to @HolyBlackCat's answer:

ifneq ($(or $(VAR1),$(VAR2),$(VAR3)),)

Both will do the same, and @HolyBlackCat's answer shorter, but if you wanted to do something slightly more complex, then this methodology is good to know.

  • Related