From 6376dcc0da2f8329e6d0520fbd3fe42a7fc2830d Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 12 Nov 2012 17:35:53 +0100
Subject: [PATCH] Improve make regen-vcs-version

"make regen-vcs-version" is run at every ./devel/upload time, in order
to have reasonably up-to-date information in the uploaded
scripts/binaries. However, this means it currently triggers
recompilation of (at least) Ganeti/Version.hs, and sometimes more than
that.

Since we only care about the contents of the file and not the
timestamp, let's change the make rule so that it only updates the file
if there are actually changes in the content, as checked by
"cmp". This results in a much faster ./devel/upload, especially for
small changes in the (non-Haskell) code, or when the code has already
been compiled.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 Makefile.am | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index d6bf864b9..ea3840764 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1155,11 +1155,14 @@ clean-vcs-version:
 
 .PHONY: regen-vcs-version
 regen-vcs-version:
-	set -e; \
+	@set -e; \
 	cd $(srcdir); \
 	if test -d .git; then \
-	  $(MAKE) $(AM_MAKEFLAGS) clean-vcs-version; \
-	  $(MAKE) $(AM_MAKEFLAGS) vcs-version; \
+	  T=`mktemp` ; trap 'rm -f $$T' EXIT; \
+	  git describe > $$T; \
+	  if ! cmp --quiet $$T vcs-version; then \
+	    mv $$T vcs-version; \
+	  fi; \
 	fi
 
 htools/Ganeti/Version.hs: htools/Ganeti/Version.hs.in \
-- 
GitLab