GNU默认情况下保持静音 [英] GNU Make silent by default
问题描述
默认情况下是否可以从Makefile
内部抑制命令回显?
Is it possible to suppress command echoing by default from within the Makefile
?
我知道在--silent
模式下运行make
会做到这一点,就像在每个命令前面加上@
一样.
I know that running make
in --silent
mode will do it, as will prefixing every command with @
.
我正在寻找命令或节,我可以在Makefile中包含 ,从而省去了用@
乱扔一切或让用户手动使一切静音的麻烦.
I'm looking for a command or stanza I can include inside the Makefile, saving the trouble of littering everything with @
or having the user silence everything manually.
推荐答案
如果定义目标.SILENT:
,则make将不会回显任何内容.通常最好保护定义,因此您可以轻松地将其关闭:
If you define the target .SILENT:
, then make will not echo anything. It's usually best to guard the definition, so you can easily turn it off:
ifndef VERBOSE
.SILENT:
endif
现在默认情况下,make将不打印任何内容,但是如果您运行make VERBOSE=1
,它将打印.
Now by default, make will print nothing, but if you run make VERBOSE=1
, it will print.
请注意,尽管手册中的声明声称.SILENT
已过时-如果得到适当的保护,它通常比@
好得多(更有用,更灵活).
Note that despite the statement in the manual claiming that .SILENT
is obsolete -- if properly guarded, it is generally much better (more useful and flexible) than @
.
.SILENT
目标不应成为Makefile
上的第一个目标,否则make
将默认使用它.
The .SILENT
target should not be the first on your Makefile
, otherwise make
will use it by default.
这篇关于GNU默认情况下保持静音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!