Search code examples
makefile

How to detect if the makefile `--silent/--quiet` command line option was set?


How to detect if the makefile --silent / --quiet command line options was set?

Related questions:

  1. how to detect if --quiet option is specified with rake

Solution

  • I think you need:

    $(findstring s,$(word 1, $(MAKEFLAGS)))
    

    Because MAKEFLAGS has long options, too, eg:

    MAKEFLAGS=s -j80 --jobserver-auth=4,6
    

    So, IOW:

     # Set SILENT to 's' if --quiet/-s set, otherwise ''.
     SILENT := $(findstring s,$(word 1, $(MAKEFLAGS)))