2 dnl # Certain kernel build options are not supported. These must be
3 dnl # detected at configure time and cause a build failure. Otherwise
4 dnl # modules may be successfully built that behave incorrectly.
6 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEFINED], [
7 AS_IF([test "x$cross_compiling" != xyes], [
10 #include "$LINUX/include/linux/license.h"
12 return !license_is_gpl_compatible(
16 AC_DEFINE([ZFS_IS_GPL_COMPATIBLE], [1],
17 [Define to 1 if GPL-only symbols can be used])
22 ZFS_AC_KERNEL_SRC_CONFIG_MODULES
23 ZFS_AC_KERNEL_SRC_CONFIG_BLOCK
24 ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC
25 ZFS_AC_KERNEL_SRC_CONFIG_TRIM_UNUSED_KSYMS
26 ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_DEFLATE
27 ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE
29 AC_MSG_CHECKING([for kernel config option compatibility])
30 ZFS_LINUX_TEST_COMPILE_ALL([config])
33 ZFS_AC_KERNEL_CONFIG_MODULES
34 ZFS_AC_KERNEL_CONFIG_BLOCK
35 ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC
36 ZFS_AC_KERNEL_CONFIG_TRIM_UNUSED_KSYMS
37 ZFS_AC_KERNEL_CONFIG_ZLIB_DEFLATE
38 ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE
42 dnl # Check CONFIG_BLOCK
44 dnl # Verify the kernel has CONFIG_BLOCK support enabled.
46 AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_BLOCK], [
47 ZFS_LINUX_TEST_SRC([config_block], [
48 #if !defined(CONFIG_BLOCK)
49 #error CONFIG_BLOCK not defined
54 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_BLOCK], [
55 AC_MSG_CHECKING([whether CONFIG_BLOCK is defined])
56 ZFS_LINUX_TEST_RESULT([config_block], [
61 *** This kernel does not include the required block device support.
62 *** Rebuild the kernel with CONFIG_BLOCK=y set.])
67 dnl # Check CONFIG_DEBUG_LOCK_ALLOC
69 dnl # This is typically only set for debug kernels because it comes with
70 dnl # a performance penalty. However, when it is set it maps the non-GPL
71 dnl # symbol mutex_lock() to the GPL-only mutex_lock_nested() symbol.
72 dnl # This will cause a failure at link time which we'd rather know about
73 dnl # at compile time.
75 dnl # Since we plan to pursue making mutex_lock_nested() a non-GPL symbol
76 dnl # with the upstream community we add a check to detect this case.
78 AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC], [
79 ZFS_LINUX_TEST_SRC([config_debug_lock_alloc], [
80 #include <linux/mutex.h>
87 ], [], [ZFS_META_LICENSE])
90 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC], [
91 AC_MSG_CHECKING([whether mutex_lock() is GPL-only])
92 ZFS_LINUX_TEST_RESULT([config_debug_lock_alloc_license], [
97 *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible
98 *** with the CDDL license and will prevent the module linking stage
99 *** from succeeding. You must rebuild your kernel without this
100 *** option enabled.])
105 dnl # Check CONFIG_MODULES
107 dnl # Verify the kernel has CONFIG_MODULES support enabled.
109 AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_MODULES], [
110 ZFS_LINUX_TEST_SRC([config_modules], [
111 #if !defined(CONFIG_MODULES)
112 #error CONFIG_MODULES not defined
117 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_MODULES], [
118 AC_MSG_CHECKING([whether CONFIG_MODULES is defined])
119 AS_IF([test "x$enable_linux_builtin" != xyes], [
120 ZFS_LINUX_TEST_RESULT([config_modules], [
125 *** This kernel does not include the required loadable module
128 *** To build OpenZFS as a loadable Linux kernel module
129 *** enable loadable module support by setting
130 *** `CONFIG_MODULES=y` in the kernel configuration and run
131 *** `make modules_prepare` in the Linux source tree.
133 *** If you don't intend to enable loadable kernel module
134 *** support, please compile OpenZFS as a Linux kernel built-in.
136 *** Prepare the Linux source tree by running `make prepare`,
137 *** use the OpenZFS `--enable-linux-builtin` configure option,
138 *** copy the OpenZFS sources into the Linux source tree using
139 *** `./copy-builtin <linux source directory>`,
140 *** set `CONFIG_ZFS=y` in the kernel configuration and compile
145 ZFS_LINUX_TRY_COMPILE([], [], [
146 AC_MSG_RESULT([not needed])
148 AC_MSG_RESULT([error])
150 *** This kernel is unable to compile object files.
152 *** Please make sure you prepared the Linux source tree
153 *** by running `make prepare` there.
160 dnl # Check CONFIG_TRIM_UNUSED_KSYMS
162 dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS disabled.
164 AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_TRIM_UNUSED_KSYMS], [
165 ZFS_LINUX_TEST_SRC([config_trim_unusued_ksyms], [
166 #if defined(CONFIG_TRIM_UNUSED_KSYMS)
167 #error CONFIG_TRIM_UNUSED_KSYMS not defined
172 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_TRIM_UNUSED_KSYMS], [
173 AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
174 ZFS_LINUX_TEST_RESULT([config_trim_unusued_ksyms], [
178 AS_IF([test "x$enable_linux_builtin" != xyes], [
180 *** This kernel has unused symbols trimming enabled, please disable.
181 *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
187 dnl # Check CONFIG_ZLIB_INFLATE
189 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
191 AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE], [
192 ZFS_LINUX_TEST_SRC([config_zlib_inflate], [
193 #if !defined(CONFIG_ZLIB_INFLATE) && \
194 !defined(CONFIG_ZLIB_INFLATE_MODULE)
195 #error CONFIG_ZLIB_INFLATE not defined
200 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE], [
201 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
202 ZFS_LINUX_TEST_RESULT([config_zlib_inflate], [
207 *** This kernel does not include the required zlib inflate support.
208 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
213 dnl # Check CONFIG_ZLIB_DEFLATE
215 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
217 AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_DEFLATE], [
218 ZFS_LINUX_TEST_SRC([config_zlib_deflate], [
219 #if !defined(CONFIG_ZLIB_DEFLATE) && \
220 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
221 #error CONFIG_ZLIB_DEFLATE not defined
226 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_ZLIB_DEFLATE], [
227 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
228 ZFS_LINUX_TEST_RESULT([config_zlib_deflate], [
233 *** This kernel does not include the required zlib deflate support.
234 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])