Makefile: Sink the silent-rules machinery.
[preload-hacks] / Makefile
index 519270e..9733bc1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -44,24 +44,6 @@ man1dir                       = ${mandir}/man1
 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    $@";
-
-###--------------------------------------------------------------------------
 ### Build parameters.
 
 ## Mess with these if you like.
@@ -78,10 +60,20 @@ INST_BIN             = $(INSTALL) -c -m755
 MKDIRS                  = $(INSTALL) -d -m755
 
 ## Probably best if you leave these alone.
-REAL_CFLAGS             = $(CFLAGS) -fPIC
+REAL_CFLAGS             = $(CFLAGS) -fPIC -MD
 REAL_LDFLAGS            = $(LDFLAGS) -shared
 
 ###--------------------------------------------------------------------------
+### Quiet building.
+
+## Verbosity.
+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                  = @
+
+###--------------------------------------------------------------------------
 ### Main targets.
 
 ## noip
@@ -138,28 +130,30 @@ DISTFILES         += $(patsubst %, debian/%.lintian-overrides, \
 ###--------------------------------------------------------------------------
 ### Building.
 
-all: $(TARGETS)
+all:: $(TARGETS)
 .PHONY: ALL
 
 CLEAN                  += $(TARGETS)
-CLEAN                  += *.o
-clean:
+CLEAN                  += *.o *.d
+clean::
        rm -f $(CLEAN)
 .PHONY: 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))
+
 ###--------------------------------------------------------------------------
 ### Installation.