Force exit from a Makefile target without raising an error

后端 未结 2 1899
清酒与你
清酒与你 2021-02-18 16:37

I work with a Makefile generated by an external tool (Netbeans), where I can not change the logic of the main target, but I am able to \"inject\" logic in a target that is execu

相关标签:
2条回答
  • 2021-02-18 16:44

    Just expanding a bit on @Ken's excellent response. You can also do this:

    ifeq ("test", "test")
    postinstall:
        @echo "test = test"
    else
    postinstall:
        @echo "test != test"
    endif
    
    0 讨论(0)
  • 2021-02-18 17:07

    You can have the all target do nothing if a variable is not set:

    ifeq ($(SOME_VAR),)
    $(info SOME_VAR not set!)
    all:
    else
    all: target1 target2 targetetc
    endif
    
    0 讨论(0)
提交回复
热议问题