]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - config/always-pyzfs.m4
pyzfs: python3 support (build system)
[FreeBSD/FreeBSD.git] / config / always-pyzfs.m4
1 dnl #
2 dnl # Determines if pyzfs can be built, requires Python 2.7 or latter.
3 dnl #
4 AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_PYZFS], [
5         AC_ARG_ENABLE([pyzfs],
6                 AC_HELP_STRING([--enable-pyzfs],
7                 [install libzfs_core python bindings @<:@default=check@:>@]),
8                 [enable_pyzfs=$enableval],
9                 [enable_pyzfs=check])
10
11         dnl #
12         dnl # Packages for pyzfs specifically enabled/disabled.
13         dnl #
14         AS_IF([test "x$enable_pyzfs" != xcheck], [
15                 AS_IF([test "x$enable_pyzfs" = xyes], [
16                         DEFINE_PYZFS='--with pyzfs'
17                 ], [
18                         DEFINE_PYZFS='--without pyzfs'
19                 ])
20         ], [
21                 DEFINE_PYZFS=''
22         ])
23         AC_SUBST(DEFINE_PYZFS)
24
25         dnl #
26         dnl # Require python-devel libraries
27         dnl #
28         AS_IF([test "x$enable_pyzfs" = xcheck  -o "x$enable_pyzfs" = xyes], [
29                 AS_IF([test "${PYTHON_VERSION:0:2}" = "2."], [
30                         PYTHON_REQUIRED_VERSION=">= '2.7.0'"
31                 ], [
32                         AS_IF([test "${PYTHON_VERSION:0:2}" = "3."], [
33                                 PYTHON_REQUIRED_VERSION=">= '3.4.0'"
34                         ], [
35                                 AC_MSG_ERROR("Python $PYTHON_VERSION unknown")
36                         ])
37                 ])
38
39                 AX_PYTHON_DEVEL([$PYTHON_REQUIRED_VERSION], [
40                         AS_IF([test "x$enable_pyzfs" = xyes], [
41                                 AC_MSG_ERROR("Python $PYTHON_REQUIRED_VERSION development library is not installed")
42                         ], [test ! "x$enable_pyzfs" = xno], [
43                                 enable_pyzfs=no
44                         ])
45                 ])
46         ])
47
48         dnl #
49         dnl # Python "setuptools" module is required to build and install pyzfs
50         dnl #
51         AS_IF([test "x$enable_pyzfs" = xcheck -o "x$enable_pyzfs" = xyes], [
52                 ZFS_AC_PYTHON_MODULE([setuptools], [], [
53                         AS_IF([test "x$enable_pyzfs" = xyes], [
54                                 AC_MSG_ERROR("Python $PYTHON_VERSION setuptools is not installed")
55                         ], [test ! "x$enable_pyzfs" = xno], [
56                                 enable_pyzfs=no
57                         ])
58                 ])
59         ])
60
61         dnl #
62         dnl # Python "cffi" module is required to run pyzfs
63         dnl #
64         AS_IF([test "x$enable_pyzfs" = xcheck -o "x$enable_pyzfs" = xyes], [
65                 ZFS_AC_PYTHON_MODULE([cffi], [], [
66                         AS_IF([test "x$enable_pyzfs" = xyes], [
67                                 AC_MSG_ERROR("Python $PYTHON_VERSION cffi is not installed")
68                         ], [test ! "x$enable_pyzfs" = xno], [
69                                 enable_pyzfs=no
70                         ])
71                 ])
72         ])
73
74         dnl #
75         dnl # Set enable_pyzfs to 'yes' if every check passed
76         dnl #
77         AS_IF([test "x$enable_pyzfs" = xcheck], [enable_pyzfs=yes])
78
79         AM_CONDITIONAL([PYZFS_ENABLED], [test x$enable_pyzfs = xyes])
80         AC_SUBST([PYZFS_ENABLED], [$enable_pyzfs])
81         AC_SUBST(pythonsitedir, [$PYTHON_SITE_PKG])
82
83         AC_MSG_CHECKING([whether to enable pyzfs: ])
84         AC_MSG_RESULT($enable_pyzfs)
85 ])