控制 make 命令的输出不那么冗长,不要回显每个命令
目前,我正在使用 Makefile 来跟踪项目的所有依赖项和编译。问题是 make 只是输出它正在执行的所有操作,这使得很难发现(甚至读取)更重要的信息(例如编译器警告)。
有没有办法控制终端上显示哪些信息?我知道有一个 -s
选项可以使 make 静音,但这不是我想要的。我需要一些更精致的东西,也许显示编译目标而不显示整个编译命令。
有什么办法可以控制吗?
注意:有一个关于 automake 和 autoconf 命令的类似问题。但我不使用这些,而且我专门在 make 上寻找一些东西。
Currently, I'm using a Makefile to keep track of all dependencies and copilation of my project. The problem is that make simply outputs everything it's doing, and that makes it hard to spot (or even read) more important information (such as compiler warnings).
Is there a way to control what information is displayed on the terminal? I know there's a -s
option that silences make, but that's not what I want. I need something a little more refined, perhaps showing the compilation target without showing the entire compilation command.
Is there any way to control that?
Note: There's a similar question regarding the automake and autoconf commands. But I don't use those, and I'm specifically looking for something on make.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,这是通常的事情
领先的
@
的抑制回显操作的通常行为,而不抑制其输出。可以通过将其重定向到
/dev/null
来抑制各种操作的输出。如果您希望一行真正保持安静,请记住也要对标准错误进行评分。Well there's the usual business
The leading
@
's suppress the usual behavior of echoing the action without suppressing its output.The output of various actions can be suppressed by redirecting it to
/dev/null
. Remember to grad the standard error too if you want a line to be really silent.标准 Unix 答案(毕竟 `make`` 是一个 Unix 工具):
为什么这不是一个合适的解决方案?
您还可以在
Makefile
本身中进行过滤,例如通过调整SHELL
变量或添加一个调用
$(MAKE) | 的目标grep
。主要思想是允许根据调用者的意愿打开和关闭过滤。
The standard Unix answer (`make`` is a Unix tool, after all):
Why is that not an appropriate solution here?
You could also put filtering within the
Makefile
itself, e.g. by tweaking theSHELL
variableor adding a target that calls
$(MAKE) | grep
.The main idea is to allow the filtering to be switched on and off as the caller pleases.
(太晚了,仅为登陆此处的 Google 员工添加)
这对我有用。在 Makefile 中,您可以使用以下命令控制每个命令的详细程度:
(Too late, Adding just for Googlers landing here)
This works for me. On your Makefile you can control verbosity for each command using something like: