changeset 116:953b8cc6357a

Added support to display Mercurial revision
author Sebastien Decugis <sdecugis@nict.go.jp>
date Tue, 05 Aug 2008 17:26:05 +0900
parents 29e581a70ba6
children 67ec7dba49b1
files configure.ac waaad/Makefile.am waaad/main.c
diffstat 3 files changed, 36 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Mon Aug 04 17:07:27 2008 +0900
+++ b/configure.ac	Tue Aug 05 17:26:05 2008 +0900
@@ -28,6 +28,12 @@
 # Include the macro definition to check the pthread availability
 sinclude(acx_pthread.m4)
 
+# Test the version of the sources
+AS_IF( [test -d $srcdir/.hg], [hgstr=`cd $srcdir && hg log -r tip --template '{rev}:{node|short}'`],
+	      [hgstr='No Mercurial'])
+AC_DEFINE_UNQUOTED([PACKAGE_HG_REVISION], ["$hgstr"], [Mercurial version of package at configure time])
+
+
 #######################
 # Checks for programs
 
--- a/waaad/Makefile.am	Mon Aug 04 17:07:27 2008 +0900
+++ b/waaad/Makefile.am	Tue Aug 05 17:26:05 2008 +0900
@@ -14,7 +14,7 @@
 AM_YFLAGS = -d
 
 # The lex file need bison to output the header file before compiling:
-BUILT_SOURCES = conf-gram.h
+BUILT_SOURCES = conf-gram.h hgversion.h
 
 # We are building the "waaad" program :
 bin_PROGRAMS = waaad
@@ -22,7 +22,7 @@
 # This is the list of sources for "waaad" :
 waaad_SOURCES = waaad-internal.h main.c \
 		conf.h conf.c conf-gram.y conf-token.l \
-		log.h log.c \
+		hgversion.h log.h log.c \
 		extensions.h extensions.c \
 		dictionary.h dictionary.c \
 		dict-base.h dict-base.c \
@@ -35,3 +35,14 @@
 		dispatch.h dispatch.c \
 		security.h security.c
 
+# Rule to make the hgversion.h file
+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
+
+clean-local:
+	rm -f hgversion.h
--- a/waaad/main.c	Mon Aug 04 17:07:27 2008 +0900
+++ b/waaad/main.c	Tue Aug 05 17:26:05 2008 +0900
@@ -42,14 +42,29 @@
  */
 
 #include "waaad-internal.h"
+#include "hgversion.h"
 #include <stdio.h>
 #include <getopt.h>
 
 /* Display package version */
 static void main_version_core(void)
 {
-	printf( "%s (%s) version %s\n",
-		PACKAGE_NAME, PACKAGE_TARNAME, PACKAGE_VERSION);
+	printf("%s (%s) version %s"
+#ifdef PACKAGE_HG_REVISION
+		" - ac:%s"
+#endif /* PACKAGE_HG_VERSION */
+#ifdef HG_VERSION
+		" - cc:%s"
+#endif /* HG_VERSION */
+		"\n", 
+		PACKAGE_NAME, PACKAGE_TARNAME, PACKAGE_VERSION
+#ifdef PACKAGE_HG_REVISION
+		, PACKAGE_HG_REVISION
+#endif /* PACKAGE_HG_VERSION */
+#ifdef HG_VERSION
+		, HG_VERSION
+#endif /* HG_VERSION */
+		);
 }
 
 /* Display package version and general info */
"Welcome to our mercurial repository"