Reputation: 3186
I have a bunch of variables in my GNU Makefile, and users might change their values. I'd like the Makefile to fail before it starts executing if some of those values don't make any sense.
For example:
FOODIR=foo
BARDIR=bar
is okay, but if the user sets this to
FOODIR=foo
BARDIR=foo
I'd like the Makefile to fail. I'm looking for the right syntax to do this. Something like:
ifeq ($(FOODIR),$(BARDIR))
exit 1;
endif
but that doesn't work. What's the best way of doing this?
Upvotes: 1
Views: 249
Reputation: 100856
Makefiles are not shell scripts; you can't use shell commands like exit
.
There is a GNU make function $(error ...)
you can use (if your GNU make is recent enough):
ifeq ($(FOODIR),$(BARDIR))
$(error FOODIR is the same as BARDIR: $(FOODIR))
endif
Upvotes: 3