向Makefile添加注释

12 makefile

如何添加注释(带回声),Makefile以便在运行时打印?

Aln*_*tak 25

你应该用

target:
     @echo "Building!"
Run Code Online (Sandbox Code Playgroud)

注意@,它告诉Make不显示命令本身.如果没有这个,输出将如下所示:

echo "Building!"
Building!
Run Code Online (Sandbox Code Playgroud)


Fra*_*Man 6

或者,因为Make只是将规则中的任何内容推送到bash,你可以使用一个bash将bash视为注释.

Rule:  Dependencies
    # Your Comment
    Command
Run Code Online (Sandbox Code Playgroud)

会输出

$ make Rule
    # Your Comment
    Command
Run Code Online (Sandbox Code Playgroud)

  • 你怎么能这样做呢?在没有打印的makefile中放置注释? (3认同)
  • 最后询问:http://stackoverflow.com/questions/18360776/how-to-not-print-in-the-output-a-comment-in-a-makefile/18363477?noredirect=1#18363477 (2认同)
  • @knocte 您可以在“#”之前使用“@” (2认同)

Joe*_*oey 2

由于 makefile 主要包含构建特定目标时要运行的命令,因此我想说您只需使用:echo