双重"at"(@@)符号在Makefile中的作用是什么?

Chr*_*s M 10 bash makefile

我经常看到Makefiles用"@"符号启动命令来抑制正常输出.

target: test
    @echo foo
Run Code Online (Sandbox Code Playgroud)

有这个输出:

$ make test
foo
Run Code Online (Sandbox Code Playgroud)

但我常常在命令前面遇到带有@@的Makefiles:

target: test
    @@echo foo
Run Code Online (Sandbox Code Playgroud)

据我所知,输出与echo命令之前只有一个@的Makefiles相同.

有什么不同?

(@@似乎是常见做法,如此Google代码搜索所示:http://www.google.com/codesearch#search/&q=@@echo%20makefile&type=cs)

Eri*_*ski 6

在OpusMake中,@@意思是"真的,非常安静".它会导致OpusMake禁止打印命令,即使在调用时也是如此make -n.可能有人在某个地方对这个功能有一定的了解,编写了他们的makefile以使用它,有人看到它并复制它,并且因为它没有破坏其他make变种(至少,不是GNU make),它只是停留在.


era*_*ran 4

查看代码,似乎它只是删除了所有前导@(或+/-),但我不是100%确定(也就是说,您可以根据需要放置尽可能多的@) - 看看job。 make源代码中的c。

while (*p != '\0')
    {
      if (*p == '@')
    flags |= COMMANDS_SILENT;
      else if (*p == '+')
    flags |= COMMANDS_RECURSE;
      else if (*p == '-')
    child->noerror = 1;
      else if (!isblank ((unsigned char)*p))
    break;
      ++p;
    }
Run Code Online (Sandbox Code Playgroud)