Update the kstat dataset_name when renaming a zvol
[zfs.git] / config / always-python.m4
blob5a2008124f72ae6506f834fa20225b882b254c4a
1 dnl #
2 dnl # The majority of the python scripts are written to be compatible
3 dnl # with Python 3.6. This option is intended to
4 dnl # to provide a method to specify the default system version, and
5 dnl # set the PYTHON environment variable accordingly.
6 dnl #
7 AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_PYTHON], [
8         AC_ARG_WITH([python],
9                 AS_HELP_STRING([--with-python[=VERSION]],
10                 [default system python version @<:@default=check@:>@]),
11                 [with_python=$withval],
12                 [with_python=check])
14         AS_CASE([$with_python],
15                 [check], [AC_CHECK_PROGS([PYTHON], [python3], [:])],
16                 [3*], [PYTHON="python${with_python}"],
17                 [*python3*], [PYTHON="${with_python}"],
18                 [no], [PYTHON=":"],
19                 [AC_MSG_ERROR([Unknown --with-python value '$with_python'])]
20         )
22         dnl #
23         dnl # Minimum supported Python versions for utilities: Python 3.6
24         dnl #
25         AM_PATH_PYTHON([], [], [:])
26         AS_IF([test -z "$PYTHON_VERSION"], [
27                 PYTHON_VERSION=$(echo ${PYTHON##*/} | tr -cd 0-9.)
28         ])
29         PYTHON_MINOR=${PYTHON_VERSION#*\.}
31         AS_CASE([$PYTHON_VERSION],
32                 [3.*], [
33                         AS_IF([test $PYTHON_MINOR -lt 6],
34                                 [AC_MSG_ERROR("Python >= 3.6 is required")])
35                 ],
36                 [:|2|3], [],
37                 [PYTHON_VERSION=3]
38         )
40         AM_CONDITIONAL([USING_PYTHON], [test "$PYTHON" != :])
41         AC_SUBST([PYTHON_SHEBANG], [python3])
43         dnl #
44         dnl # Request that packages be built for a specific Python version.
45         dnl #
46         AS_IF([test "x$with_python" != xcheck], [
47                 PYTHON_PKG_VERSION=$(echo $PYTHON_VERSION | tr -d .)
48                 DEFINE_PYTHON_PKG_VERSION='--define "__use_python_pkg_version '${PYTHON_PKG_VERSION}'"'
49                 DEFINE_PYTHON_VERSION='--define "__use_python '${PYTHON}'"'
50         ], [
51                 DEFINE_PYTHON_VERSION=''
52                 DEFINE_PYTHON_PKG_VERSION=''
53         ])
55         AC_SUBST(DEFINE_PYTHON_VERSION)
56         AC_SUBST(DEFINE_PYTHON_PKG_VERSION)