autoconf: Split PACKAGE_VERSION in four parts
authorTobias Brunner <tobias@strongswan.org>
Mon, 2 Sep 2013 09:26:31 +0000 (11:26 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 2 Sep 2013 09:30:24 +0000 (11:30 +0200)
The parts can be accessed with the variables:

PACKAGE_VERSION_MAJOR
PACKAGE_VERSION_MINOR
PACKAGE_VERSION_BUILD
PACKAGE_VERSION_REVIEW

The last part will be empty for regular releases.

configure.ac
m4/macros/split-package-version.m4 [new file with mode: 0644]

index 2a9504b..06b003c 100644 (file)
@@ -27,6 +27,9 @@ AC_CONFIG_HEADERS([config.h])
 AC_DEFINE([CONFIG_H_INCLUDED], [], [defined if config.h included])
 PKG_PROG_PKG_CONFIG
 
+m4_include(m4/macros/split-package-version.m4)
+SPLIT_PACKAGE_VERSION
+
 # =================================
 #  check --enable-xxx & --with-xxx
 # =================================
diff --git a/m4/macros/split-package-version.m4 b/m4/macros/split-package-version.m4
new file mode 100644 (file)
index 0000000..8f7941d
--- /dev/null
@@ -0,0 +1,17 @@
+# SPLIT_PACKAGE_VERSION
+# ---------------------------
+# Split package version in four parts
+AC_DEFUN([SPLIT_PACKAGE_VERSION],
+       [
+       AC_REQUIRE([AC_PROG_SED])
+       PACKAGE_VERSION_MAJOR=`echo "$PACKAGE_VERSION" | $SED 's/\([[0-9]]\+\).*/\1/'`
+       PACKAGE_VERSION_MINOR=`echo "$PACKAGE_VERSION" | $SED 's/[[0-9]]\+\.\([[0-9]]\+\).*/\1/'`
+       PACKAGE_VERSION_BUILD=`echo "$PACKAGE_VERSION" | $SED 's/[[0-9]]\+\.[[0-9]]\+\.\([[0-9]]\+\).*/\1/'`
+       PACKAGE_VERSION_REVIEW=`echo "$PACKAGE_VERSION" | $SED 's/[[0-9]]\+\.[[0-9]]\+\.[[0-9]]\+\(.*\)/\1/'`
+       AC_SUBST([PACKAGE_VERSION_MAJOR])
+       AC_SUBST([PACKAGE_VERSION_MINOR])
+       AC_SUBST([PACKAGE_VERSION_BUILD])
+       AC_SUBST([PACKAGE_VERSION_REVIEW])
+       ]
+)
+