xref: /freebsd/sys/contrib/openzfs/config/kernel-config-defined.m4 (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1dnl #
2dnl # Certain kernel build options are not supported.  These must be
3dnl # detected at configure time and cause a build failure.  Otherwise
4dnl # modules may be successfully built that behave incorrectly.
5dnl #
6AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEFINED], [
7	ZFS_AC_KERNEL_SRC_CONFIG_MODULES
8	ZFS_AC_KERNEL_SRC_CONFIG_BLOCK
9	ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC
10	ZFS_AC_KERNEL_SRC_CONFIG_TRIM_UNUSED_KSYMS
11	ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_DEFLATE
12	ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE
13
14	AC_MSG_CHECKING([for kernel config option compatibility])
15	ZFS_LINUX_TEST_COMPILE_ALL([config])
16	AC_MSG_RESULT([done])
17
18	ZFS_AC_KERNEL_CONFIG_MODULES
19	ZFS_AC_KERNEL_CONFIG_BLOCK
20	ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC
21	ZFS_AC_KERNEL_CONFIG_TRIM_UNUSED_KSYMS
22	ZFS_AC_KERNEL_CONFIG_ZLIB_DEFLATE
23	ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE
24])
25
26dnl #
27dnl # Check CONFIG_BLOCK
28dnl #
29dnl # Verify the kernel has CONFIG_BLOCK support enabled.
30dnl #
31AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_BLOCK], [
32	ZFS_LINUX_TEST_SRC([config_block], [
33		#if !defined(CONFIG_BLOCK)
34		#error CONFIG_BLOCK not defined
35		#endif
36	],[])
37])
38
39AC_DEFUN([ZFS_AC_KERNEL_CONFIG_BLOCK], [
40	AC_MSG_CHECKING([whether CONFIG_BLOCK is defined])
41	ZFS_LINUX_TEST_RESULT([config_block], [
42		AC_MSG_RESULT([yes])
43	],[
44		AC_MSG_RESULT([no])
45		AC_MSG_ERROR([
46	*** This kernel does not include the required block device support.
47	*** Rebuild the kernel with CONFIG_BLOCK=y set.])
48	])
49])
50
51dnl #
52dnl # Check CONFIG_DEBUG_LOCK_ALLOC
53dnl #
54dnl # This is typically only set for debug kernels because it comes with
55dnl # a performance penalty.  However, when it is set it maps the non-GPL
56dnl # symbol mutex_lock() to the GPL-only mutex_lock_nested() symbol.
57dnl # This will cause a failure at link time which we'd rather know about
58dnl # at compile time.
59dnl #
60dnl # Since we plan to pursue making mutex_lock_nested() a non-GPL symbol
61dnl # with the upstream community we add a check to detect this case.
62dnl #
63AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC], [
64	ZFS_LINUX_TEST_SRC([config_debug_lock_alloc], [
65		#include <linux/mutex.h>
66	],[
67		struct mutex lock;
68
69		mutex_init(&lock);
70		mutex_lock(&lock);
71		mutex_unlock(&lock);
72	], [], [ZFS_META_LICENSE])
73])
74
75AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC], [
76	AC_MSG_CHECKING([whether mutex_lock() is GPL-only])
77	ZFS_LINUX_TEST_RESULT([config_debug_lock_alloc_license], [
78		AC_MSG_RESULT(no)
79	],[
80		AC_MSG_RESULT(yes)
81		AC_MSG_ERROR([
82	*** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible
83	*** with the CDDL license and will prevent the module linking stage
84	*** from succeeding.  You must rebuild your kernel without this
85	*** option enabled.])
86	])
87])
88
89dnl #
90dnl # Check CONFIG_MODULES
91dnl #
92dnl # Verify the kernel has CONFIG_MODULES support enabled.
93dnl #
94AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_MODULES], [
95	ZFS_LINUX_TEST_SRC([config_modules], [
96		#if !defined(CONFIG_MODULES)
97		#error CONFIG_MODULES not defined
98		#endif
99	],[])
100])
101
102AC_DEFUN([ZFS_AC_KERNEL_CONFIG_MODULES], [
103	AC_MSG_CHECKING([whether CONFIG_MODULES is defined])
104	AS_IF([test "x$enable_linux_builtin" != xyes], [
105		ZFS_LINUX_TEST_RESULT([config_modules], [
106			AC_MSG_RESULT([yes])
107		],[
108			AC_MSG_RESULT([no])
109			AC_MSG_ERROR([
110		*** This kernel does not include the required loadable module
111		*** support!
112		***
113		*** To build OpenZFS as a loadable Linux kernel module
114		*** enable loadable module support by setting
115		*** `CONFIG_MODULES=y` in the kernel configuration and run
116		*** `make modules_prepare` in the Linux source tree.
117		***
118		*** If you don't intend to enable loadable kernel module
119		*** support, please compile OpenZFS as a Linux kernel built-in.
120		***
121		*** Prepare the Linux source tree by running `make prepare`,
122		*** use the OpenZFS `--enable-linux-builtin` configure option,
123		*** copy the OpenZFS sources into the Linux source tree using
124		*** `./copy-builtin <linux source directory>`,
125		*** set `CONFIG_ZFS=y` in the kernel configuration and compile
126		*** kernel as usual.
127			])
128		])
129	], [
130		ZFS_LINUX_TRY_COMPILE([], [], [
131			AC_MSG_RESULT([not needed])
132		],[
133			AC_MSG_RESULT([error])
134			AC_MSG_ERROR([
135		*** This kernel is unable to compile object files.
136		***
137		*** Please make sure you prepared the Linux source tree
138		*** by running `make prepare` there.
139			])
140		])
141	])
142])
143
144dnl #
145dnl # Check CONFIG_TRIM_UNUSED_KSYMS
146dnl #
147dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS disabled.
148dnl #
149AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_TRIM_UNUSED_KSYMS], [
150	ZFS_LINUX_TEST_SRC([config_trim_unusued_ksyms], [
151		#if defined(CONFIG_TRIM_UNUSED_KSYMS)
152		#error CONFIG_TRIM_UNUSED_KSYMS not defined
153		#endif
154	],[])
155])
156
157AC_DEFUN([ZFS_AC_KERNEL_CONFIG_TRIM_UNUSED_KSYMS], [
158	AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
159	ZFS_LINUX_TEST_RESULT([config_trim_unusued_ksyms], [
160		AC_MSG_RESULT([yes])
161	],[
162		AC_MSG_RESULT([no])
163		AS_IF([test "x$enable_linux_builtin" != xyes], [
164			AC_MSG_ERROR([
165	*** This kernel has unused symbols trimming enabled, please disable.
166	*** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
167		])
168	])
169])
170
171dnl #
172dnl # Check CONFIG_ZLIB_INFLATE
173dnl #
174dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
175dnl #
176AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE], [
177	ZFS_LINUX_TEST_SRC([config_zlib_inflate], [
178		#if !defined(CONFIG_ZLIB_INFLATE) && \
179		    !defined(CONFIG_ZLIB_INFLATE_MODULE)
180		#error CONFIG_ZLIB_INFLATE not defined
181		#endif
182	],[])
183])
184
185AC_DEFUN([ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE], [
186	AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
187	ZFS_LINUX_TEST_RESULT([config_zlib_inflate], [
188		AC_MSG_RESULT([yes])
189	],[
190		AC_MSG_RESULT([no])
191		AC_MSG_ERROR([
192	*** This kernel does not include the required zlib inflate support.
193	*** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
194	])
195])
196
197dnl #
198dnl # Check CONFIG_ZLIB_DEFLATE
199dnl #
200dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
201dnl #
202AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_DEFLATE], [
203	ZFS_LINUX_TEST_SRC([config_zlib_deflate], [
204		#if !defined(CONFIG_ZLIB_DEFLATE) && \
205		    !defined(CONFIG_ZLIB_DEFLATE_MODULE)
206		#error CONFIG_ZLIB_DEFLATE not defined
207		#endif
208	],[])
209])
210
211AC_DEFUN([ZFS_AC_KERNEL_CONFIG_ZLIB_DEFLATE], [
212	AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
213	ZFS_LINUX_TEST_RESULT([config_zlib_deflate], [
214		AC_MSG_RESULT([yes])
215	],[
216		AC_MSG_RESULT([no])
217		AC_MSG_ERROR([
218	*** This kernel does not include the required zlib deflate support.
219	*** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
220	])
221])
222