[PATCH v3 3/4] cgit.mk: don't rebuild everything if CGIT_VERSION changes

John Keeping john at keeping.me.uk
Wed Mar 6 22:22:08 CET 2013

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 at keeping.me.uk>
Changes since v2:

- With the previous patch, ui-patch.c no longer references CGIT_VERSION
  so ui-patch.o is removed from CGIT_VERSION_OBJS.

 cgit.mk | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/cgit.mk b/cgit.mk
index 4869c55..c8ecd3a 100644
--- a/cgit.mk
+++ b/cgit.mk
@@ -15,7 +15,6 @@ $(CGIT_PREFIX)VERSION: 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.
@@ -53,6 +52,14 @@ CGIT_OBJ_NAMES += vector.o
+# Only cgit.c reference CGIT_VERSION so we only rebuild its objects when the
+# version changes.
+CGIT_VERSION_OBJS := $(addprefix $(CGIT_PREFIX),cgit.o)
 ifeq ($(wildcard $(CGIT_PREFIX).depend),)
 missing_dep_dirs += $(CGIT_PREFIX).depend

More information about the CGit mailing list