changeset 120:a72941c75ca6

Improved building of hgversion to avoid systematic recompilation
author Sebastien Decugis <sdecugis@nict.go.jp>
date Thu, 07 Aug 2008 11:24:40 +0900
parents 039c5384ec7e
children 9f2cd378d020
files waaad/Makefile.am
diffstat 1 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/waaad/Makefile.am	Thu Aug 07 10:38:37 2008 +0900
+++ b/waaad/Makefile.am	Thu Aug 07 11:24:40 2008 +0900
@@ -36,14 +36,28 @@
 		security.h security.c
 
 # Rule to make the hgversion.h file
-hgversion.h:
-	@echo "Rebuilding hgversion.h..."
-	@echo '/* Mercurial repository information, generated on '`date -R`' */' > hgversion.h
-	@if test -d $(srcdir)/../.hg; then echo '#define HG_VERSION "'`cd $(srcdir)/.. && hg log -r tip --template '{rev}:{node|short}'`'"' >> hgversion.h; \
+hgversion.h:	stamp-hg
+	echo "Rebuilding hgversion.h..."
+	echo '/* Mercurial repository information, generated on '`date -R`' */' > hgversion.h
+	if test -d $(srcdir)/../.hg; then echo '#define HG_VERSION "'`cd $(srcdir)/.. && hg log -r tip --template '{rev}:{node|short}'`'"' >> hgversion.h; \
 	else echo '/* No Mercurial repository found */' >> hgversion.h; \
 	fi
 
-.PHONY: hgversion.h
+stamp-hg: stamp-hg.cur
+
+# Currently, this is executed twice... it could be improved.
+stamp-hg.cur:
+	if test -d $(srcdir)/../.hg; \
+	then echo `cd $(srcdir)/.. && hg log -r tip --template '{rev}:{node|short}'` > stamp-hg.cur; \
+	else echo 0 > stamp-hg.cur; \
+	fi
+	if test -e stamp-hg && diff -q stamp-hg stamp-hg.cur ; \
+	then rm stamp-hg.cur; \
+	else mv -f stamp-hg.cur stamp-hg; \
+	fi
+
+.PHONY: stamp-hg.cur
+.SILENT: stamp-hg.cur hgversion.h
 
 clean-local:
 	rm -f hgversion.h
"Welcome to our mercurial repository"