X-Git-Url: https://git.distorted.org.uk/~mdw/cfd/blobdiff_plain/4cb2b0916988d634cbdff76dd823ff2d85be5689..7cc492bc2769cc3f095aadb86c18e53f7b5fea46:/aclocal.glob diff --git a/aclocal.glob b/aclocal.glob index 6e48f26..957a9d0 100644 --- a/aclocal.glob +++ b/aclocal.glob @@ -39,9 +39,10 @@ dnl ARGS = arguments to pass dnl dnl Use: Like `AC_REQUIRE', only it handles arguments. +m4_define([_m4_divert(mdwdvt_REQUIRE)], 54633) AC_DEFUN([mdw_REQUIRE], [ifdef([AC_PROVIDE_$1], , -[AC_DIVERT_PUSH(builtin(eval, AC_DIVERSION_CURRENT - 1))dnl +[AC_DIVERT_PUSH([mdwdvt_REQUIRE])dnl indir($@) AC_DIVERT_POP()dnl ])]) @@ -173,6 +174,89 @@ else : $4 fi]) +dnl --- *@-mdw__PYTHON_VERSION-@* --- +dnl +dnl Will fail hopelessly on Python < 1.5.2. Nobody uses that any more, +dnl right? + +AC_DEFUN([mdw__PYTHON_VERSION], +[$1 -c 'from sys import *; v = argv[1]; vv = v.split("."); x = 0 +for i in range(len(vv)): x = x | (int(vv[i]) << (24 - i * 8)) +exit(x > hexversion)' $2]) + +dnl --- *@-mdw_PROG_PYTHON-@* --- +dnl +dnl Author: Mark Wooding +dnl +dnl Synopsis: mdw_PROG_PYTHON(VERSION, [IF-FOUND], [IF-NOT-FOUND]) +dnl +dnl Arguments: VERSION = version number of Python required +dnl IF-FOUND = what to do if it's found +dnl IF-NOT-FOUND = what to do if it isn't +dnl +dnl Use: Attempts to find a working version of Python with a late +dnl enough version number. It supplies an option `--with-python' +dnl to allow the user to provide a Python interpreter. If one +dnl isn't provided explicitly, it searches for `python' and +dnl `pythonVERSION' in the current PATH, asking them whether they +dnl have a late enough version number. The path of the working +dnl Python is put into the `PYTHON' environment variable; +dnl `AC_SUBST' is used to substitute its value into Python +dnl scripts. If there is no Python to be found, the value of +dnl `PYTHON' is set to be `none'. + +AC_DEFUN([mdw_PROG_PYTHON], +[AC_ARG_WITH([python], +[ --with-python=PYTHON specify path to Python version $1 or newer], +[PYTHON="$withval"], +if test -z "$PYTHON"; then +[AC_CACHE_CHECK([for Python version $1 or later], mdw_cv_prog_python, +[mdw_cv_prog_python="none" +for p in `echo "$PATH:/usr/local/bin" | tr ":" " "`; do + case $p in /*) ;; *) p=`pwd`/$p ;; esac + if mdw__PYTHON_VERSION(["$p/python"], $1); then + mdw_cv_prog_python="$p/python" + break + fi + if mdw__PYTHON_VERSION(["$p/python$1"], $1); then + mdw_cv_prog_python="$p/python$1" + break + fi +done]) +PYTHON="$mdw_cv_prog_python"]) +fi + +AC_SUBST(PYTHON)dnl +if test "$PYTHON" = "none"; then : + $3 +else : + $2 +fi]) + +dnl --- *@-mdw_CHECK_PYTHON-@* --- +dnl +dnl Author: Mark Wooding +dnl +dnl Synopsis: mdw_CHECK_PYTHON(VERSION) +dnl +dnl Arguments: VERSION = version number of Python required +dnl +dnl Use: Verifies that the Python interpreter in the `PYTHON' shell +dnl variable actually works and is of the right version. If it's +dnl not, an error is raised and configuration is aborted. + +AC_DEFUN([mdw_CHECK_PYTHON], +[mdw_REQUIRE([mdw_PROG_PYTHON], [$1]) +AC_MSG_CHECKING([whether Python ($PYTHON) works]) +if test "$PYTHON" != "none" && mdw__PYTHON_VERSION("$PYTHON", $1); then + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) + AC_MSG_ERROR([Python version $1 or newer not found. +If you have a recent enough Python, and I just failed to find it, try using +the --with-python=PYTHON option to give me an explicit pathname.]) +fi]) + dnl --- *@-mdw__PERL_VERSION-@* --- dnl dnl AC_DEFUN relies on `[', `]' being quotes, so I have to drop down a level.