将make命令的输出控制得不太冗长,不要回显每个命令 [英] Control the output of a make command to be less verbose, don't echo each command

查看:389
本文介绍了将make命令的输出控制得不太冗长,不要回显每个命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在使用Makefile来跟踪项目的所有依赖关系和编译.问题在于 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).

是否可以控制终端上显示的信息?我知道有一个-s选项可以使 make 静音,但这不是我想要的.我需要一些改进的东西,也许在不显示整个编译命令的情况下显示了编译目标.

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?

注意:关于automake和autoconf命令,有一个类似的问题.但是我不使用这些东西,而是专门在寻找make上的东西.

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.

推荐答案

好吗?

target: dependency1 dependency2
    @echo Making $@
    @$(CC) -o $@ $(OPTIONS) $^

引导@抑制了通常的回显行为动作没有会抑制其输出.

The leading @'s suppress the usual behavior of echoing the action without suppressing its output.

可以通过将其重定向到/dev/null来抑制各种操作的输出.如果您要使一行真正保持静音,请记住也要对标准错误进行分级.

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.

这篇关于将make命令的输出控制得不太冗长,不要回显每个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆