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"