Can you make valid Makefiles without tab characters?

前端 未结 10 2584
孤城傲影
孤城傲影 2020-12-02 07:17
target: dependencies
    command1
    command2

On my system (Mac OS X), make seems to require that that Makefiles have a tab character

10条回答
  •  离开以前
    2020-12-02 07:30

    Until GNU Make 4.2

    Steven Penny's answer works.

    .RECIPEPREFIX +=
    

    The reason why this works is described in my comment.


    Since GNU Make 4.3 (released on 19 Jan 2020)

    Behavior of += operator has been changed in a backward-incompatible way. If the left operand has an empty value, a space is no longer added.

    You can instead use

    .RECIPEPREFIX := $(.RECIPEPREFIX)
    

    , where is a single space. Although $(.RECIPEPREFIX) is expanded as an empty value, this is needed not to let GNU Make ignore . Note this code works even on GNU Make older than version 4.3.

提交回复
热议问题