chiark / gitweb /
Makefile: Refactor the silent-rules machinery.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 6 Jun 2018 20:56:27 +0000 (21:56 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 6 Jun 2018 23:54:08 +0000 (00:54 +0100)
Now it's more like what I do elsewhere.

Makefile

index 4f075250a694d85e8ccb37d4201779f748cc2ac0..f8dadc5ff32dfdc98be839a4005aa88d79286f95 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -47,19 +47,11 @@ DESTDIR                      =
 ### Quiet building.
 
 ## Verbosity.
-V                       = 0
-
-## Compilation.
-V_CC                    = $(V_CC_$(V))$(CC)
-V_CC_0                  = @echo "  CC     $@";
-
-## Linking.
-V_LD                    = $(V_LD_$(V))$(LD)
-V_LD_0                  = @echo "  LD     $@";
-
-## Generation.
-V_GEN                   = $(V_GEN_$(V))
-V_GEN_0                         = @echo "  GEN    $@";
+V                      ?= 0
+v_tag                   = $(call v_tag_$V,$1)
+v_tag_0                         = @printf "  %-8s %s\n" "$1" "$@";
+V_AT                    = $(V_AT_$V)
+V_AT_0                  = @
 
 ###--------------------------------------------------------------------------
 ### Build parameters.
@@ -149,15 +141,15 @@ clean::
 
 ## Building sources.
 %.o: %.c
-       $(V_CC) -c $(REAL_CFLAGS) $< -o $@
+       $(call v_tag,CC)$(CC) -c $(REAL_CFLAGS) $< -o $@
 
 ## Constructing preload hacks.
 $(addsuffix .so,$(HACKS)): %.so: $$(patsubst %.c,%.o,$$($$*_SOURCES))
-       $(V_LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
+       $(call v_tag,LD)$(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
 
 ## Constructing the scripts.
 $(SCRIPTS): %: withlib.in
-       $(V_GEN)sed "s/@lib@/$@/" withlib.in >$@.new && \
+       $(call v_tag,GEN)sed "s/@lib@/$@/" withlib.in >$@.new && \
                chmod +x $@.new && mv $@.new $@
 
 -include $(patsubst %.c,%d,$(ALL_SOURCES))