How to have GNU make explicitly test for failure?

前端 未结 3 1559
臣服心动
臣服心动 2020-12-24 00:50

After years of not using make, I find myself needing it again, the gnu version now. I\'m pretty sure I should be able to do what I want, but haven\'t figured out how, or fo

3条回答
  •  难免孤独
    2020-12-24 00:57

    The proper solution if you want to require the target to fail is to negate its exit code.

    # Makefile
    # 
    test:
        myProg -h > test.log              # Display help
        myProg good_input >> test.log     # should run fine
        ! myProg bad_input1 >> test.log      # Error 1
        ! myProg bad_input2 >> test.log      # Error 2
    

    Now, it is an error to succeed in those two cases.

提交回复
热议问题