From 54f08f2bdb5c0eb2696f2ee5f30d72f6a2bf3b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Wed, 9 Mar 2016 14:44:48 +0200 Subject: [PATCH] Use output of git describe as version. --- src/Makefile.am | 1 + src/global.h | 4 +++- tools/version.sh | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 tools/version.sh diff --git a/src/Makefile.am b/src/Makefile.am index 9d3bc609..626f7578 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,6 +31,7 @@ kvazaar_SOURCES = \ yuv_io.h kvazaar_LDADD = libkvazaar.la $(LIBS) +kvazaar_CPPFLAGS = -DKVZ_VERSION="`$(srcdir)/../tools/version.sh`" libkvazaar_la_SOURCES = \ bitstream.c \ diff --git a/src/global.h b/src/global.h index 952bf877..ba97a54f 100644 --- a/src/global.h +++ b/src/global.h @@ -181,7 +181,9 @@ typedef int16_t coeff_t; // NOTE: When making a release, check to see if incrementing libversion in // configure.ac is necessary. -#define KVZ_VERSION 0.8.3 +#ifndef KVZ_VERSION +#define KVZ_VERSION v0.8.3 +#endif #define VERSION_STRING QUOTE_EXPAND(KVZ_VERSION) //#define VERBOSE 1 diff --git a/tools/version.sh b/tools/version.sh new file mode 100755 index 00000000..07dffd30 --- /dev/null +++ b/tools/version.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +cd "$(dirname "$0")" +cd .. + +if type git >/dev/null 2>/dev/null && [ -d .git ]; then + version="$(git describe --dirty --tags --match 'v*')" +else + version="$(awk '/#define KVZ_VERSION/ { print $3 }' src/global.h)" +fi + +printf '%s\n' "$version"