buildautoconfautomakegnu-toolchainlinux-toolchain

Autofoo test for maximum version of Python


I'm trying to get autofoo to test for a maximum version of Python rather than a minimum. Example:

AC_REQUIRE([AM_PATH_PYTHON([2.7])])

... will test for Python >= 2.7, and will probably turn up with /usr/bin/python3. I want it to return nothing greater than python2.7, however.

Is there a straightforward way to do this? I asked around, and so far the best response I've gotten is, "rewrite the macro."

Thanks in advance!


Solution

  • 1). Add to acinclude.m4

    `# my_CHECK_MAJOR_VERSION(VARIABLE, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])`  
    `# ---------------------------------------------------------------------------`  
    `# Run ACTION-IF-TRUE if the VAR has a major version >= VERSION.`  
    `# Run ACTION-IF-FALSE otherwise.`  
    AC_DEFUN([my_CHECK_MAJOR_VERSION],  
    [AC_MSG_CHECKING([whether $1 $$1 major version == $2])  
    case $$1 in  
    $2*)  
      AC_MSG_RESULT([yes])  
      ifelse([$3], [$3], [:])  
      ;;  
    *)  
      AC_MSG_RESULT([no])  
      ifelse([$4], , [AC_MSG_ERROR([$$1 differs from $2])], [$4])  
      ;;  
    esac])  
    

    2.) Add to zconfigure.inz

    my_CHECK_MAJOR_VERSION([PYTHON_VERSION], [2])  
    

    3.) aclocal, automake, autoconf

    That's it.