Abort makefile if variable not set

后端 未结 5 1224
栀梦
栀梦 2020-12-22 16:11

How could I abort a make/makefile execution based on a makefile\'s variable not being set/valued?

I came up with this, but works only if caller doesn\'t explicitly r

5条回答
  •  盖世英雄少女心
    2020-12-22 16:41

    Use the shell function test:

    foo:
        test $(something)
    

    Usage:

    $ make foo
    test 
    Makefile:2: recipe for target 'foo' failed
    make: *** [foo] Error 1
    $ make foo something=x
    test x
    

提交回复
热议问题