Add Version file and associated scripts

When building from source, it is desired that we embed the version
string into the resulting binaries so that we can determine exactly what
version of the sources were used.

This change adds a Version file, which always holds the latest release
version, and a configure.version script, which tries to get the version
information from Git, before falling back to using the version embedded
in the above file. The generated configure script will then have the
version embedded within it, which will then create the BUILD_VERSION
definition in config.h. Applications can then use this definition as
needed.
reverse-scroll
nirenjan 2021-09-22 01:37:57 -07:00
parent 5f21ccd2e9
commit ba936df6f8
4 changed files with 40 additions and 1 deletions

View File

@ -83,6 +83,8 @@ EXTRA_DIST += \
LICENSE \
README.md \
config.rpath \
configure.version \
Version \
gettext.h \
usb-ids.h \
po/README.md

1
Version 100644
View File

@ -0,0 +1 @@
0.2.3

View File

@ -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

34
configure.version 100755
View File

@ -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}"