Following advice at Abort makefile if variable not set I am attempting to use ifndef
but it's not working.
Makefile:
foo:
ifndef BAR
$(error "Must set BAR")
endif
But make foo BAR=quux
does not work:
Makfile:2: *** "Must set BAR". Stop.
What gives? Is it whitespace issue? Or am I misunderstanding completely?
(I'm using GNU Make)
I tried also:
foo:
ifndef BAR
$(error "Must set BAR")
endif
echo $(BAR)
Which seems to sort of work but still causes the ifndef
to be invoked if a target further down in the Makefile (which does not require the variable to be set) is invoked.