Can I be notified when I use undefined variables?


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 Makefile, because there was a one symbol typo in the name of the variable.

Yes, there is a way:

make --warn-undefined-variables

I've just tested it with make version 3.81


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):