[macros PATCH] Handle patch level version checking (x.y.z) in XORG_MACROS_VERSION

Dan Nicholson dbn.lists at gmail.com
Thu Feb 5 12:26:06 PST 2009


Just checking the major and minor version of xorg-macros is not enough
granularity. Awk is used to split out the first three sections of the
version number. If the field is not available, 0 is substituted.

Signed-off-by: Dan Nicholson <dbn.lists at gmail.com>
---
 I only tested this with gawk, but I believe this is portable awk syntax.

 xorg-macros.m4.in |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
index 56ec104..02292c2 100644
--- a/xorg-macros.m4.in
+++ b/xorg-macros.m4.in
@@ -43,18 +43,31 @@ dnl of the copyright holder.
 # See the "minimum version" comment for each macro you use to see what 
 # version you require.
 AC_DEFUN([XORG_MACROS_VERSION],[
-	[XORG_MACROS_needed_version=$1
-	XORG_MACROS_needed_major=`echo $XORG_MACROS_needed_version | sed 's/\..*$//'`
-	XORG_MACROS_needed_minor=`echo $XORG_MACROS_needed_version | sed -e 's/^[0-9]*\.//' -e 's/\..*$//'`]
-	AC_MSG_CHECKING([if xorg-macros used to generate configure is at least ${XORG_MACROS_needed_major}.${XORG_MACROS_needed_minor}])
-	[XORG_MACROS_version=@VERSION@
-	XORG_MACROS_major=`echo $XORG_MACROS_version | sed 's/\..*$//'`
-	XORG_MACROS_minor=`echo $XORG_MACROS_version | sed -e 's/^[0-9]*\.//' -e 's/\..*$//'`]
+	AC_REQUIRE([AC_PROG_AWK])
+	XORG_MACROS_needed_version="$1"
+	XORG_MACROS_needed_major=`echo $XORG_MACROS_needed_version | \
+		$AWK -F . '{if ($[]1) print $[]1; else print 0}'`
+	XORG_MACROS_needed_minor=`echo $XORG_MACROS_needed_version | \
+		$AWK -F . '{if ($[]2) print $[]2; else print 0}'`
+	XORG_MACROS_needed_patch=`echo $XORG_MACROS_needed_version | \
+		$AWK -F . '{if ($[]3) print $[]3; else print 0}'`
+	AC_MSG_CHECKING([if xorg-macros used to generate configure is at least $XORG_MACROS_needed_version])
+	XORG_MACROS_version=@VERSION@
+	XORG_MACROS_major=`echo $XORG_MACROS_version | \
+		$AWK -F . '{if ($[]1) print $[]1; else print 0}'`
+	XORG_MACROS_minor=`echo $XORG_MACROS_version | \
+		$AWK -F . '{if ($[]2) print $[]2; else print 0}'`
+	XORG_MACROS_patch=`echo $XORG_MACROS_version | \
+		$AWK -F . '{if ($[]3) print $[]3; else print 0}'`
 	if test $XORG_MACROS_major -ne $XORG_MACROS_needed_major ; then
+		AC_MSG_RESULT([no, $XORG_MACROS_version])
 		AC_MSG_ERROR([configure built with incompatible version of xorg-macros.m4 - requires version ${XORG_MACROS_major}.x])
 	fi
-	if test $XORG_MACROS_minor -lt $XORG_MACROS_needed_minor ; then
-		AC_MSG_ERROR([configure built with too old of a version of xorg-macros.m4 - requires version ${XORG_MACROS_major}.${XORG_MACROS_minor}.0 or newer])
+	if test $XORG_MACROS_minor -lt $XORG_MACROS_needed_minor || \
+	   { test $XORG_MACROS_minor -eq $XORG_MACROS_needed_minor && \
+	     test $XORG_MACROS_patch -lt $XORG_MACROS_needed_patch; }; then
+		AC_MSG_RESULT([no, $XORG_MACROS_version])
+		AC_MSG_ERROR([configure built with too old of a version of xorg-macros.m4])
 	fi
 	AC_MSG_RESULT([yes, $XORG_MACROS_version])
 ]) # XORG_MACROS_VERSION
-- 
1.5.6.6




More information about the xorg mailing list