是否可以强制使用 GNU Make 回显配方?

Is it possible to enforce recipe echoing with GNU Make?

根据 the GNU make manual,shell 命令的回显可以通过在相应的行前面加上前缀 @.

来抑制

使用选项 -n--just-print,可以干 运行 并打印所有这些前缀行,而无需实际执行。

是否可以同时执行 make recipes 打印 shell 命令?换句话说,我可以对 所有 食谱强制回显,无论它们是否在开头有 @ 吗?

GNU Make 4.0 有选项 --trace。 (不知道最早支持的版本是多少--trace,只知道4.0支持。)

'--trace'

Show tracing information for 'make' execution. Prints the entire recipe to be executed, even for recipes that are normally silent (due to '.SILENT' or '@'). Also prints the makefile name and line number where the recipe was defined, and information on why the target is being rebuilt.

有了这个Makefile:

all:
    @echo foo
    echo blah

常规 运行:

$ make
foo
echo blah
blah

--trace:

$ make --trace
Makefile:2: target 'all' does not exist
echo foo
foo
echo blah
blah

echo foo 即使以 @.

开头,也会输出