Override target in makefile to add more commands?

前端 未结 6 704
小蘑菇
小蘑菇 2020-12-23 17:16

At work we use a common makefile that other makefiles include (via the include statement) and it has a generic \"clean\" target that kills some common files. I want to add

6条回答
  •  遥遥无期
    2020-12-23 17:57

    Use implicit rules:

    existing-target: my-extention
    
    my-extention:
        echo running command 1
        echo running command 2
    

    Very simple make tutorial to ramp up.

    When using :: you can run into issues since make complains when you mix single colon : and double colon :: rules:

    a:
        echo a
    
    a::
        echo aa
    

    will result in:

    . . .
    *** target file `a' has both : and :: entries.  Stop.
    

提交回复
热议问题