Created
September 3, 2014 16:08
-
-
Save deryni/017dc953c75b9396b80d to your computer and use it in GitHub Desktop.
Automake-style Silent Rules support for GNU Make.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SR_PREFIX ?= SR | |
# Manual automake silent rule stuff | |
$(SR_PREFIX)_DEFAULT_VERBOSITY = 0 | |
$(SR_PREFIX)_SILENT_VERBOSITY = -1 | |
V ?= $($(SR_PREFIX)_DEFAULT_VERBOSITY) | |
SILENT := $(and $(filter $($(SR_PREFIX)_SILENT_VERBOSITY),$(V)),silent) | |
DEFAULT := $(and $(filter $($(SR_PREFIX)_DEFAULT_VERBOSITY),$(V)),default) | |
VERBOSE := $(and $(filter-out $($(SR_PREFIX)_SILENT_VERBOSITY) $($(SR_PREFIX)_DEFAULT_VERBOSITY),$(V)),verbose) | |
VERBOSITY_MODE := $(or $(SILENT),$(DEFAULT),$(VERBOSE)) | |
NOT_SILENT := $(filter-out silent, $(VERBOSITY_MODE)) | |
NOT_DEFAULT := $(filter-out default, $(VERBOSITY_MODE)) | |
NOT_VERBOSE := $(filter-out verbose, $(VERBOSITY_MODE)) | |
define vrule | |
$(SR_PREFIX)_V_$(1) = $$($(SR_PREFIX)_V_$(1)_$$(V)) | |
$(SR_PREFIX)_V_$(1)_ = $$($(SR_PREFIX)_V_$(1)_$$($(SR_PREFIX)_DEFAULT_VERBOSITY)) | |
$(SR_PREFIX)_V_$(1)_$($(SR_PREFIX)_DEFAULT_VERBOSITY) = @echo $(2); | |
$(SR_PREFIX)_V_$(1)_$($(SR_PREFIX)_SILENT_VERBOSITY) := @ | |
ifndef $(SR_PREFIX)_V_$(1)_$(V) | |
$(SR_PREFIX)_V_$(1)_$(V) := | |
endif | |
endef | |
# -n prevents echo from printing an empty line. | |
$(eval $(call vrule,AT,-n)) | |
$(eval $(call vrule,GEN,GEN $$@)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment