From: NeilBrown Date: Thu, 28 Mar 2013 01:53:57 +0000 (+1100) Subject: Extract version information from 'git' if possible. X-Git-Tag: v1.0~44 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=6a994ca3d2accbf089ace45c846bff6641a39ca9;p=wiggle.git Extract version information from 'git' if possible. 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 Signed-off-by: NeilBrown --- diff --git a/Makefile b/Makefile index e5dbcfb..850d681 100644 --- 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;} diff --git a/ReadMe.c b/ReadMe.c index 1a171a2..255acd8 100644 --- a/ReadMe.c +++ b/ReadMe.c @@ -29,7 +29,14 @@ #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";