本文介绍了忽略makefile中的(@)符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在makefile文件中,以符号>开头的行会禁用输出.我有一个makefile,其中每行都以at开头,但是对于调试,我需要查看发生了什么.有没有办法告诉make忽略at并输出行?调试过多,并且-n选项将其打印出来,但不执行任何操作(适用于空运行)

In makefiles, a line prefixed with an at symbols disables the print of the output. I have a makefile where every line is prefixed with an at, but for debug I need to see what's going on. Is there a way to tell make to ignore the at and output the line ? the debug is excessive, and the -n option prints them, but does not do anything (it's for dry run)

推荐答案

设置一个默认值为@的变量:

Make a variable that has a default value of @:

AT := @

然后在您的Makefile中使用它:

foo:
    $(AT)fooc -o $@

然后以make AT=身份运行make.如果您愿意,您可以得到比这更奇特的产品:

Then run make as make AT=. You can get fancier than that, if you like:

V := 0
AT_0 := @
AT_1 :=
AT = $(AT_$(V))

除非V设置为1(例如make V=1),否则这将使命令静音.这使用了非POSIX,但递归变量扩展的常见功能.

This will make commands silent, unless V is set to 1 (e.g., make V=1). This uses the non-POSIX, but common feature of recursive variable expansion.

这篇关于忽略makefile中的(@)符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

查看更多