开发者

What does the double "at" (@@) symbol do in a Makefile?

开发者 https://www.devze.com 2023-04-01 01:53 出处:网络
I have often seen Makefiles that start commands with an \"@\" symbol to suppress normal output. target: test

I have often seen Makefiles that start commands with an "@" symbol to suppress normal output.

target: test
    @echo foo

Has this output:

$ make test
foo

But I often encounter Makefiles with @@ in front of commands:

target: test
    @@echo foo

And the output is identical, as far as I can tell, from Makefiles with only one @ before the echo command.

What's the difference?

(The @@ seems to be common practice, as seen by this Google Code search: http://www.go开发者_JAVA百科ogle.com/codesearch#search/&q=@@echo%20makefile&type=cs)


In OpusMake, @@ means, "really, really quiet". It causes OpusMake to suppress printing the commands even when invoked as make -n. Probably somebody, somewhere, had some familiarity with that feature, wrote their makefiles to use it, somebody else saw it and copied it, and since it doesn't break other make variants (at least, not GNU make), it just stuck around.


Looking at the code, it seems that it just strips all the leading @ (or +/-), but I'm not 100% sure (that is, you can put there as many @ as you wish) - look at job.c in make source code.

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;
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号