Linux 如何在 Makefile 中隐藏编译消息?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9883950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 05:25:25  来源:igfitidea点击:

How to hide compiling message in Makefile?

linuxmakefile

提问by Amumu

The linux kernel I compile only prints message like:

我编译的 linux 内核只打印如下消息:

CC  .....
LD [M] ....

How can I hide the compiling message printed out by make and output what I want? Where can I find the portion of code which does this in kernel Makefile?

如何隐藏 make 打印的编译消息并输出我想要的内容?我在哪里可以找到在内核 Makefile 中执行此操作的代码部分?

采纳答案by Kristof Provost

In short, prepend '@'.

简而言之,在前面加上'@'。

What the kernel makefiles do is rather more complicated, but it boils down to something like this:

内核 makefile 所做的事情相当复杂,但归结为这样的事情:

%.o: %.c
    @echo [CC] $@
    @gcc -o $@ -c $<

Look at the GNU Make manual. GNU Make really is quite well documented, and if you're doing a lot of work with it it's worth the effort to read it through.

查看GNU Make 手册。GNU Make 确实有很好的文档记录,如果您正在使用它进行大量工作,那么通读它是值得的。