2 dnl # Default ZFS kernel configuration
4 AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
8 ZFS_AC_KERNEL_MISC_MINOR
11 ZFS_AC_KERNEL_CTL_NAME
12 ZFS_AC_KERNEL_PDE_DATA
13 ZFS_AC_KERNEL_SET_FS_PWD_WITH_CONST
14 ZFS_AC_KERNEL_2ARGS_VFS_FSYNC
15 ZFS_AC_KERNEL_FS_STRUCT_SPINLOCK
16 ZFS_AC_KERNEL_KUIDGID_T
17 ZFS_AC_KERNEL_FALLOCATE
18 ZFS_AC_KERNEL_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
19 ZFS_AC_KERNEL_RWSEM_SPINLOCK_IS_RAW
20 ZFS_AC_KERNEL_RWSEM_ACTIVITY
21 ZFS_AC_KERNEL_RWSEM_ATOMIC_LONG_COUNT
22 ZFS_AC_KERNEL_SCHED_RT_HEADER
23 ZFS_AC_KERNEL_SCHED_SIGNAL_HEADER
24 ZFS_AC_KERNEL_IO_SCHEDULE_TIMEOUT
25 ZFS_AC_KERNEL_4ARGS_VFS_GETATTR
26 ZFS_AC_KERNEL_3ARGS_VFS_GETATTR
27 ZFS_AC_KERNEL_2ARGS_VFS_GETATTR
28 ZFS_AC_KERNEL_USLEEP_RANGE
29 ZFS_AC_KERNEL_KMEM_CACHE_ALLOCFLAGS
30 ZFS_AC_KERNEL_KMEM_CACHE_CREATE_USERCOPY
31 ZFS_AC_KERNEL_WAIT_ON_BIT
32 ZFS_AC_KERNEL_WAIT_QUEUE_ENTRY_T
33 ZFS_AC_KERNEL_WAIT_QUEUE_HEAD_ENTRY
34 ZFS_AC_KERNEL_INODE_TIMES
35 ZFS_AC_KERNEL_INODE_LOCK
36 ZFS_AC_KERNEL_GROUP_INFO_GID
39 ZFS_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST
40 ZFS_AC_KERNEL_DECLARE_EVENT_CLASS
41 ZFS_AC_KERNEL_CURRENT_BIO_TAIL
42 ZFS_AC_KERNEL_SUPER_USER_NS
43 ZFS_AC_KERNEL_SUBMIT_BIO
44 ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_CHECK_EVENTS
45 ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID
46 ZFS_AC_KERNEL_TYPE_FMODE_T
47 ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH
48 ZFS_AC_KERNEL_BLKDEV_REREAD_PART
49 ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE
50 ZFS_AC_KERNEL_LOOKUP_BDEV
51 ZFS_AC_KERNEL_INVALIDATE_BDEV_ARGS
52 ZFS_AC_KERNEL_BDEV_LOGICAL_BLOCK_SIZE
53 ZFS_AC_KERNEL_BDEV_PHYSICAL_BLOCK_SIZE
54 ZFS_AC_KERNEL_BIO_BVEC_ITER
55 ZFS_AC_KERNEL_BIO_FAILFAST_DTD
56 ZFS_AC_KERNEL_BIO_SET_DEV
57 ZFS_AC_KERNEL_REQ_FAILFAST_MASK
58 ZFS_AC_KERNEL_REQ_OP_DISCARD
59 ZFS_AC_KERNEL_REQ_OP_SECURE_ERASE
60 ZFS_AC_KERNEL_REQ_OP_FLUSH
61 ZFS_AC_KERNEL_BIO_BI_OPF
62 ZFS_AC_KERNEL_BIO_END_IO_T_ARGS
63 ZFS_AC_KERNEL_BIO_BI_STATUS
64 ZFS_AC_KERNEL_BIO_RW_BARRIER
65 ZFS_AC_KERNEL_BIO_RW_DISCARD
66 ZFS_AC_KERNEL_BLK_QUEUE_BDI
67 ZFS_AC_KERNEL_BLK_QUEUE_FLAG_CLEAR
68 ZFS_AC_KERNEL_BLK_QUEUE_FLAG_SET
69 ZFS_AC_KERNEL_BLK_QUEUE_FLUSH
70 ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS
71 ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS
72 ZFS_AC_KERNEL_BLK_QUEUE_HAVE_BIO_RW_UNPLUG
73 ZFS_AC_KERNEL_BLK_QUEUE_HAVE_BLK_PLUG
74 ZFS_AC_KERNEL_GET_DISK_AND_MODULE
75 ZFS_AC_KERNEL_GET_DISK_RO
76 ZFS_AC_KERNEL_HAVE_BIO_SET_OP_ATTRS
77 ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL
78 ZFS_AC_KERNEL_DISCARD_GRANULARITY
79 ZFS_AC_KERNEL_CONST_XATTR_HANDLER
80 ZFS_AC_KERNEL_XATTR_HANDLER_NAME
81 ZFS_AC_KERNEL_XATTR_HANDLER_GET
82 ZFS_AC_KERNEL_XATTR_HANDLER_SET
83 ZFS_AC_KERNEL_XATTR_HANDLER_LIST
84 ZFS_AC_KERNEL_INODE_OWNER_OR_CAPABLE
85 ZFS_AC_KERNEL_POSIX_ACL_FROM_XATTR_USERNS
86 ZFS_AC_KERNEL_POSIX_ACL_RELEASE
87 ZFS_AC_KERNEL_SET_CACHED_ACL_USABLE
88 ZFS_AC_KERNEL_POSIX_ACL_CHMOD
89 ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T
90 ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS
91 ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION
92 ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION_WITH_NAMEIDATA
93 ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL
94 ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL_WITH_FLAGS
95 ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL
96 ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL
97 ZFS_AC_KERNEL_INODE_OPERATIONS_GETATTR
98 ZFS_AC_KERNEL_INODE_SET_FLAGS
99 ZFS_AC_KERNEL_INODE_SET_IVERSION
100 ZFS_AC_KERNEL_GET_ACL_HANDLE_CACHE
101 ZFS_AC_KERNEL_SHOW_OPTIONS
102 ZFS_AC_KERNEL_FILE_INODE
103 ZFS_AC_KERNEL_FILE_DENTRY
105 ZFS_AC_KERNEL_EVICT_INODE
106 ZFS_AC_KERNEL_DIRTY_INODE_WITH_FLAGS
107 ZFS_AC_KERNEL_NR_CACHED_OBJECTS
108 ZFS_AC_KERNEL_FREE_CACHED_OBJECTS
109 ZFS_AC_KERNEL_FALLOCATE
110 ZFS_AC_KERNEL_AIO_FSYNC
111 ZFS_AC_KERNEL_MKDIR_UMODE_T
112 ZFS_AC_KERNEL_LOOKUP_NAMEIDATA
113 ZFS_AC_KERNEL_CREATE_NAMEIDATA
114 ZFS_AC_KERNEL_GET_LINK
115 ZFS_AC_KERNEL_PUT_LINK
116 ZFS_AC_KERNEL_TMPFILE
117 ZFS_AC_KERNEL_TRUNCATE_RANGE
118 ZFS_AC_KERNEL_AUTOMOUNT
119 ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
120 ZFS_AC_KERNEL_COMMIT_METADATA
121 ZFS_AC_KERNEL_CLEAR_INODE
122 ZFS_AC_KERNEL_SETATTR_PREPARE
123 ZFS_AC_KERNEL_INSERT_INODE_LOCKED
124 ZFS_AC_KERNEL_D_MAKE_ROOT
125 ZFS_AC_KERNEL_D_OBTAIN_ALIAS
126 ZFS_AC_KERNEL_D_PRUNE_ALIASES
127 ZFS_AC_KERNEL_D_SET_D_OP
128 ZFS_AC_KERNEL_D_REVALIDATE_NAMEIDATA
129 ZFS_AC_KERNEL_CONST_DENTRY_OPERATIONS
130 ZFS_AC_KERNEL_TRUNCATE_SETSIZE
131 ZFS_AC_KERNEL_6ARGS_SECURITY_INODE_INIT_SECURITY
132 ZFS_AC_KERNEL_CALLBACK_SECURITY_INODE_INIT_SECURITY
133 ZFS_AC_KERNEL_FST_MOUNT
135 ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
136 ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT
137 ZFS_AC_KERNEL_SHRINKER_CALLBACK
138 ZFS_AC_KERNEL_S_INSTANCES_LIST_HEAD
141 ZFS_AC_KERNEL_SET_NLINK
142 ZFS_AC_KERNEL_ELEVATOR_CHANGE
143 ZFS_AC_KERNEL_5ARG_SGET
144 ZFS_AC_KERNEL_LSEEK_EXECUTE
145 ZFS_AC_KERNEL_VFS_ITERATE
146 ZFS_AC_KERNEL_VFS_RW_ITERATE
147 ZFS_AC_KERNEL_VFS_DIRECT_IO
148 ZFS_AC_KERNEL_GENERIC_WRITE_CHECKS
149 ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
150 ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
151 ZFS_AC_KERNEL_MAKE_REQUEST_FN
152 ZFS_AC_KERNEL_GENERIC_IO_ACCT_3ARG
153 ZFS_AC_KERNEL_GENERIC_IO_ACCT_4ARG
155 ZFS_AC_KERNEL_KUID_HELPERS
156 ZFS_AC_KERNEL_MODULE_PARAM_CALL_CONST
157 ZFS_AC_KERNEL_RENAME_WANTS_FLAGS
158 ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR
159 ZFS_AC_KERNEL_CURRENT_TIME
160 ZFS_AC_KERNEL_GLOBAL_PAGE_STATE
161 ZFS_AC_KERNEL_ACL_HAS_REFCOUNT
162 ZFS_AC_KERNEL_USERNS_CAPABILITIES
163 ZFS_AC_KERNEL_IN_COMPAT_SYSCALL
164 ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64
166 AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
167 KERNEL_MAKE="$KERNEL_MAKE O=$LINUX_OBJ"
170 AC_SUBST(KERNEL_MAKE)
174 dnl # Detect name used for Module.symvers file in kernel
176 AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
177 modpost=$LINUX/scripts/Makefile.modpost
178 AC_MSG_CHECKING([kernel file name for module symbols])
179 AS_IF([test "x$enable_linux_builtin" != xyes -a -f "$modpost"], [
180 AS_IF([grep -q Modules.symvers $modpost], [
181 LINUX_SYMBOLS=Modules.symvers
183 LINUX_SYMBOLS=Module.symvers
186 AS_IF([test ! -f "$LINUX_OBJ/$LINUX_SYMBOLS"], [
188 *** Please make sure the kernel devel package for your distribution
189 *** is installed. If you are building with a custom kernel, make sure the
190 *** kernel is configured, built, and the '--with-linux=PATH' configure
191 *** option refers to the location of the kernel source.])
196 AC_MSG_RESULT($LINUX_SYMBOLS)
197 AC_SUBST(LINUX_SYMBOLS)
201 dnl # Detect the kernel to be built against
203 AC_DEFUN([ZFS_AC_KERNEL], [
205 AS_HELP_STRING([--with-linux=PATH],
206 [Path to kernel source]),
207 [kernelsrc="$withval"])
209 AC_ARG_WITH(linux-obj,
210 AS_HELP_STRING([--with-linux-obj=PATH],
211 [Path to kernel build objects]),
212 [kernelbuild="$withval"])
214 AC_MSG_CHECKING([kernel source directory])
215 AS_IF([test -z "$kernelsrc"], [
216 AS_IF([test -e "/lib/modules/$(uname -r)/source"], [
217 headersdir="/lib/modules/$(uname -r)/source"
218 sourcelink=$(readlink -f "$headersdir")
219 ], [test -e "/lib/modules/$(uname -r)/build"], [
220 headersdir="/lib/modules/$(uname -r)/build"
221 sourcelink=$(readlink -f "$headersdir")
223 sourcelink=$(ls -1d /usr/src/kernels/* \
225 2>/dev/null | grep -v obj | tail -1)
228 AS_IF([test -n "$sourcelink" && test -e ${sourcelink}], [
229 kernelsrc=`readlink -f ${sourcelink}`
231 kernelsrc="[Not found]"
234 AS_IF([test "$kernelsrc" = "NONE"], [
240 AC_MSG_RESULT([$kernelsrc])
241 AS_IF([test ! -d "$kernelsrc"], [
243 *** Please make sure the kernel devel package for your distribution
244 *** is installed and then try again. If that fails, you can specify the
245 *** location of the kernel source with the '--with-linux=PATH' option.])
248 AC_MSG_CHECKING([kernel build directory])
249 AS_IF([test -z "$kernelbuild"], [
250 AS_IF([test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"], [
251 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
252 ], [test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}], [
253 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
254 ], [test -d ${kernelsrc}-obj/${target_cpu}/default], [
255 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
256 ], [test -d `dirname ${kernelsrc}`/build-${target_cpu}], [
257 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
259 kernelbuild=${kernelsrc}
262 AC_MSG_RESULT([$kernelbuild])
264 AC_MSG_CHECKING([kernel source version])
265 utsrelease1=$kernelbuild/include/linux/version.h
266 utsrelease2=$kernelbuild/include/linux/utsrelease.h
267 utsrelease3=$kernelbuild/include/generated/utsrelease.h
268 AS_IF([test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1], [
269 utsrelease=linux/version.h
270 ], [test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2], [
271 utsrelease=linux/utsrelease.h
272 ], [test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3], [
273 utsrelease=generated/utsrelease.h
276 AS_IF([test "$utsrelease"], [
277 kernsrcver=`(echo "#include <$utsrelease>";
278 echo "kernsrcver=UTS_RELEASE") |
279 ${CPP} -I $kernelbuild/include - |
280 grep "^kernsrcver=" | cut -d \" -f 2`
282 AS_IF([test -z "$kernsrcver"], [
283 AC_MSG_RESULT([Not found])
284 AC_MSG_ERROR([*** Cannot determine kernel version.])
287 AC_MSG_RESULT([Not found])
288 if test "x$enable_linux_builtin" != xyes; then
289 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
292 *** Cannot find UTS_RELEASE definition.
293 *** Please run 'make prepare' inside the kernel source tree.])
297 AC_MSG_RESULT([$kernsrcver])
300 LINUX_OBJ=${kernelbuild}
301 LINUX_VERSION=${kernsrcver}
305 AC_SUBST(LINUX_VERSION)
307 ZFS_AC_MODULE_SYMVERS
311 dnl # Detect the QAT module to be built against
312 dnl # QAT provides hardware acceleration for data compression:
313 dnl # https://01.org/intel-quickassist-technology
314 dnl # * Download and install QAT driver from the above link
315 dnl # * Start QAT driver in your system:
316 dnl # service qat_service start
317 dnl # * Enable QAT in ZFS, e.g.:
318 dnl # ./configure --with-qat=<qat-driver-path>/QAT1.6
320 dnl # * Set GZIP compression in ZFS dataset:
321 dnl # zfs set compression = gzip <dataset>
322 dnl # Then the data written to this ZFS pool is compressed
323 dnl # by QAT accelerator automatically, and de-compressed by
324 dnl # QAT when read from the pool.
325 dnl # * Get QAT hardware statistics by:
326 dnl # cat /proc/icp_dh895xcc_dev/qat
327 dnl # * To disable QAT:
328 dnl # insmod zfs.ko zfs_qat_disable=1
330 AC_DEFUN([ZFS_AC_QAT], [
332 AS_HELP_STRING([--with-qat=PATH],
333 [Path to qat source]),
334 AS_IF([test "$withval" = "yes"],
335 AC_MSG_ERROR([--with-qat=PATH requires a PATH]),
336 [qatsrc="$withval"]))
338 AC_ARG_WITH([qat-obj],
339 AS_HELP_STRING([--with-qat-obj=PATH],
340 [Path to qat build objects]),
341 [qatbuild="$withval"])
343 AS_IF([test ! -z "${qatsrc}"], [
344 AC_MSG_CHECKING([qat source directory])
345 AC_MSG_RESULT([$qatsrc])
346 QAT_SRC="${qatsrc}/quickassist"
347 AS_IF([ test ! -e "$QAT_SRC/include/cpa.h"], [
349 *** Please make sure the qat driver package is installed
350 *** and specify the location of the qat source with the
351 *** '--with-qat=PATH' option then try again. Failed to
357 AS_IF([test ! -z "${qatsrc}"], [
358 AC_MSG_CHECKING([qat build directory])
359 AS_IF([test -z "$qatbuild"], [
360 qatbuild="${qatsrc}/build"
363 AC_MSG_RESULT([$qatbuild])
365 AS_IF([ ! test -e "$QAT_OBJ/icp_qa_al.ko" && ! test -e "$QAT_OBJ/qat_api.ko"], [
367 *** Please make sure the qat driver is installed then try again.
368 *** Failed to find icp_qa_al.ko or qat_api.ko in:
375 AC_DEFINE(HAVE_QAT, 1,
376 [qat is enabled and existed])
380 dnl # Detect the name used for the QAT Module.symvers file.
382 AS_IF([test ! -z "${qatsrc}"], [
383 AC_MSG_CHECKING([qat file for module symbols])
384 QAT_SYMBOLS=$QAT_SRC/lookaside/access_layer/src/Module.symvers
386 AS_IF([test -r $QAT_SYMBOLS], [
387 AC_MSG_RESULT([$QAT_SYMBOLS])
388 AC_SUBST(QAT_SYMBOLS)
391 *** Please make sure the qat driver is installed then try again.
392 *** Failed to find Module.symvers in:
400 dnl # Basic toolchain sanity check.
402 AC_DEFUN([ZFS_AC_TEST_MODULE], [
403 AC_MSG_CHECKING([whether modules can be built])
404 ZFS_LINUX_TRY_COMPILE([],[],[
408 if test "x$enable_linux_builtin" != xyes; then
409 AC_MSG_ERROR([*** Unable to build an empty module.])
412 *** Unable to build an empty module.
413 *** Please run 'make scripts' inside the kernel source tree.])
419 dnl # Certain kernel build options are not supported. These must be
420 dnl # detected at configure time and cause a build failure. Otherwise
421 dnl # modules may be successfully built that behave incorrectly.
423 AC_DEFUN([ZFS_AC_KERNEL_CONFIG], [
424 AS_IF([test "x$cross_compiling" != xyes], [
427 #include "$LINUX/include/linux/license.h"
429 return !license_is_gpl_compatible("$ZFS_META_LICENSE");
432 AC_DEFINE([ZFS_IS_GPL_COMPATIBLE], [1],
433 [Define to 1 if GPL-only symbols can be used])
438 ZFS_AC_KERNEL_CONFIG_THREAD_SIZE
439 ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC
440 ZFS_AC_KERNEL_CONFIG_TRIM_UNUSED_KSYMS
441 ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE
442 ZFS_AC_KERNEL_CONFIG_ZLIB_DEFLATE
446 dnl # Check configured THREAD_SIZE
448 dnl # The stack size will vary by architecture, but as of Linux 3.15 on x86_64
449 dnl # the default thread stack size was increased to 16K from 8K. Therefore,
450 dnl # on newer kernels and some architectures stack usage optimizations can be
451 dnl # conditionally applied to improve performance without negatively impacting
454 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_THREAD_SIZE], [
455 AC_MSG_CHECKING([whether kernel was built with 16K or larger stacks])
456 ZFS_LINUX_TRY_COMPILE([
457 #include <linux/module.h>
459 #if (THREAD_SIZE < 16384)
460 #error "THREAD_SIZE is less than 16K"
464 AC_DEFINE(HAVE_LARGE_STACKS, 1, [kernel has large stacks])
471 dnl # Check CONFIG_DEBUG_LOCK_ALLOC
473 dnl # This is typically only set for debug kernels because it comes with
474 dnl # a performance penalty. However, when it is set it maps the non-GPL
475 dnl # symbol mutex_lock() to the GPL-only mutex_lock_nested() symbol.
476 dnl # This will cause a failure at link time which we'd rather know about
477 dnl # at compile time.
479 dnl # Since we plan to pursue making mutex_lock_nested() a non-GPL symbol
480 dnl # with the upstream community we add a check to detect this case.
482 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC], [
484 ZFS_LINUX_CONFIG([DEBUG_LOCK_ALLOC], [
485 AC_MSG_CHECKING([whether mutex_lock() is GPL-only])
486 tmp_flags="$EXTRA_KCFLAGS"
487 ZFS_LINUX_TRY_COMPILE([
488 #include <linux/module.h>
489 #include <linux/mutex.h>
491 MODULE_LICENSE("$ZFS_META_LICENSE");
503 *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible
504 *** with the CDDL license and will prevent the module linking stage
505 *** from succeeding. You must rebuild your kernel without this
506 *** option enabled.])
508 EXTRA_KCFLAGS="$tmp_flags"
513 dnl # Check CONFIG_TRIM_UNUSED_KSYMS
515 dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS disabled.
517 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_TRIM_UNUSED_KSYMS], [
518 AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
519 ZFS_LINUX_TRY_COMPILE([
520 #if defined(CONFIG_TRIM_UNUSED_KSYMS)
521 #error CONFIG_TRIM_UNUSED_KSYMS not defined
528 *** This kernel has unused symbols trimming enabled, please disable.
529 *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
534 dnl # ZFS_LINUX_CONFTEST_H
536 AC_DEFUN([ZFS_LINUX_CONFTEST_H], [
537 cat - <<_ACEOF >conftest.h
543 dnl # ZFS_LINUX_CONFTEST_C
545 AC_DEFUN([ZFS_LINUX_CONFTEST_C], [
546 cat confdefs.h - <<_ACEOF >conftest.c
552 dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY])
554 m4_define([ZFS_LANG_PROGRAM], [
559 dnl Do *not* indent the following line: there may be CPP directives.
560 dnl Don't move the `;' right after for the same reason.
568 dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
570 AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
571 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST_C([$1])])
572 m4_ifvaln([$6], [ZFS_LINUX_CONFTEST_H([$6])], [ZFS_LINUX_CONFTEST_H([])])
573 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
574 echo "obj-m := conftest.o" >build/Makefile
576 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
578 [AC_TRY_COMMAND(cp conftest.c conftest.h build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror $FRAME_LARGER_THAN $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])],
580 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
586 dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE
588 AC_DEFUN([ZFS_LINUX_TRY_COMPILE],
589 [ZFS_LINUX_COMPILE_IFELSE(
590 [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
592 [test -s build/conftest.o],
597 dnl # ZFS_LINUX_CONFIG
599 AC_DEFUN([ZFS_LINUX_CONFIG],
600 [AC_MSG_CHECKING([whether kernel was built with CONFIG_$1])
601 ZFS_LINUX_TRY_COMPILE([
602 #include <linux/module.h>
605 #error CONFIG_$1 not #defined
617 dnl # ZFS_CHECK_SYMBOL_EXPORT
618 dnl # check symbol exported or not
620 AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
621 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
622 $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
624 if test $rc -ne 0; then
627 grep -q -E "EXPORT_SYMBOL.*($1)" \
628 "$LINUX/$file" 2>/dev/null
630 if test $rc -eq 0; then
635 if test $export -eq 0; then :
646 dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL
647 dnl # like ZFS_LINUX_TRY_COMPILE, except ZFS_CHECK_SYMBOL_EXPORT
648 dnl # is called if not compiling for builtin
650 AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [
651 ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
652 if test $rc -ne 0; then :
655 if test "x$enable_linux_builtin" != xyes; then
656 ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
658 if test $rc -ne 0; then :
667 dnl # ZFS_LINUX_TRY_COMPILE_HEADER
668 dnl # like ZFS_LINUX_TRY_COMPILE, except the contents conftest.h are
669 dnl # provided via the fifth parameter
671 AC_DEFUN([ZFS_LINUX_TRY_COMPILE_HEADER],
672 [ZFS_LINUX_COMPILE_IFELSE(
673 [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
675 [test -s build/conftest.o],