summaryrefslogtreecommitdiff
path: root/m4/fp_compare_versions.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/fp_compare_versions.m4')
-rw-r--r--m4/fp_compare_versions.m427
1 files changed, 27 insertions, 0 deletions
diff --git a/m4/fp_compare_versions.m4 b/m4/fp_compare_versions.m4
new file mode 100644
index 0000000000..5acab9e4ff
--- /dev/null
+++ b/m4/fp_compare_versions.m4
@@ -0,0 +1,27 @@
+# FP_COMPARE_VERSIONS(VERSION1, TEST, VERSION2, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+# ----------------------------------------------------------------------------------
+# Compare dotted version numbers VERSION1 and VERSION2 lexicographically according
+# to TEST (one of -eq, -ne, -lt, -le, -gt, or -ge).
+AC_DEFUN([FP_COMPARE_VERSIONS],
+[fp_version1=$1; fp_version2=$3
+fp_save_IFS=$IFS; IFS='.'
+while test x"$fp_version1" != x || test x"$fp_version2" != x
+do
+
+ set dummy $fp_version1; shift
+ fp_num1=""
+ test $[@%:@] = 0 || { fp_num1="[$]1"; shift; }
+ test x"$fp_num1" = x && fp_num1="0"
+ fp_version1="[$]*"
+
+ set dummy $fp_version2; shift
+ fp_num2=""
+ test $[@%:@] = 0 || { fp_num2="[$]1"; shift; }
+ test x"$fp_num2" = x && fp_num2="0"
+ fp_version2="[$]*"
+
+ test "$fp_num1" = "$fp_num2" || break;
+done
+IFS=$fp_save_IFS
+AS_IF([test "$fp_num1" $2 "$fp_num2"], [$4], [$5])[]dnl
+])# FP_COMPARE_VERSIONS