From: Yann Collet Date: Fri, 16 Oct 2020 07:18:16 +0000 (-0700) Subject: track header dependencies during build X-Git-Tag: v1.4.7~48^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6b87c2b77299cdeabc08e52c4fa14fbe468f5f3;p=thirdparty%2Fzstd.git track header dependencies during build modifying a header file will now trigger recompilation of related *.c units --- diff --git a/programs/Makefile b/programs/Makefile index 4899c69c3..a0dc0fbac 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -15,6 +15,9 @@ # zstd-decompress : decompressor-only version of zstd # ########################################################################## +# verbose mode can be triggered by V=1 or VERBOSE=1 +Q = $(if $(filter 1,$(V) $(VERBOSE)),,@) + ZSTDDIR := ../lib # Version numbers @@ -318,6 +321,28 @@ preview-man: clean-man man man ./zstdgrep.1 man ./zstdless.1 + +# Generate .h dependencies automatically + +MKDIR = mkdir + +DEPDIR := .deps +DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.d + +COMPILE.c = $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c + +%.o : %.c +%.o : %.c $(DEPDIR)/%.d | $(DEPDIR) + $(COMPILE.c) $(OUTPUT_OPTION) $< + +$(DEPDIR): ; $(Q)$(MKDIR) -p $@ + +DEPFILES := $(ZSTDLIB_LOCAL_SRC:%.c=$(DEPDIR)/%.d) +$(DEPFILES): + +include $(wildcard $(DEPFILES)) + + #----------------------------------------------------------------------------- # make install is validated only for Linux, macOS, BSD, Hurd and Solaris targets #-----------------------------------------------------------------------------