all repos — cgit @ d6768a67093166810621d2521f10fd016bd75721

a hyperfast web frontend for git written in c

cgit.mk: don't rebuild everything if CGIT_VERSION changes

If CGIT_VERSION is in CGIT_CFLAGS then a change in version (for example
because you have committed your changes) causes all of the CGit objects
to be rebuilt.  Avoid this by using EXTRA_CPPFLAGS to add the version
for only those files that are affected and make them depend on VERSION.

Signed-off-by: John Keeping <john@keeping.me.uk>
John Keeping john@keeping.me.uk
Wed, 06 Mar 2013 21:22:08 +0000
commit

d6768a67093166810621d2521f10fd016bd75721

parent

1a6feaf5fafdaec4a1adb1c0d54b95106122ede5

1 files changed, 8 insertions(+), 1 deletions(-)

jump to
M cgit.mkcgit.mk

@@ -15,7 +15,6 @@ .PHONY: force-version

# CGIT_CFLAGS is a separate variable so that we can track it separately # and avoid rebuilding all of Git when these variables change. -CGIT_CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' CGIT_CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' CGIT_CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' CGIT_CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"'

@@ -52,6 +51,14 @@ CGIT_OBJ_NAMES += ui-tree.o

CGIT_OBJ_NAMES += vector.o CGIT_OBJS := $(addprefix $(CGIT_PREFIX),$(CGIT_OBJ_NAMES)) + +# Only cgit.c reference CGIT_VERSION so we only rebuild its objects when the +# version changes. +CGIT_VERSION_OBJS := $(addprefix $(CGIT_PREFIX),cgit.o) +$(CGIT_VERSION_OBJS): $(CGIT_PREFIX)VERSION +$(CGIT_VERSION_OBJS): EXTRA_CPPFLAGS = \ + -DCGIT_VERSION='"$(CGIT_VERSION)"' + ifeq ($(wildcard $(CGIT_PREFIX).depend),) missing_dep_dirs += $(CGIT_PREFIX).depend