Can make warn me, when I use unset variables?

后端 未结 2 1058
暗喜
暗喜 2021-02-13 18:03

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

2条回答
  •  终归单人心
    2021-02-13 18:35

    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
    

提交回复
热议问题