Is there a way to tell make to complain when I use unset variables? Something similar to set -u
in bash?
I have just spent twenty minutes debugging my Makef
Yes, there is a way:
make --warn-undefined-variables
I've just tested it with make version 3.81
EDIT:
You can also set it in your makefile, to protect yourself in the future from silly mistakes. To do it just put this somewhere near the top of your makefile (this will be passed to recursive make processes too):
MAKEFLAGS=--warn-undefined-variables
Here is how one can do it to make make fail immediately:
ifndef PSWD
$(error PSWD is undefined)
endif