]> git.neil.brown.name Git - wiggle.git/commitdiff
Extract version information from 'git' if possible.
authorNeilBrown <neilb@suse.de>
Thu, 28 Mar 2013 01:53:57 +0000 (12:53 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 28 Mar 2013 01:53:57 +0000 (12:53 +1100)
The version number (and date) reported by "wiggle -V" now
includes information from 'git' if the code was build from a
git repo rather than from a tar-ball.

Suggested-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: NeilBrown <neilb@suse.de>
Makefile
ReadMe.c

index e5dbcfb351e8bff54cdfd38240dd78afe1ab2f31..850d68116970b492b1015081d35cbc539a5f5168 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,10 +18,15 @@ all: wiggle wiggle.man test
 
 wiggle : wiggle.o load.o parse.o split.o extract.o diff.o bestmatch.o ReadMe.o \
               merge2.o vpatch.o ccan/hash/hash.o
-wiggle.o load.o parse.o split.o extract.o diff.o bestmatch.o ReadMe.o \
+wiggle.o load.o parse.o split.o extract.o diff.o bestmatch.o \
                merge2.o vpatch.o :: wiggle.h
 split.o :: ccan/hash/hash.h config.h
 
+VERSION = $(shell [ -d .git ] && git describe HEAD)
+VERS_DATE = $(shell [ -d .git ] && git log -n1 --format=format:%cd --date=short)
+DVERS = $(if $(VERSION),-DVERSION=\"$(VERSION)\",)
+DDATE = $(if $(VERS_DATE),-DVERS_DATE=\"$(VERS_DATE)\",)
+CFLAGS += $(DVERS) $(DDATE)
 
 test: wiggle dotest
        ./dotest
@@ -45,7 +50,7 @@ install : wiggle wiggle.1
 
 version : ReadMe.c wiggle.1
        @rm -f version
-       @sed -n -e 's/.*wiggle \([0-9.]*\) .*/\1/p' ReadMe.c > .version-readme
+       @sed -n -e 's/.*VERSION "\([0-9.]*\)".*/\1/p' ReadMe.c > .version-readme
        @sed -n -e 's/.*WIGGLE 1 "" v\([0-9.]*\)$$/\1/p' wiggle.1 > .version-man
        @cmp -s .version-readme .version-man && cat .version-man > version || { echo Inconsistant versions.; exit 1;}
 
index 1a171a2ddd43ea53e7fd02b817d6460b5f8bcbf7..255acd8c34ab6fc95ff8f2ebe4702804cc4bd7d5 100644 (file)
--- a/ReadMe.c
+++ b/ReadMe.c
 
 #include "wiggle.h"
 
-char Version[] = "wiggle 0.9 2012-05-14 GPL-2+ http://neil.brown.name/wiggle/\n";
+#ifndef VERSION
+#define VERSION "0.9"
+#endif
+#ifndef VERS_DATE
+#define VERS_DATE "2012-05-14"
+#endif
+
+char Version[] = "wiggle " VERSION " " VERS_DATE " GPL-2+ http://neil.brown.name/wiggle/\n";
 
 char short_options[] = "xdmwlrhiW123p::VRvqBb";