In my Makefile I would like to check the following complex condition:
ifdef VAR1 || VAR2 || VAR3
action
endif
however the documentation says the syntax like that is not supported. So the only simple workaround that came to my mind is to use the concatenation:
ifneq ($(VAR1)$(VAR2)$(VAR3),)
action
endif
Are there any other more correct solutions?
For the following case:
ifdef VAR1 && VAR2 && VAR3
action
endif
one need to write
ifdef VAR1
ifdef VAR2
ifdef VAR3
action
endif
endif
endif
which is also ugly. Are there more elegant alternatives?
If your
make
is GNU-make and all the defined variables include a non-space character,can be written as
On a related note, probably
and
function requires version 3.81 or later.In case some defined variables may be empty strings, if we prepare the following functions:
then the following conditions:
can be written respectively as: