xref: /freebsd/sys/contrib/openzfs/config/kernel-config-defined.m4 (revision 31ba4ce8898f9dfa5e7f054fdbc26e50a599a6e3)
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	AS_IF([test "x$cross_compiling" != xyes], [
8		AC_RUN_IFELSE([
9			AC_LANG_PROGRAM([
10				#include "$LINUX/include/linux/license.h"
11			], [
12				return !license_is_gpl_compatible(
13				    "$ZFS_META_LICENSE");
14			])
15		], [
16			AC_DEFINE([ZFS_IS_GPL_COMPATIBLE], [1],
17			    [Define to 1 if GPL-only symbols can be used])
18		], [
19		])
20	])
21
22	ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC
23	ZFS_AC_KERNEL_SRC_CONFIG_TRIM_UNUSED_KSYMS
24	ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE
25	ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_DEFLATE
26
27	AC_MSG_CHECKING([for kernel config option compatibility])
28	ZFS_LINUX_TEST_COMPILE_ALL([config])
29	AC_MSG_RESULT([done])
30
31	ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC
32	ZFS_AC_KERNEL_CONFIG_TRIM_UNUSED_KSYMS
33	ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE
34	ZFS_AC_KERNEL_CONFIG_ZLIB_DEFLATE
35])
36
37dnl #
38dnl # Check CONFIG_DEBUG_LOCK_ALLOC
39dnl #
40dnl # This is typically only set for debug kernels because it comes with
41dnl # a performance penalty.  However, when it is set it maps the non-GPL
42dnl # symbol mutex_lock() to the GPL-only mutex_lock_nested() symbol.
43dnl # This will cause a failure at link time which we'd rather know about
44dnl # at compile time.
45dnl #
46dnl # Since we plan to pursue making mutex_lock_nested() a non-GPL symbol
47dnl # with the upstream community we add a check to detect this case.
48dnl #
49AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC], [
50	ZFS_LINUX_TEST_SRC([config_debug_lock_alloc], [
51		#include <linux/mutex.h>
52	],[
53		struct mutex lock;
54
55		mutex_init(&lock);
56		mutex_lock(&lock);
57		mutex_unlock(&lock);
58	], [], [ZFS_META_LICENSE])
59])
60
61AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC], [
62	AC_MSG_CHECKING([whether mutex_lock() is GPL-only])
63	ZFS_LINUX_TEST_RESULT([config_debug_lock_alloc_license], [
64		AC_MSG_RESULT(no)
65	],[
66		AC_MSG_RESULT(yes)
67		AC_MSG_ERROR([
68	*** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible
69	*** with the CDDL license and will prevent the module linking stage
70	*** from succeeding.  You must rebuild your kernel without this
71	*** option enabled.])
72	])
73])
74
75dnl #
76dnl # Check CONFIG_TRIM_UNUSED_KSYMS
77dnl #
78dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS disabled.
79dnl #
80AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_TRIM_UNUSED_KSYMS], [
81	ZFS_LINUX_TEST_SRC([config_trim_unusued_ksyms], [
82		#if defined(CONFIG_TRIM_UNUSED_KSYMS)
83		#error CONFIG_TRIM_UNUSED_KSYMS not defined
84		#endif
85	],[])
86])
87
88AC_DEFUN([ZFS_AC_KERNEL_CONFIG_TRIM_UNUSED_KSYMS], [
89	AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
90	ZFS_LINUX_TEST_RESULT([config_trim_unusued_ksyms], [
91		AC_MSG_RESULT([yes])
92	],[
93		AC_MSG_RESULT([no])
94		AS_IF([test "x$enable_linux_builtin" != xyes], [
95			AC_MSG_ERROR([
96	*** This kernel has unused symbols trimming enabled, please disable.
97	*** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
98		])
99	])
100])
101
102dnl #
103dnl # Check CONFIG_ZLIB_INFLATE
104dnl #
105dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
106dnl #
107AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE], [
108	ZFS_LINUX_TEST_SRC([config_zlib_inflate], [
109		#if !defined(CONFIG_ZLIB_INFLATE) && \
110		    !defined(CONFIG_ZLIB_INFLATE_MODULE)
111		#error CONFIG_ZLIB_INFLATE not defined
112		#endif
113	],[])
114])
115
116AC_DEFUN([ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE], [
117	AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
118	ZFS_LINUX_TEST_RESULT([config_zlib_inflate], [
119		AC_MSG_RESULT([yes])
120	],[
121		AC_MSG_RESULT([no])
122		AC_MSG_ERROR([
123	*** This kernel does not include the required zlib inflate support.
124	*** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
125	])
126])
127
128dnl #
129dnl # Check CONFIG_ZLIB_DEFLATE
130dnl #
131dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
132dnl #
133AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_DEFLATE], [
134	ZFS_LINUX_TEST_SRC([config_zlib_deflate], [
135		#if !defined(CONFIG_ZLIB_DEFLATE) && \
136		    !defined(CONFIG_ZLIB_DEFLATE_MODULE)
137		#error CONFIG_ZLIB_DEFLATE not defined
138		#endif
139	],[])
140])
141
142AC_DEFUN([ZFS_AC_KERNEL_CONFIG_ZLIB_DEFLATE], [
143	AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
144	ZFS_LINUX_TEST_RESULT([config_zlib_deflate], [
145		AC_MSG_RESULT([yes])
146	],[
147		AC_MSG_RESULT([no])
148		AC_MSG_ERROR([
149	*** This kernel does not include the required zlib deflate support.
150	*** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
151	])
152])
153