2 dnl # The majority of the python scripts are written to be compatible
3 dnl # with Python 2.6 and Python 3.4. Therefore, they may be installed
4 dnl # and used with either interpreter. This option is intended to
5 dnl # to provide a method to specify the default system version, and
6 dnl # set the PYTHON environment variable accordingly.
8 AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_PYTHON], [
10 AC_HELP_STRING([--with-python[=VERSION]],
11 [default system python version @<:@default=check@:>@]),
12 [with_python=$withval],
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}"],
22 [AC_MSG_ERROR([Unknown --with-python value '$with_python'])]
26 dnl # Minimum supported Python versions for utilities:
27 dnl # Python 2.6 or Python 3.4
29 AM_PATH_PYTHON([], [], [:])
30 AS_IF([test -z "$PYTHON_VERSION"], [
31 PYTHON_VERSION=$(basename $PYTHON | tr -cd 0-9.)
33 PYTHON_MINOR=${PYTHON_VERSION#*\.}
35 AS_CASE([$PYTHON_VERSION],
37 AS_IF([test $PYTHON_MINOR -lt 6],
38 [AC_MSG_ERROR("Python >= 2.6 is required")])
41 AS_IF([test $PYTHON_MINOR -lt 4],
42 [AC_MSG_ERROR("Python >= 3.4 is required")])
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])
53 dnl # Request that packages be built for a specific Python version.
55 AS_IF([test "x$with_python" != xcheck], [
56 PYTHON_PKG_VERSION=$(echo $PYTHON_VERSION | tr -d .)
57 DEFINE_PYTHON_PKG_VERSION='--define "__use_python_pkg_version '${PYTHON_PKG_VERSION}'"'
58 DEFINE_PYTHON_VERSION='--define "__use_python '${PYTHON}'"'
60 DEFINE_PYTHON_VERSION=''
61 DEFINE_PYTHON_PKG_VERSION=''
64 AC_SUBST(DEFINE_PYTHON_VERSION)
65 AC_SUBST(DEFINE_PYTHON_PKG_VERSION)