Add automatic HG changeset id information in "-v" param
authorMatteo Facchinetti
Thu, 25 Aug 2011 17:22:44 +0200
changeset 370 f3cec8694f65
parent 369 569e7d9e2406
child 371 926490780952
Add automatic HG changeset id information in "-v" param
Makefile.am
Makefile.in
main.cc
--- a/Makefile.am	Thu Aug 25 08:56:28 2011 +0200
+++ b/Makefile.am	Thu Aug 25 17:22:44 2011 +0200
@@ -6,6 +6,9 @@
 
 ACLOCAL_AMFLAGS=-I config
 
+HGVERSION= $(shell hg -R $(top_srcdir) parents --template '{node|short}' 2> /dev/null || grep node $(top_srcdir)/.hg_archival.txt 2> /dev/null || true )
+AM_CXXFLAGS += -DHGVERSION="\"${HGVERSION}\""
+
 iec2c_LDADD = stage1_2/libstage1_2.a \
 	stage3/libstage3.a \
 	stage4/generate_c/libstage4_c.a \
--- a/Makefile.in	Thu Aug 25 08:56:28 2011 +0200
+++ b/Makefile.in	Thu Aug 25 17:22:44 2011 +0200
@@ -220,9 +220,11 @@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-AM_CXXFLAGS = -g -Wall -Wpointer-arith -Wwrite-strings -Wno-unused 
+AM_CXXFLAGS = -g -Wall -Wpointer-arith -Wwrite-strings -Wno-unused \
+	-DHGVERSION="\"${HGVERSION}\""
 SUBDIRS = absyntax absyntax_utils stage1_2 stage3 stage4 
 ACLOCAL_AMFLAGS = -I config
+HGVERSION = $(shell hg -R $(top_srcdir) parents --template '{node|short}' 2> /dev/null || grep node $(top_srcdir)/.hg_archival.txt 2> /dev/null || true )
 iec2c_LDADD = stage1_2/libstage1_2.a \
 	stage3/libstage3.a \
 	stage4/generate_c/libstage4_c.a \
--- a/main.cc	Thu Aug 25 08:56:28 2011 +0200
+++ b/main.cc	Thu Aug 25 17:22:44 2011 +0200
@@ -135,7 +135,8 @@
       printusage(argv[0]);
       return 0;
     case 'v':
-      fprintf(stdout, "%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION);      
+      fprintf(stdout, "%s version %s\n"
+		      "changeset id: %s\n", PACKAGE_NAME, PACKAGE_VERSION, HGVERSION);      
       return 0;        
     case 'f':
       stage1_2_options.full_token_loc = true;