summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-03-09 11:37:18 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-17 19:05:50 -0400
commit84927818ee68c6826327abc26d4647fb56053fb7 (patch)
tree108ab49003f77c80a1b2eeb755df44ecad416f22
parent540fa6b2cff3802877ff56a47ab3611e33a9ac86 (diff)
downloadhaskell-84927818ee68c6826327abc26d4647fb56053fb7.tar.gz
llvmGen: Accept range of LLVM versions
Previously we would support only one LLVM major version. Here we generalize this to accept a range, taking this range to be LLVM 10 to 11, as 11 is necessary for Apple M1 support. We also accept 12, as that is what apple ships with BigSur on the M1.
-rw-r--r--aclocal.m435
-rw-r--r--compiler/GHC/CmmToLlvm.hs11
-rw-r--r--compiler/GHC/CmmToLlvm/Base.hs12
-rw-r--r--compiler/GHC/SysTools/Tasks.hs8
-rw-r--r--configure.ac16
-rw-r--r--distrib/configure.ac.in7
-rw-r--r--ghc.mk9
-rw-r--r--hadrian/src/Rules/BinaryDist.hs3
-rw-r--r--hadrian/src/Rules/SourceDist.hs3
-rw-r--r--m4/ax_compare_version.m4177
10 files changed, 245 insertions, 36 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index be132387f2..d7b6c58f44 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -3,6 +3,8 @@
# To be a good autoconf citizen, names of local macros have prefixed with FP_ to
# ensure we don't clash with any pre-supplied autoconf ones.
+m4_include([m4/ax_compare_version.m4])
+
# FPTOOLS_WRITE_FILE
# ------------------
# Write $2 to the file named $1.
@@ -2249,22 +2251,29 @@ AC_DEFUN([XCODE_VERSION],[
#
# $1 = the variable to set
# $2 = the command to look for
-# $3 = the version of the command to look for
+# $3 = the lower bound version of the command to look for
+# $4 = the upper bound version of the command to look for.
#
AC_DEFUN([FIND_LLVM_PROG],[
# Test for program with and without version name.
- AC_CHECK_TOOLS([$1], [$2-$3 $2-$3.0 $2], [:])
- if test "$$1" != ":"; then
- AC_MSG_CHECKING([$$1 is version $3])
- if test `$$1 --version | grep -c "version $3"` -gt 0 ; then
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- $1=""
- fi
- else
- $1=""
- fi
+ PROG_VERSION_CANDIDATES=$(for llvmVersion in `seq $4 -1 $3`; do echo "$2-$llvmVersion $2-$llvmVersion.0"; done)
+ AC_CHECK_TOOLS([$1], [$PROG_VERSION_CANDIDATES $2], [])
+ AS_IF([test x"$$1" != x],[
+ PROG_VERSION=`$$1 --version | awk '/.*version [[0-9\.]]+/{for(i=1;i<=NF;i++){ if(\$i ~ /^[[0-9\.]]+$/){print \$i}}}'`
+ AS_IF([test x"$PROG_VERSION" == x],
+ [AC_MSG_RESULT(no)
+ $1=""
+ AC_MSG_NOTICE([We only support llvm $3 to $4 (no version found).])],
+ [AC_MSG_CHECKING([$$1 version ($PROG_VERSION) is between $3 and $4])
+ AX_COMPARE_VERSION([$PROG_VERSION], [lt], [$3],
+ [AC_MSG_RESULT(no)
+ $1=""
+ AC_MSG_NOTICE([We only support llvm $3 to $4 (found $PROG_VERSION).])],
+ [AX_COMPARE_VERSION([$PROG_VERSION], [gt], [$4],
+ [AC_MSG_RESULT(no)
+ $1=""
+ AC_MSG_NOTICE([We only support llvm $3 to $4 (found $PROG_VERSION).])],
+ [AC_MSG_RESULT(yes)])])])])
])
# CHECK_LD_COPY_BUG()
diff --git a/compiler/GHC/CmmToLlvm.hs b/compiler/GHC/CmmToLlvm.hs
index 21cfdf6dcd..95b682af38 100644
--- a/compiler/GHC/CmmToLlvm.hs
+++ b/compiler/GHC/CmmToLlvm.hs
@@ -66,7 +66,8 @@ llvmCodeGen logger dflags h cmm_stream
let doWarn = wopt Opt_WarnUnsupportedLlvmVersion dflags
when (not (llvmVersionSupported ver) && doWarn) $ putMsg logger dflags $
"You are using an unsupported version of LLVM!" $$
- "Currently only " <> text (llvmVersionStr supportedLlvmVersion) <> " is supported." <+>
+ "Currently only" <+> text (llvmVersionStr supportedLlvmVersionMin) <+>
+ "to" <+> text (llvmVersionStr supportedLlvmVersionMax) <+> "is supported." <+>
"System LLVM version: " <> text (llvmVersionStr ver) $$
"We will try though..."
let isS390X = platformArch (targetPlatform dflags) == ArchS390X
@@ -75,8 +76,14 @@ llvmCodeGen logger dflags h cmm_stream
"Warning: For s390x the GHC calling convention is only supported since LLVM version 10." <+>
"You are using LLVM version: " <> text (llvmVersionStr ver)
+ -- HACK: the Nothing case here is potentially wrong here but we
+ -- currently don't use the LLVM version to guide code generation
+ -- so this is okay.
+ let llvm_ver :: LlvmVersion
+ llvm_ver = fromMaybe supportedLlvmVersionMin mb_ver
+
-- run code generation
- a <- runLlvm logger dflags (fromMaybe supportedLlvmVersion mb_ver) bufh $
+ a <- runLlvm logger dflags llvm_ver bufh $
llvmCodeGen' dflags cmm_stream
bFlush bufh
diff --git a/compiler/GHC/CmmToLlvm/Base.hs b/compiler/GHC/CmmToLlvm/Base.hs
index a943bfcebb..eda29c1ec7 100644
--- a/compiler/GHC/CmmToLlvm/Base.hs
+++ b/compiler/GHC/CmmToLlvm/Base.hs
@@ -15,7 +15,8 @@ module GHC.CmmToLlvm.Base (
LiveGlobalRegs,
LlvmUnresData, LlvmData, UnresLabel, UnresStatic,
- LlvmVersion, supportedLlvmVersion, llvmVersionSupported, parseLlvmVersion,
+ LlvmVersion, supportedLlvmVersionMin, supportedLlvmVersionMax,
+ llvmVersionSupported, parseLlvmVersion,
llvmVersionStr, llvmVersionList,
LlvmM,
@@ -265,6 +266,7 @@ llvmPtrBits platform = widthInBits $ typeWidth $ gcWord platform
-- Newtype to avoid using the Eq instance!
newtype LlvmVersion = LlvmVersion { llvmVersionNE :: NE.NonEmpty Int }
+ deriving (Eq, Ord)
parseLlvmVersion :: String -> Maybe LlvmVersion
parseLlvmVersion =
@@ -281,11 +283,13 @@ parseLlvmVersion =
(ver_str, rest) = span isDigit s
-- | The LLVM Version that is currently supported.
-supportedLlvmVersion :: LlvmVersion
-supportedLlvmVersion = LlvmVersion (sUPPORTED_LLVM_VERSION NE.:| [])
+supportedLlvmVersionMin, supportedLlvmVersionMax :: LlvmVersion
+supportedLlvmVersionMin = LlvmVersion (sUPPORTED_LLVM_VERSION_MIN NE.:| [])
+supportedLlvmVersionMax = LlvmVersion (sUPPORTED_LLVM_VERSION_MAX NE.:| [])
llvmVersionSupported :: LlvmVersion -> Bool
-llvmVersionSupported (LlvmVersion v) = NE.head v == sUPPORTED_LLVM_VERSION
+llvmVersionSupported v =
+ v > supportedLlvmVersionMin && v <= supportedLlvmVersionMax
llvmVersionStr :: LlvmVersion -> String
llvmVersionStr = intercalate "." . map show . llvmVersionList
diff --git a/compiler/GHC/SysTools/Tasks.hs b/compiler/GHC/SysTools/Tasks.hs
index 694d3155c1..0fb74233fc 100644
--- a/compiler/GHC/SysTools/Tasks.hs
+++ b/compiler/GHC/SysTools/Tasks.hs
@@ -13,7 +13,7 @@ import GHC.Prelude
import GHC.Platform
import GHC.ForeignSrcLang
-import GHC.CmmToLlvm.Base (LlvmVersion, llvmVersionStr, supportedLlvmVersion, parseLlvmVersion)
+import GHC.CmmToLlvm.Base (LlvmVersion, llvmVersionStr, supportedLlvmVersionMin, supportedLlvmVersionMax, llvmVersionStr, parseLlvmVersion)
import GHC.SysTools.Process
import GHC.SysTools.Info
@@ -234,8 +234,10 @@ figureLlvmVersion logger dflags = traceToolCommand logger dflags "llc" $ do
errorMsg logger dflags $ vcat
[ text "Warning:", nest 9 $
text "Couldn't figure out LLVM version!" $$
- text ("Make sure you have installed LLVM " ++
- llvmVersionStr supportedLlvmVersion) ]
+ text ("Make sure you have installed LLVM between "
+ ++ llvmVersionStr supportedLlvmVersionMin
+ ++ " and "
+ ++ llvmVersionStr supportedLlvmVersionMax) ]
return Nothing)
diff --git a/configure.ac b/configure.ac
index 2645ee5aa1..6b772f4a79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -719,10 +719,14 @@ AC_SUBST(InstallNameToolCmd)
# tools we are looking for. In the past, GHC supported a number of
# versions of LLVM simultaneously, but that stopped working around
# 3.5/3.6 release of LLVM.
-LlvmVersion=10
-AC_SUBST([LlvmVersion])
-sUPPORTED_LLVM_VERSION=$(echo \($LlvmVersion\) | sed 's/\./,/')
-AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION], ${sUPPORTED_LLVM_VERSION}, [The supported LLVM version number])
+LlvmMinVersion=10
+LlvmMaxVersion=12 # inclusive
+AC_SUBST([LlvmMinVersion])
+AC_SUBST([LlvmMaxVersion])
+sUPPORTED_LLVM_VERSION_MIN=$(echo \($LlvmMinVersion\) | sed 's/\./,/')
+sUPPORTED_LLVM_VERSION_MAX=$(echo \($LlvmMaxVersion\) | sed 's/\./,/')
+AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION_MIN], ${sUPPORTED_LLVM_VERSION_MIN}, [The minimum supported LLVM version number])
+AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION_MAX], ${sUPPORTED_LLVM_VERSION_MAX}, [The maximum supported LLVM version number])
dnl ** Which LLVM clang to use?
dnl --------------------------------------------------------------
@@ -734,14 +738,14 @@ AC_SUBST([ClangCmd])
dnl ** Which LLVM llc to use?
dnl --------------------------------------------------------------
AC_ARG_VAR(LLC,[Use as the path to LLVM's llc [default=autodetect]])
-FIND_LLVM_PROG([LLC], [llc], [$LlvmVersion])
+FIND_LLVM_PROG([LLC], [llc], [$LlvmMinVersion], [$LlvmMaxVersion])
LlcCmd="$LLC"
AC_SUBST([LlcCmd])
dnl ** Which LLVM opt to use?
dnl --------------------------------------------------------------
AC_ARG_VAR(OPT,[Use as the path to LLVM's opt [default=autodetect]])
-FIND_LLVM_PROG([OPT], [opt], [$LlvmVersion])
+FIND_LLVM_PROG([OPT], [opt], [$LlvmMinVersion], [$LlvmMaxVersion])
OptCmd="$OPT"
AC_SUBST([OptCmd])
diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index 4de89941df..c287c3368d 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -118,19 +118,20 @@ AC_SUBST([StripCmd])
# tools we are looking for. In the past, GHC supported a number of
# versions of LLVM simultaneously, but that stopped working around
# 3.5/3.6 release of LLVM.
-LlvmVersion=@LlvmVersion@
+LlvmMinVersion=@LlvmMinVersion@
+LlvmMaxVersion=@LlvmMaxVersion@
dnl ** Which LLVM llc to use?
dnl --------------------------------------------------------------
AC_ARG_VAR(LLC,[Use as the path to LLVM's llc [default=autodetect]])
-FIND_LLVM_PROG([LLC], [llc], [$LlvmVersion])
+FIND_LLVM_PROG([LLC], [llc], [$LlvmMinVersion], [$LlvmMaxVersion])
LlcCmd="$LLC"
AC_SUBST([LlcCmd])
dnl ** Which LLVM opt to use?
dnl --------------------------------------------------------------
AC_ARG_VAR(OPT,[Use as the path to LLVM's opt [default=autodetect]])
-FIND_LLVM_PROG([OPT], [opt], [$LlvmVersion])
+FIND_LLVM_PROG([OPT], [opt], [$LlvmMinVersion], [$LlvmMaxVersion])
OptCmd="$OPT"
AC_SUBST([OptCmd])
diff --git a/ghc.mk b/ghc.mk
index 61d314c624..f4e9a7655e 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -1079,7 +1079,7 @@ BIN_DIST_MK = $(BIN_DIST_PREP_DIR)/bindist.mk
unix-binary-dist-prep: $(includes_1_H_CONFIG) $(includes_1_H_PLATFORM) $(includes_1_H_VERSION)
$(call removeTrees,bindistprep/)
"$(MKDIRHIER)" $(BIN_DIST_PREP_DIR)
- set -e; for i in packages LICENSE compiler ghc rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh llvm-targets llvm-passes ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$$i $(BIN_DIST_PREP_DIR)/; done
+ set -e; for i in packages LICENSE compiler ghc rts libraries utils docs libffi includes driver mk rules Makefile m4 aclocal.m4 config.sub config.guess install-sh llvm-targets llvm-passes ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$$i $(BIN_DIST_PREP_DIR)/; done
echo "HADDOCK_DOCS = $(HADDOCK_DOCS)" >> $(BIN_DIST_MK)
echo "BUILD_SPHINX_HTML = $(BUILD_SPHINX_HTML)" >> $(BIN_DIST_MK)
echo "BUILD_SPHINX_PDF = $(BUILD_SPHINX_PDF)" >> $(BIN_DIST_MK)
@@ -1172,12 +1172,13 @@ SRC_DIST_TESTSUITE_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_TESTSUITE_NAME).
#
# Files to include in source distributions
#
-SRC_DIST_GHC_DIRS = mk rules docs distrib bindisttest libffi includes \
+SRC_DIST_GHC_DIRS = mk m4 rules docs distrib bindisttest libffi includes \
utils docs rts compiler ghc driver libraries libffi-tarballs \
- hadrian
+ hadrian
SRC_DIST_GHC_FILES += \
configure.ac config.guess config.sub configure \
- aclocal.m4 README.md ANNOUNCE HACKING.md INSTALL.md LICENSE Makefile \
+ aclocal.m4 m4/ax_compare_version.m4 \
+ README.md ANNOUNCE HACKING.md INSTALL.md LICENSE Makefile \
install-sh llvm-targets llvm-passes VERSION GIT_COMMIT_ID \
boot packages ghc.mk MAKEHELP.md
diff --git a/hadrian/src/Rules/BinaryDist.hs b/hadrian/src/Rules/BinaryDist.hs
index 8709de6b26..a527664b23 100644
--- a/hadrian/src/Rules/BinaryDist.hs
+++ b/hadrian/src/Rules/BinaryDist.hs
@@ -203,11 +203,14 @@ bindistRules = do
root -/- "bindist" -/- "ghc-*" -/- "configure" %> \configurePath -> do
ghcRoot <- topDirectory
copyFile (ghcRoot -/- "aclocal.m4") (ghcRoot -/- "distrib" -/- "aclocal.m4")
+ copyDirectory (ghcRoot -/- "m4") (ghcRoot -/- "distrib")
buildWithCmdOptions [] $
target (vanillaContext Stage1 ghc) (Autoreconf $ ghcRoot -/- "distrib") [] []
-- We clean after ourselves, moving the configure script we generated in
-- our bindist dir
removeFile (ghcRoot -/- "distrib" -/- "aclocal.m4")
+ removeDirectory (ghcRoot -/- "distrib" -/- "m4")
+
moveFile (ghcRoot -/- "distrib" -/- "configure") configurePath
-- Generate the Makefile that enables the "make install" part
diff --git a/hadrian/src/Rules/SourceDist.hs b/hadrian/src/Rules/SourceDist.hs
index 78c1539b3d..de35922ae1 100644
--- a/hadrian/src/Rules/SourceDist.hs
+++ b/hadrian/src/Rules/SourceDist.hs
@@ -113,7 +113,8 @@ prepareTree dest = do
, "mk"
, "rts"
, "rules"
- , "utils" ]
+ , "utils"
+ , "m4" ]
srcFiles =
[ "GIT_COMMIT_ID"
, "HACKING.md"
diff --git a/m4/ax_compare_version.m4 b/m4/ax_compare_version.m4
new file mode 100644
index 0000000000..ffb4997e8b
--- /dev/null
+++ b/m4/ax_compare_version.m4
@@ -0,0 +1,177 @@
+# ===========================================================================
+# https://www.gnu.org/software/autoconf-archive/ax_compare_version.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+#
+# DESCRIPTION
+#
+# This macro compares two version strings. Due to the various number of
+# minor-version numbers that can exist, and the fact that string
+# comparisons are not compatible with numeric comparisons, this is not
+# necessarily trivial to do in a autoconf script. This macro makes doing
+# these comparisons easy.
+#
+# The six basic comparisons are available, as well as checking equality
+# limited to a certain number of minor-version levels.
+#
+# The operator OP determines what type of comparison to do, and can be one
+# of:
+#
+# eq - equal (test A == B)
+# ne - not equal (test A != B)
+# le - less than or equal (test A <= B)
+# ge - greater than or equal (test A >= B)
+# lt - less than (test A < B)
+# gt - greater than (test A > B)
+#
+# Additionally, the eq and ne operator can have a number after it to limit
+# the test to that number of minor versions.
+#
+# eq0 - equal up to the length of the shorter version
+# ne0 - not equal up to the length of the shorter version
+# eqN - equal up to N sub-version levels
+# neN - not equal up to N sub-version levels
+#
+# When the condition is true, shell commands ACTION-IF-TRUE are run,
+# otherwise shell commands ACTION-IF-FALSE are run. The environment
+# variable 'ax_compare_version' is always set to either 'true' or 'false'
+# as well.
+#
+# Examples:
+#
+# AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])
+# AX_COMPARE_VERSION([3.15],[lt],[3.15.8])
+#
+# would both be true.
+#
+# AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])
+# AX_COMPARE_VERSION([3.15],[gt],[3.15.8])
+#
+# would both be false.
+#
+# AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])
+#
+# would be true because it is only comparing two minor versions.
+#
+# AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])
+#
+# would be true because it is only comparing the lesser number of minor
+# versions of the two values.
+#
+# Note: The characters that separate the version numbers do not matter. An
+# empty string is the same as version 0. OP is evaluated by autoconf, not
+# configure, so must be a string, not a variable.
+#
+# The author would like to acknowledge Guido Draheim whose advice about
+# the m4_case and m4_ifvaln functions make this macro only include the
+# portions necessary to perform the specific comparison specified by the
+# OP argument in the final configure script.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Tim Toolan <toolan@ele.uri.edu>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 13
+
+dnl #########################################################################
+AC_DEFUN([AX_COMPARE_VERSION], [
+ AC_REQUIRE([AC_PROG_AWK])
+
+ # Used to indicate true or false condition
+ ax_compare_version=false
+
+ # Convert the two version strings to be compared into a format that
+ # allows a simple string comparison. The end result is that a version
+ # string of the form 1.12.5-r617 will be converted to the form
+ # 0001001200050617. In other words, each number is zero padded to four
+ # digits, and non digits are removed.
+ AS_VAR_PUSHDEF([A],[ax_compare_version_A])
+ A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
+ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/[[^0-9]]//g'`
+
+ AS_VAR_PUSHDEF([B],[ax_compare_version_B])
+ B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
+ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/[[^0-9]]//g'`
+
+ dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary
+ dnl # then the first line is used to determine if the condition is true.
+ dnl # The sed right after the echo is to remove any indented white space.
+ m4_case(m4_tolower($2),
+ [lt],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`
+ ],
+ [gt],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`
+ ],
+ [le],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`
+ ],
+ [ge],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`
+ ],[
+ dnl Split the operator from the subversion count if present.
+ m4_bmatch(m4_substr($2,2),
+ [0],[
+ # A count of zero means use the length of the shorter version.
+ # Determine the number of characters in A and B.
+ ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'`
+ ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'`
+
+ # Set A to no more than B's length and B to no more than A's length.
+ A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`
+ B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`
+ ],
+ [[0-9]+],[
+ # A count greater than zero means use only that many subversions
+ A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
+ B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
+ ],
+ [.+],[
+ AC_WARNING(
+ [invalid OP numeric parameter: $2])
+ ],[])
+
+ # Pad zeros at end of numbers to make same length.
+ ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"
+ B="$B`echo $A | sed 's/./0/g'`"
+ A="$ax_compare_version_tmp_A"
+
+ # Check for equality or inequality as necessary.
+ m4_case(m4_tolower(m4_substr($2,0,2)),
+ [eq],[
+ test "x$A" = "x$B" && ax_compare_version=true
+ ],
+ [ne],[
+ test "x$A" != "x$B" && ax_compare_version=true
+ ],[
+ AC_WARNING([invalid OP parameter: $2])
+ ])
+ ])
+
+ AS_VAR_POPDEF([A])dnl
+ AS_VAR_POPDEF([B])dnl
+
+ dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.
+ if test "$ax_compare_version" = "true" ; then
+ m4_ifvaln([$4],[$4],[:])dnl
+ m4_ifvaln([$5],[else $5])dnl
+ fi
+]) dnl AX_COMPARE_VERSION