打印 make 目标名称

Printing make target name

是否可以让gnu make进程输出正在执行的目标名称?这将有助于调试构建过程。

> make a
building b
building c
building a

最好不要在每个目标中添加 echo $@ 语句。

您可以通过命令行设置所需的调试级别。在您的情况下,看起来 basic 就足够了:

$ make --debug=b
GNU Make 4.0
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating goal targets....
 File 'all' does not exist.
   File 'foo' does not exist.
  Must remake target 'foo'.
  Successfully remade target file 'foo'.
   File 'bar' does not exist.
  Must remake target 'bar'.
  Successfully remade target file 'bar'.
   File 'baz' does not exist.
  Must remake target 'baz'.
  Successfully remade target file 'baz'.
Must remake target 'all'.
Successfully remade target file 'all'.

参见GNU Make options