1dnl # 2dnl # The majority of the python scripts are written to be compatible 3dnl # with Python 2.6 and Python 3.4. Therefore, they may be installed 4dnl # and used with either interpreter. This option is intended to 5dnl # to provide a method to specify the default system version, and 6dnl # set the PYTHON environment variable accordingly. 7dnl # 8AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_PYTHON], [ 9 AC_ARG_WITH([python], 10 AS_HELP_STRING([--with-python[=VERSION]], 11 [default system python version @<:@default=check@:>@]), 12 [with_python=$withval], 13 [with_python=check]) 14 15 AS_CASE([$with_python], 16 [check], [AC_CHECK_PROGS([PYTHON], [python3 python2], [:])], 17 [2*], [PYTHON="python${with_python}"], 18 [*python2*], [PYTHON="${with_python}"], 19 [3*], [PYTHON="python${with_python}"], 20 [*python3*], [PYTHON="${with_python}"], 21 [no], [PYTHON=":"], 22 [AC_MSG_ERROR([Unknown --with-python value '$with_python'])] 23 ) 24 25 dnl # 26 dnl # Minimum supported Python versions for utilities: 27 dnl # Python 2.6 or Python 3.4 28 dnl # 29 AM_PATH_PYTHON([], [], [:]) 30 AS_IF([test -z "$PYTHON_VERSION"], [ 31 PYTHON_VERSION=$(echo ${PYTHON##*/} | tr -cd 0-9.) 32 ]) 33 PYTHON_MINOR=${PYTHON_VERSION#*\.} 34 35 AS_CASE([$PYTHON_VERSION], 36 [2.*], [ 37 AS_IF([test $PYTHON_MINOR -lt 6], 38 [AC_MSG_ERROR("Python >= 2.6 is required")]) 39 ], 40 [3.*], [ 41 AS_IF([test $PYTHON_MINOR -lt 4], 42 [AC_MSG_ERROR("Python >= 3.4 is required")]) 43 ], 44 [:|2|3], [], 45 [PYTHON_VERSION=3] 46 ) 47 48 AM_CONDITIONAL([USING_PYTHON], [test "$PYTHON" != :]) 49 AM_CONDITIONAL([USING_PYTHON_2], [test "x${PYTHON_VERSION%%\.*}" = x2]) 50 AM_CONDITIONAL([USING_PYTHON_3], [test "x${PYTHON_VERSION%%\.*}" = x3]) 51 52 AM_COND_IF([USING_PYTHON_2], 53 [AC_SUBST([PYTHON_SHEBANG], [python2])], 54 [AC_SUBST([PYTHON_SHEBANG], [python3])]) 55 56 dnl # 57 dnl # Request that packages be built for a specific Python version. 58 dnl # 59 AS_IF([test "x$with_python" != xcheck], [ 60 PYTHON_PKG_VERSION=$(echo $PYTHON_VERSION | tr -d .) 61 DEFINE_PYTHON_PKG_VERSION='--define "__use_python_pkg_version '${PYTHON_PKG_VERSION}'"' 62 DEFINE_PYTHON_VERSION='--define "__use_python '${PYTHON}'"' 63 ], [ 64 DEFINE_PYTHON_VERSION='' 65 DEFINE_PYTHON_PKG_VERSION='' 66 ]) 67 68 AC_SUBST(DEFINE_PYTHON_VERSION) 69 AC_SUBST(DEFINE_PYTHON_PKG_VERSION) 70]) 71