From 7046ff20f93eca1d850df43fe716922e6d105c1c Mon Sep 17 00:00:00 2001 From: Alon Bar-Lev Date: Sat, 5 May 2012 09:39:42 +0300 Subject: build: add git revision to --version output if build from git repository If source is located at git repository, acquire branch and revision of head to be printed at --version output. Signed-off-by: Alon Bar-Lev Acked-by: David Sommerseth Message-Id: 1336199983-9916-1-git-send-email-alon.barlev@gmail.com URL: http://article.gmane.org/gmane.network.openvpn.devel/6431 Signed-off-by: David Sommerseth --- Makefile.am | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Makefile.am') diff --git a/Makefile.am b/Makefile.am index 7579f72..c580579 100644 --- a/Makefile.am +++ b/Makefile.am @@ -40,10 +40,20 @@ MAINTAINERCLEANFILES = \ $(srcdir)/depcomp $(srcdir)/aclocal.m4 \ $(srcdir)/config.guess $(srcdir)/config.sub +CLEANFILES = \ + config-version.h + EXTRA_DIST = \ contrib \ debug +.PHONY: config-version.h + +if GIT_CHECKOUT +BUILT_SOURCES = \ + config-version.h +endif + SUBDIRS = build distro include src sample doc tests dist_doc_DATA = \ @@ -56,6 +66,7 @@ dist_doc_DATA = \ dist_noinst_DATA = \ .gitignore \ .gitattributes \ + config-version.h.in \ PORTS \ README.IPv6 TODO.IPv6 \ README.polarssl \ @@ -78,3 +89,13 @@ if WIN32 rootdir=$(prefix) root_DATA = version.sh endif + +config-version.h: + @CONFIGURE_GIT_REVISION="`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) rev-parse --symbolic-full-name HEAD`/`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) rev-parse --short=16 HEAD`"; \ + $(SED) "s#@CONFIGURE_GIT_REVISION[@]#$${CONFIGURE_GIT_REVISION}#g" "$(srcdir)/config-version.h.in" > config-version.h.tmp + @if ! [ -f config-version.h ] || ! cmp -s config-version.h.tmp config-version.h; then \ + echo "replacing config-version.h"; \ + mv config-version.h.tmp config-version.h; \ + else \ + rm -f config-version.h.tmp; \ + fi -- cgit