aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2024-12-11 22:55:28 +0100
committerRodrigo Arias Mallo <rodarima@gmail.com>2024-12-11 22:55:28 +0100
commitc04640262ac7f4afa19f750744a5e3aff0071d5f (patch)
tree86354cd9f1e2bc613c794f95120aeafbd593ad83 /src
parent07dd1aba3284761c20d9c87a81967c84c8a98cf2 (diff)
Avoid rebuild when the git commit is the same
Compare the commit used in the last rebuild to determine if it has changed, rather than using a phony target which always causes a rebuild.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index c0205f7d..9943b088 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -144,10 +144,14 @@ dillo.$(OBJEXT): commit.h
CLEANFILES = commit.h
if GIT_AVAILABLE
-# Always rebuild
-.PHONY: commit.h
-commit.h:
- printf '#define GIT_COMMIT "%s"\n' `git --work-tree="$(top_srcdir)" describe --dirty` > commit.h
+# Rebuild commit.tmp.h every time, but only change commit.h
+# if the version is different to avoid rebuilds.
+commit.h: commit.tmp.h
+ test -f $@ || (echo "" > $@)
+ if diff $@ $^ >/dev/null; then rm $^; else mv $^ $@; fi
+
+commit.tmp.h:
+ printf '#define GIT_COMMIT "%s"\n' `git --work-tree="$(top_srcdir)" describe --dirty` > $@
else
# No need to rebuild
commit.h: