Makefie: Give the main build the silent treatment.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 31 May 2011 20:44:41 +0000 (21:44 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 31 May 2011 20:44:41 +0000 (21:44 +0100)
Makefile

index 7fff00d..242bbfd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -35,6 +35,30 @@ default: all
 .PHONY: default
 
 ###--------------------------------------------------------------------------
+### Clever silent-rules stuff.
+
+## Verbosity switch.
+V                       = 0
+
+## Suppressing command output.
+V_AT                    = $(V_AT_$V)
+V_AT_0                  = @
+V_AT_1                  =
+
+## Replacing them with messages.
+v_echo                  = $(call v_echo_$V,$1)
+v_echo_0                = @printf "  %-6s %s\n" "$1" "$@";
+v_echo_1                =
+
+## Hacking.
+empty                   =
+space                   = $(empty) $(empty)
+
+## Specific commands.
+V_M4                    = $(call v_echo,M4)m4 -P$(space)
+V_GEN                   = $(call v_echo,GEN)
+
+###--------------------------------------------------------------------------
 ### Local configuration.
 
 ## Should set up HOSTS and add stuff to MAIN_M4_SOURCES if necessary.  Feel
@@ -70,9 +94,8 @@ all: $(TARGETS)
 .PHONY: all
 
 %.sh: %.m4 $(M4_SOURCES)
-       m4 -P base.m4 $*.m4 $(MAIN_M4_SOURCES) >$@.new
-       chmod +x $@.new
-       mv $@.new $@
+       $(V_M4)base.m4 $*.m4 $(MAIN_M4_SOURCES) >$@.new
+       $(V_AT)chmod +x $@.new && mv $@.new $@
 
 clean:; rm -f $(TARGETS) *.new
 .PHONY: clean