diff --git a/Makefile.am b/Makefile.am index d286c4b..005e5f1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -83,6 +83,8 @@ EXTRA_DIST += \ LICENSE \ README.md \ config.rpath \ + configure.version \ + Version \ gettext.h \ usb-ids.h \ po/README.md diff --git a/Version b/Version new file mode 100644 index 0000000..7179039 --- /dev/null +++ b/Version @@ -0,0 +1 @@ +0.2.3 diff --git a/configure.ac b/configure.ac index 0f22393..6ab79cc 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0 -AC_INIT([x52pro-linux], [0.2.3], [nirenjan@gmail.com]) +AC_INIT([x52pro-linux], [m4_esyscmd_s([cat ./Version])], [nirenjan@gmail.com]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) AC_REQUIRE_AUX_FILE([tap-driver.sh]) @@ -26,6 +26,8 @@ AX_GCC_FUNC_ATTRIBUTE([format]) AX_GCC_FUNC_ATTRIBUTE([noreturn]) AC_C_TYPEOF +AC_DEFINE([BUILD_VERSION], ["m4_esyscmd([./configure.version])"], [Build version]) + AC_MSG_NOTICE([Detected host OS is ${host_os}]) build_linux=no # Detect target system diff --git a/configure.version b/configure.version new file mode 100755 index 0000000..ff6c3e7 --- /dev/null +++ b/configure.version @@ -0,0 +1,34 @@ +#!/bin/sh +# Use the Git version if Git is available, otherwise fallback to Version + +top_srcdir="${1-.}" +test -d "${top_srcdir}" || { \ + echo "FATAL: Could not change to top_srcdir '$1'" >&2 ; \ + exit 1 ; \ +} + +version="${top_srcdir}/Version" + +# Use GIT_DIR if set +if ! test -n "${GIT_DIR}" +then + GIT_DIR="${top_srcdir}/.git" + export GIT_DIR +fi + +if test -d "${GIT_DIR}" +then + # Change tags like vX.Y.Z to X.Y.Z + DESCRIBE=$(git describe --dirty 2>/dev/null) +fi + +if test ! -n "${DESCRIBE}" +then + DESCRIBE="unknown-version" + if test -f "${version}" + then + DESCRIBE="v$(cat "${version}")" + fi +fi + +printf "%s" "${DESCRIBE}"