diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-04-02 11:52:47 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-05 05:42:38 -0400 |
commit | 7ffbdc3fa603c6411249ba9b758cf8f109c5fb30 (patch) | |
tree | 8a05d6e03ce2790e6e59651c824e569fee088d33 /m4/find_llvm_prog.m4 | |
parent | 6acadb79afe685c635fd255f90551a0fbfcbe3dc (diff) | |
download | haskell-7ffbdc3fa603c6411249ba9b758cf8f109c5fb30.tar.gz |
Break up aclocal.m4
Diffstat (limited to 'm4/find_llvm_prog.m4')
-rw-r--r-- | m4/find_llvm_prog.m4 | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/m4/find_llvm_prog.m4 b/m4/find_llvm_prog.m4 new file mode 100644 index 0000000000..79a6a502a5 --- /dev/null +++ b/m4/find_llvm_prog.m4 @@ -0,0 +1,32 @@ +# FIND_LLVM_PROG() +# -------------------------------- +# Find where the llvm tools are. We have a special function to handle when they +# are installed with a version suffix (e.g., llc-7, llc-7.0) and without (e.g. +# llc). +# +# $1 = the variable to set +# $2 = 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. + 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)])])])]) +]) |