The make documentation says the syntax of a complex conditional is as follows:
conditional-directive-one
text-if-one-is-true
else conditional-directive-two
text-if-two-is-true
else
text-if-one-and-two-are-false
endif
But all the examples I have seen each "conditional-directive-n" is testing the same $var as in the first conditional-directive-one. In effect it is like a case statement testing one variable against multiple possible values. Like this:
ifeq ($(option), 1)
CC=gcc
else ifeq ($(option), 2)
CC=clang
else
CC=mipsel-linux-gcc
endif
My question is, is this a requirement? Or could I have complete different conditional-directives like this:
ifeq ($(option), 1)
CC=gcc
else ifeq ($(myhostname), "JohnsLaptop")
CC=johnsCompiler
else
CC=
endif
So is it really just a funky syntax for a case statement, or is each 'else ifeq' independent.
I know I can do this:
ifeq ($(option), 1)
CC=gcc
else
ifeq ($(myhostname), "johnsLaptop")
CC=johnsCompiler
else
CC=mipsel-linux-gcc
endif
endif
But thats ugly. I would rather not have nested if/else without indentation if I don't have to.
I tested this on my non-standard version of make and the answer was that each conditional directive is independant. And thanks to a comment from madScientist, it seems confirmed that this is the correct answer for standard and gnumake as well.\
This code works:
ifneq ($(findstring mbist_rtl,$@),)
RTL_OPT = mixed findSrc_targets_memwrap.ini
else ifeq ($(DFT), 1)
RTL_OPT = dft
else ifeq ($(BB), 1)
RTL_OPT = ndft
else
RTL_OPT = syn
endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With