aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schink <jaylink-dev@marcschink.de>2016-10-11 16:35:29 +0200
committerMarc Schink <jaylink-dev@marcschink.de>2016-10-25 21:49:32 +0200
commitcec02b8a258f91c8c6a4a088af02d165b90e95dc (patch)
tree2cf951146df63bf8dd2554d3ebabb4c88b7acbe8
parent7b3f7bf1086b79de4830c719d8265c3546f07e07 (diff)
Append Git revision hash to package version
Append the short Git revision hash of the current commit to the package version if there is no release tag for the package version on it and Git is available. This makes the package version more informative and allows the distinction between development and release versions. This code is inspired by, but not derived from, a patch from Daniel Elstner for the libsigrok project. Signed-off-by: Marc Schink <jaylink-dev@marcschink.de>
-rw-r--r--.gitignore3
-rwxr-xr-xautogen.sh2
-rw-r--r--configure.ac21
-rw-r--r--m4/jaylink.m463
4 files changed, 69 insertions, 20 deletions
diff --git a/.gitignore b/.gitignore
index 77ed65b..26903ee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,7 +13,8 @@ libjaylink.pc
.libs
libtool
*.lo
-m4
+m4/libtool.m4
+m4/lt*.m4
Makefile
Makefile.in
*.o
diff --git a/autogen.sh b/autogen.sh
index b5969b2..1df262f 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -28,7 +28,7 @@ fi
echo "Generating build system..."
$LIBTOOLIZE --install --copy || exit 1
-aclocal || exit 1
+aclocal -I m4 || exit 1
autoheader || exit 1
autoconf || exit 1
automake --add-missing --copy || exit 1
diff --git a/configure.ac b/configure.ac
index e8780fc..37d8f80 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,14 +19,7 @@
AC_PREREQ([2.64])
-# Package version of libjaylink. This is not the same as the libtool interface
-# version.
-m4_define([jaylink_version_package_major], [0])
-m4_define([jaylink_version_package_minor], [1])
-m4_define([jaylink_version_package_micro], [0])
-m4_define([jaylink_version_package], [jaylink_version_package_major.jaylink_version_package_minor.jaylink_version_package_micro])
-
-AC_INIT([libjaylink], [jaylink_version_package], [BUG-REPORT-ADDRESS])
+AC_INIT([libjaylink], [0.1.0], [BUG-REPORT-ADDRESS])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
@@ -69,6 +62,8 @@ AC_C_BIGENDIAN
# Disable progress and informational output of libtool.
AC_SUBST([AM_LIBTOOLFLAGS], '--silent')
+JAYLINK_SET_PACKAGE_VERSION([JAYLINK_VERSION_PACKAGE], [AC_PACKAGE_VERSION])
+
# Libtool interface version of libjaylink. This is not the same as the package
# version. For information about the versioning system of libtool, see:
# http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
@@ -95,16 +90,6 @@ AS_IF([test "x$enable_subproject_build" != "xyes"],
AC_SUBST([JAYLINK_LIB_LDFLAGS])
-JAYLINK_VERSION_PACKAGE_MAJOR=jaylink_version_package_major
-JAYLINK_VERSION_PACKAGE_MINOR=jaylink_version_package_minor
-JAYLINK_VERSION_PACKAGE_MICRO=jaylink_version_package_micro
-JAYLINK_VERSION_PACKAGE=jaylink_version_package
-
-AC_SUBST([JAYLINK_VERSION_PACKAGE_MAJOR])
-AC_SUBST([JAYLINK_VERSION_PACKAGE_MINOR])
-AC_SUBST([JAYLINK_VERSION_PACKAGE_MICRO])
-AC_SUBST([JAYLINK_VERSION_PACKAGE])
-
# Use C99 compatible stdio functions on MinGW instead of the incompatible
# functions provided by Microsoft.
AS_CASE([$host_os], [mingw*],
diff --git a/m4/jaylink.m4 b/m4/jaylink.m4
new file mode 100644
index 0000000..409fc9f
--- /dev/null
+++ b/m4/jaylink.m4
@@ -0,0 +1,63 @@
+##
+## This file is part of the libjaylink project.
+##
+## Copyright (C) 2016 Marc Schink <jaylink-dev@marcschink.de>
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+##
+
+# serial 20161011
+
+## _JAYLINK_SET_PACKAGE_VERSION(prefix, version, major, minor, micro)
+##
+m4_define([_JAYLINK_SET_PACKAGE_VERSION], [
+ m4_assert([$# == 5])
+
+ # Get the short Git revision hash of the current commit.
+ git_version=`git rev-parse --short HEAD 2> /dev/null`
+
+ # Try to get the release tag for the package version from the current
+ # commit.
+ tag=`git describe --match "$2" --exact-match 2> /dev/null`
+
+ version=$2
+
+ # If Git is available, append the short Git revision hash of the
+ # current commit to the version string if there is no release tag for
+ # the package version on it.
+ AS_IF([test -n "$git_version" && test -z "$tag"],
+ [version="$version-git-$git_version"])
+
+ AC_SUBST([$1_MAJOR], [$3])
+ AC_SUBST([$1_MINOR], [$4])
+ AC_SUBST([$1_MICRO], [$5])
+ AC_SUBST([$1], [$version])
+])
+
+## JAYLINK_SET_PACKAGE_VERSION(prefix, version)
+##
+## Parse the package version string of the format <major>.<minor>.<micro> and
+## set the variables <prefix>_{MAJOR,MINOR,MICRO} to their corresponding
+## values.
+##
+## Set the variable <prefix> to the package version string. If Git is
+## available, append the short Git revision hash of the current commit to the
+## version string if there is no release tag for the package version on it.
+##
+AC_DEFUN([JAYLINK_SET_PACKAGE_VERSION], [
+ m4_assert([$# == 2])
+
+ _JAYLINK_SET_PACKAGE_VERSION([$1], [$2],
+ m4_unquote(m4_split(m4_expand([$2]), [\.])))
+])