From 6421a3ea12cf519b165afc3700a86058bdcc381d Mon Sep 17 00:00:00 2001 From: Julien Rioux Date: Tue, 16 Jul 2013 22:42:32 +0200 Subject: [PATCH] Support for testing min and max versions of Python. --- aclocal.m4 | 53 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 85febc0d85..87d8474316 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -885,7 +885,7 @@ AC_DEFUN(STEPMAKE_INIT, [ fi AC_SUBST(SHELL) - STEPMAKE_PYTHON(REQUIRED, 1.5) + STEPMAKE_PYTHON(REQUIRED, 1.5, 3.0) if expr "$MAKE" : '.*\(echo\)' >/dev/null; then $MAKE -v 2> /dev/null | grep GNU > /dev/null @@ -1031,33 +1031,49 @@ AC_DEFUN(STEPMAKE_PERL, [ ]) +# Check for python, between minimum ($2) and maximum version ($3). +# If missing, add entry to missing-list ($1, one of 'OPTIONAL', 'REQUIRED') AC_DEFUN(STEPMAKE_PYTHON, [ - unset pv AC_MSG_CHECKING([for python]) - for python in $PYTHON python python2 python2.4 python2.3 python2.2 python2.1 python2.0; do - AC_MSG_RESULT([$python]) - if ! $python -V > /dev/null 2>&1 ; then - #AC_MSG_WARN([cannot execute $python]) - PYTHON='echo no python' + python="python" + found="no" + for r in $PYTHON python python3 python3.3 python3.2 python3.1 python3.0 python2 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0; do + exe=`STEPMAKE_GET_EXECUTABLE($r)` + if ! $exe -V > /dev/null 2>&1 ; then + continue + fi + ver=`STEPMAKE_GET_VERSION($exe)` + num=`STEPMAKE_NUMERIC_VERSION($ver)` + req=`STEPMAKE_NUMERIC_VERSION($2)` + sup=`STEPMAKE_NUMERIC_VERSION($3)` + if test -n "$2" && test "$num" -lt "$req"; then + python=["$r >= $2 (installed: $ver)"] + continue else - unset pv - STEPMAKE_CHECK_VERSION(python, pv, $2) - if test -z "$pv"; then - PYTHON=$python + if test -n "$3" && test "$num" -ge "$sup"; then + python=["$r < $3 (installed: $ver)"] + continue + else + python=$r + found=$r break fi fi done - if test -n "$pv"; then - STEPMAKE_ADD_ENTRY($1, $pv) + AC_MSG_RESULT([$found]) + if test "$found" != "no"; then + AC_MSG_CHECKING([$python version]) + AC_MSG_RESULT([$ver]) + PYTHON=$found + else + STEPMAKE_ADD_ENTRY($1, $python) fi - # clear cached value since arg 2 might point us to a new binary - unset ac_cv_path_PYTHON - AC_PATH_PROG(PYTHON, $PYTHON) AC_SUBST(PYTHON) ]) +# Check for python-config, between minimum ($2) and maximum version ($3). +# If missing, add entry to missing-list ($1, one of 'OPTIONAL', 'REQUIRED') AC_DEFUN(STEPMAKE_PYTHON_DEVEL, [ AC_ARG_WITH(python-include, [AS_HELP_STRING([--with-python-include=DIR], @@ -1078,8 +1094,9 @@ AC_DEFUN(STEPMAKE_PYTHON_DEVEL, [ LDFLAGS="$LDFLAGS -l${withval}" fi ]) - - AC_CHECK_PROGS(PYTHON_CONFIG, python-config, no) + + STEPMAKE_PYTHON($1, $2, $3) + AC_CHECK_PROGS(PYTHON_CONFIG, `basename $PYTHON`-config, no) if test -z "$PYTHON_CFLAGS" -a "$PYTHON_CONFIG" != "no"; then # Clean out junk: http://bugs.python.org/issue3290 -- 2.39.2