打印制作目标名称

时间:2015-04-16 10:45:28

标签: makefile

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

> make a
building b
building c
building a

不希望在每个目标中添加echo $@个语句。

1 个答案:

答案 0 :(得分:4)

您可以通过命令行设置所需的调试级别。在您的情况下,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