From c04640262ac7f4afa19f750744a5e3aff0071d5f Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 11 Dec 2024 22:55:28 +0100 Subject: 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. --- src/Makefile.am | 12 ++++++++---- 1 file 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: -- cgit v1.2.3