Search code examples
makefilegnu-make

GNU Make silent by default


Is it possible to suppress command echoing by default from within the Makefile?

I know that running make in --silent mode will do it, as will prefixing every command with @.

I'm looking for a command or stanza I can include inside the Makefile, saving the trouble of littering everything with @ or having the user silence everything manually.


Solution

  • If you define the target .SILENT:, then make will not echo anything. It's usually best to guard the definition, so you can easily turn it off:

    ifndef VERBOSE
    .SILENT:
    endif
    

    Now by default, make will print nothing, but if you run make VERBOSE=1, it will print.

    Note that despite the statement in the manual claiming that .SILENT is obsolete -- if properly guarded, it is generally much better (more useful and flexible) than @.