]>
Commit | Line | Data |
---|---|---|
85ce3f4f | 1 | dnl # |
b1b4ac27 RM |
2 | dnl # ZFS_AC_PYTHON_MODULE(module_name, [action-if-true], [action-if-false]) |
3 | dnl # | |
4 | dnl # Checks for Python module. Freely inspired by AX_PYTHON_MODULE | |
5 | dnl # https://www.gnu.org/software/autoconf-archive/ax_python_module.html | |
6 | dnl # Required by ZFS_AC_CONFIG_ALWAYS_PYZFS. | |
7 | dnl # | |
8 | AC_DEFUN([ZFS_AC_PYTHON_MODULE], [ | |
420b4448 | 9 | PYTHON_NAME=${PYTHON##*/} |
b1b4ac27 RM |
10 | AC_MSG_CHECKING([for $PYTHON_NAME module: $1]) |
11 | AS_IF([$PYTHON -c "import $1" 2>/dev/null], [ | |
12 | AC_MSG_RESULT(yes) | |
13 | m4_ifvaln([$2], [$2]) | |
14 | ], [ | |
15 | AC_MSG_RESULT(no) | |
16 | m4_ifvaln([$3], [$3]) | |
17 | ]) | |
18 | ]) | |
19 | ||
20 | dnl # | |
8a7c4efd | 21 | dnl # Determines if pyzfs can be built, requires Python 3.6 or later. |
85ce3f4f | 22 | dnl # |
85ce3f4f | 23 | AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_PYZFS], [ |
85ce3f4f | 24 | AC_ARG_ENABLE([pyzfs], |
06346cc5 | 25 | AS_HELP_STRING([--enable-pyzfs], |
85ce3f4f | 26 | [install libzfs_core python bindings @<:@default=check@:>@]), |
27 | [enable_pyzfs=$enableval], | |
28 | [enable_pyzfs=check]) | |
29 | ||
6e72a5b9 BB |
30 | dnl # |
31 | dnl # Packages for pyzfs specifically enabled/disabled. | |
32 | dnl # | |
33 | AS_IF([test "x$enable_pyzfs" != xcheck], [ | |
609b2425 | 34 | AS_IF([test "x$enable_pyzfs" = xyes], [ |
6e72a5b9 BB |
35 | DEFINE_PYZFS='--with pyzfs' |
36 | ], [ | |
37 | DEFINE_PYZFS='--without pyzfs' | |
85ce3f4f | 38 | ]) |
6e72a5b9 | 39 | ], [ |
b1b4ac27 | 40 | AS_IF([test "$PYTHON" != :], [ |
1a132f06 RM |
41 | DEFINE_PYZFS='' |
42 | ], [ | |
43 | enable_pyzfs=no | |
44 | DEFINE_PYZFS='--without pyzfs' | |
45 | ]) | |
85ce3f4f | 46 | ]) |
6e72a5b9 | 47 | AC_SUBST(DEFINE_PYZFS) |
85ce3f4f | 48 | |
c3b6fd3d DS |
49 | dnl # |
50 | dnl # Autodetection disables pyzfs if kernel or srpm config | |
51 | dnl # | |
52 | AS_IF([test "x$enable_pyzfs" = xcheck], [ | |
53 | AS_IF([test "x$ZFS_CONFIG" = xkernel -o "x$ZFS_CONFIG" = xsrpm ], [ | |
54 | enable_pyzfs=no | |
55 | AC_MSG_NOTICE([Disabling pyzfs for kernel/srpm config]) | |
56 | ]) | |
57 | ]) | |
58 | ||
08cd0717 RE |
59 | dnl # |
60 | dnl # Python "packaging" (or, failing that, "distlib") module is required to build and install pyzfs | |
61 | dnl # | |
62 | AS_IF([test "x$enable_pyzfs" = xcheck -o "x$enable_pyzfs" = xyes], [ | |
63 | ZFS_AC_PYTHON_MODULE([packaging], [], [ | |
64 | ZFS_AC_PYTHON_MODULE([distlib], [], [ | |
65 | AS_IF([test "x$enable_pyzfs" = xyes], [ | |
66 | AC_MSG_ERROR("Python $PYTHON_VERSION packaging and distlib modules are not installed") | |
67 | ], [test "x$enable_pyzfs" != xno], [ | |
68 | enable_pyzfs=no | |
69 | ]) | |
70 | ]) | |
71 | ]) | |
72 | ]) | |
73 | ||
85ce3f4f | 74 | dnl # |
8a7c4efd | 75 | dnl # Require python3-devel libraries |
85ce3f4f | 76 | dnl # |
6e72a5b9 | 77 | AS_IF([test "x$enable_pyzfs" = xcheck -o "x$enable_pyzfs" = xyes], [ |
b1b4ac27 | 78 | AS_CASE([$PYTHON_VERSION], |
8a7c4efd | 79 | [3.*], [PYTHON_REQUIRED_VERSION=">= '3.6.0'"], |
b1b4ac27 RM |
80 | [AC_MSG_ERROR("Python $PYTHON_VERSION unknown")] |
81 | ) | |
85ce3f4f | 82 | |
317b31ee BB |
83 | AS_IF([test "x$enable_pyzfs" = xyes], [ |
84 | AX_PYTHON_DEVEL([$PYTHON_REQUIRED_VERSION]) | |
85 | ], [ | |
86 | AX_PYTHON_DEVEL([$PYTHON_REQUIRED_VERSION], [true]) | |
87 | AS_IF([test "x$ax_python_devel_found" = xno], [ | |
85ce3f4f | 88 | enable_pyzfs=no |
89 | ]) | |
90 | ]) | |
91 | ]) | |
92 | ||
93 | dnl # | |
94 | dnl # Python "setuptools" module is required to build and install pyzfs | |
95 | dnl # | |
6e72a5b9 | 96 | AS_IF([test "x$enable_pyzfs" = xcheck -o "x$enable_pyzfs" = xyes], [ |
85ce3f4f | 97 | ZFS_AC_PYTHON_MODULE([setuptools], [], [ |
98 | AS_IF([test "x$enable_pyzfs" = xyes], [ | |
6e72a5b9 | 99 | AC_MSG_ERROR("Python $PYTHON_VERSION setuptools is not installed") |
b1b4ac27 | 100 | ], [test "x$enable_pyzfs" != xno], [ |
85ce3f4f | 101 | enable_pyzfs=no |
102 | ]) | |
103 | ]) | |
104 | ]) | |
105 | ||
106 | dnl # | |
107 | dnl # Python "cffi" module is required to run pyzfs | |
108 | dnl # | |
6e72a5b9 | 109 | AS_IF([test "x$enable_pyzfs" = xcheck -o "x$enable_pyzfs" = xyes], [ |
85ce3f4f | 110 | ZFS_AC_PYTHON_MODULE([cffi], [], [ |
111 | AS_IF([test "x$enable_pyzfs" = xyes], [ | |
6e72a5b9 | 112 | AC_MSG_ERROR("Python $PYTHON_VERSION cffi is not installed") |
b1b4ac27 | 113 | ], [test "x$enable_pyzfs" != xno], [ |
85ce3f4f | 114 | enable_pyzfs=no |
115 | ]) | |
116 | ]) | |
117 | ]) | |
118 | ||
119 | dnl # | |
120 | dnl # Set enable_pyzfs to 'yes' if every check passed | |
121 | dnl # | |
122 | AS_IF([test "x$enable_pyzfs" = xcheck], [enable_pyzfs=yes]) | |
123 | ||
b1b4ac27 | 124 | AM_CONDITIONAL([PYZFS_ENABLED], [test "x$enable_pyzfs" = xyes]) |
85ce3f4f | 125 | AC_SUBST([PYZFS_ENABLED], [$enable_pyzfs]) |
85ce3f4f | 126 | AC_SUBST(pythonsitedir, [$PYTHON_SITE_PKG]) |
6e72a5b9 BB |
127 | |
128 | AC_MSG_CHECKING([whether to enable pyzfs: ]) | |
129 | AC_MSG_RESULT($enable_pyzfs) | |
85ce3f4f | 130 | ]) |