]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - zfs/config/kernel.m4
53720eeef5cfff103ae5aaf04aab064081d9e1b6
[mirror_ubuntu-zesty-kernel.git] / zfs / config / kernel.m4
1 dnl #
2 dnl # Default ZFS kernel configuration
3 dnl #
4 AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
5 ZFS_AC_KERNEL
6 ZFS_AC_SPL
7 ZFS_AC_TEST_MODULE
8 ZFS_AC_KERNEL_CONFIG
9 ZFS_AC_KERNEL_DECLARE_EVENT_CLASS
10 ZFS_AC_KERNEL_CURRENT_BIO_TAIL
11 ZFS_AC_KERNEL_SUBMIT_BIO
12 ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS
13 ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID
14 ZFS_AC_KERNEL_TYPE_FMODE_T
15 ZFS_AC_KERNEL_KOBJ_NAME_LEN
16 ZFS_AC_KERNEL_3ARG_BLKDEV_GET
17 ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH
18 ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE
19 ZFS_AC_KERNEL_LOOKUP_BDEV
20 ZFS_AC_KERNEL_INVALIDATE_BDEV_ARGS
21 ZFS_AC_KERNEL_BDEV_LOGICAL_BLOCK_SIZE
22 ZFS_AC_KERNEL_BDEV_PHYSICAL_BLOCK_SIZE
23 ZFS_AC_KERNEL_BIO_BVEC_ITER
24 ZFS_AC_KERNEL_BIO_FAILFAST_DTD
25 ZFS_AC_KERNEL_REQ_FAILFAST_MASK
26 ZFS_AC_KERNEL_REQ_OP_DISCARD
27 ZFS_AC_KERNEL_REQ_OP_SECURE_ERASE
28 ZFS_AC_KERNEL_REQ_OP_FLUSH
29 ZFS_AC_KERNEL_BIO_BI_OPF
30 ZFS_AC_KERNEL_BIO_END_IO_T_ARGS
31 ZFS_AC_KERNEL_BIO_RW_BARRIER
32 ZFS_AC_KERNEL_BIO_RW_DISCARD
33 ZFS_AC_KERNEL_BLK_QUEUE_FLUSH
34 ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS
35 ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS
36 ZFS_AC_KERNEL_GET_DISK_RO
37 ZFS_AC_KERNEL_GET_GENDISK
38 ZFS_AC_KERNEL_DISCARD_GRANULARITY
39 ZFS_AC_KERNEL_CONST_XATTR_HANDLER
40 ZFS_AC_KERNEL_XATTR_HANDLER_NAME
41 ZFS_AC_KERNEL_XATTR_HANDLER_GET
42 ZFS_AC_KERNEL_XATTR_HANDLER_SET
43 ZFS_AC_KERNEL_XATTR_HANDLER_LIST
44 ZFS_AC_KERNEL_INODE_OWNER_OR_CAPABLE
45 ZFS_AC_KERNEL_POSIX_ACL_FROM_XATTR_USERNS
46 ZFS_AC_KERNEL_POSIX_ACL_RELEASE
47 ZFS_AC_KERNEL_POSIX_ACL_CHMOD
48 ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T
49 ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS
50 ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION
51 ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION_WITH_NAMEIDATA
52 ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL
53 ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL_WITH_FLAGS
54 ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL
55 ZFS_AC_KERNE_GET_ACL_HANDLE_CACHE
56 ZFS_AC_KERNEL_SHOW_OPTIONS
57 ZFS_AC_KERNEL_FILE_INODE
58 ZFS_AC_KERNEL_FSYNC
59 ZFS_AC_KERNEL_EVICT_INODE
60 ZFS_AC_KERNEL_DIRTY_INODE_WITH_FLAGS
61 ZFS_AC_KERNEL_NR_CACHED_OBJECTS
62 ZFS_AC_KERNEL_FREE_CACHED_OBJECTS
63 ZFS_AC_KERNEL_FALLOCATE
64 ZFS_AC_KERNEL_MKDIR_UMODE_T
65 ZFS_AC_KERNEL_LOOKUP_NAMEIDATA
66 ZFS_AC_KERNEL_CREATE_NAMEIDATA
67 ZFS_AC_KERNEL_GET_LINK
68 ZFS_AC_KERNEL_PUT_LINK
69 ZFS_AC_KERNEL_TRUNCATE_RANGE
70 ZFS_AC_KERNEL_AUTOMOUNT
71 ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
72 ZFS_AC_KERNEL_COMMIT_METADATA
73 ZFS_AC_KERNEL_CLEAR_INODE
74 ZFS_AC_KERNEL_INSERT_INODE_LOCKED
75 ZFS_AC_KERNEL_D_MAKE_ROOT
76 ZFS_AC_KERNEL_D_OBTAIN_ALIAS
77 ZFS_AC_KERNEL_D_PRUNE_ALIASES
78 ZFS_AC_KERNEL_D_SET_D_OP
79 ZFS_AC_KERNEL_D_REVALIDATE_NAMEIDATA
80 ZFS_AC_KERNEL_CONST_DENTRY_OPERATIONS
81 ZFS_AC_KERNEL_CHECK_DISK_SIZE_CHANGE
82 ZFS_AC_KERNEL_TRUNCATE_SETSIZE
83 ZFS_AC_KERNEL_6ARGS_SECURITY_INODE_INIT_SECURITY
84 ZFS_AC_KERNEL_CALLBACK_SECURITY_INODE_INIT_SECURITY
85 ZFS_AC_KERNEL_MOUNT_NODEV
86 ZFS_AC_KERNEL_SHRINK
87 ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
88 ZFS_AC_KERNEL_S_INSTANCES_LIST_HEAD
89 ZFS_AC_KERNEL_S_D_OP
90 ZFS_AC_KERNEL_BDI_SETUP_AND_REGISTER
91 ZFS_AC_KERNEL_SET_NLINK
92 ZFS_AC_KERNEL_ELEVATOR_CHANGE
93 ZFS_AC_KERNEL_5ARG_SGET
94 ZFS_AC_KERNEL_LSEEK_EXECUTE
95 ZFS_AC_KERNEL_VFS_ITERATE
96 ZFS_AC_KERNEL_VFS_RW_ITERATE
97 ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
98 ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
99 ZFS_AC_KERNEL_MAKE_REQUEST_FN
100 ZFS_AC_KERNEL_GENERIC_IO_ACCT
101
102 AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
103 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
104 ])
105 AC_SUBST(KERNELMAKE_PARAMS)
106
107
108 dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
109 dnl # compiler options are added by the kernel build system.
110 KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_UNUSED_BUT_SET_VARIABLE"
111 KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_BOOL_COMPARE"
112 KERNELCPPFLAGS="$KERNELCPPFLAGS -DHAVE_SPL -D_KERNEL"
113 KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\""
114
115 AC_SUBST(KERNELCPPFLAGS)
116 ])
117
118 dnl #
119 dnl # Detect name used for Module.symvers file in kernel
120 dnl #
121 AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
122 modpost=$LINUX/scripts/Makefile.modpost
123 AC_MSG_CHECKING([kernel file name for module symbols])
124 AS_IF([test "x$enable_linux_builtin" != xyes -a -f "$modpost"], [
125 AS_IF([grep -q Modules.symvers $modpost], [
126 LINUX_SYMBOLS=Modules.symvers
127 ], [
128 LINUX_SYMBOLS=Module.symvers
129 ])
130
131 AS_IF([test ! -f "$LINUX_OBJ/$LINUX_SYMBOLS"], [
132 AC_MSG_ERROR([
133 *** Please make sure the kernel devel package for your distribution
134 *** is installed. If you are building with a custom kernel, make sure the
135 *** kernel is configured, built, and the '--with-linux=PATH' configure
136 *** option refers to the location of the kernel source.])
137 ])
138 ], [
139 LINUX_SYMBOLS=NONE
140 ])
141 AC_MSG_RESULT($LINUX_SYMBOLS)
142 AC_SUBST(LINUX_SYMBOLS)
143 ])
144
145 dnl #
146 dnl # Detect the kernel to be built against
147 dnl #
148 AC_DEFUN([ZFS_AC_KERNEL], [
149 AC_ARG_WITH([linux],
150 AS_HELP_STRING([--with-linux=PATH],
151 [Path to kernel source]),
152 [kernelsrc="$withval"])
153
154 AC_ARG_WITH(linux-obj,
155 AS_HELP_STRING([--with-linux-obj=PATH],
156 [Path to kernel build objects]),
157 [kernelbuild="$withval"])
158
159 AC_MSG_CHECKING([kernel source directory])
160 AS_IF([test -z "$kernelsrc"], [
161 AS_IF([test -e "/lib/modules/$(uname -r)/source"], [
162 headersdir="/lib/modules/$(uname -r)/source"
163 sourcelink=$(readlink -f "$headersdir")
164 ], [test -e "/lib/modules/$(uname -r)/build"], [
165 headersdir="/lib/modules/$(uname -r)/build"
166 sourcelink=$(readlink -f "$headersdir")
167 ], [
168 sourcelink=$(ls -1d /usr/src/kernels/* \
169 /usr/src/linux-* \
170 2>/dev/null | grep -v obj | tail -1)
171 ])
172
173 AS_IF([test -n "$sourcelink" && test -e ${sourcelink}], [
174 kernelsrc=`readlink -f ${sourcelink}`
175 ], [
176 kernelsrc="[Not found]"
177 ])
178 ], [
179 AS_IF([test "$kernelsrc" = "NONE"], [
180 kernsrcver=NONE
181 ])
182 ])
183
184 AC_MSG_RESULT([$kernelsrc])
185 AS_IF([test ! -d "$kernelsrc"], [
186 AC_MSG_ERROR([
187 *** Please make sure the kernel devel package for your distribution
188 *** is installed and then try again. If that fails, you can specify the
189 *** location of the kernel source with the '--with-linux=PATH' option.])
190 ])
191
192 AC_MSG_CHECKING([kernel build directory])
193 AS_IF([test -z "$kernelbuild"], [
194 AS_IF([test -e "/lib/modules/$(uname -r)/build"], [
195 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
196 ], [test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}], [
197 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
198 ], [test -d ${kernelsrc}-obj/${target_cpu}/default], [
199 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
200 ], [test -d `dirname ${kernelsrc}`/build-${target_cpu}], [
201 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
202 ], [
203 kernelbuild=${kernelsrc}
204 ])
205 ])
206 AC_MSG_RESULT([$kernelbuild])
207
208 AC_MSG_CHECKING([kernel source version])
209 utsrelease1=$kernelbuild/include/linux/version.h
210 utsrelease2=$kernelbuild/include/linux/utsrelease.h
211 utsrelease3=$kernelbuild/include/generated/utsrelease.h
212 AS_IF([test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1], [
213 utsrelease=linux/version.h
214 ], [test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2], [
215 utsrelease=linux/utsrelease.h
216 ], [test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3], [
217 utsrelease=generated/utsrelease.h
218 ])
219
220 AS_IF([test "$utsrelease"], [
221 kernsrcver=`(echo "#include <$utsrelease>";
222 echo "kernsrcver=UTS_RELEASE") |
223 cpp -I $kernelbuild/include |
224 grep "^kernsrcver=" | cut -d \" -f 2`
225
226 AS_IF([test -z "$kernsrcver"], [
227 AC_MSG_RESULT([Not found])
228 AC_MSG_ERROR([*** Cannot determine kernel version.])
229 ])
230 ], [
231 AC_MSG_RESULT([Not found])
232 if test "x$enable_linux_builtin" != xyes; then
233 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
234 else
235 AC_MSG_ERROR([
236 *** Cannot find UTS_RELEASE definition.
237 *** Please run 'make prepare' inside the kernel source tree.])
238 fi
239 ])
240
241 AC_MSG_RESULT([$kernsrcver])
242
243 LINUX=${kernelsrc}
244 LINUX_OBJ=${kernelbuild}
245 LINUX_VERSION=${kernsrcver}
246
247 AC_SUBST(LINUX)
248 AC_SUBST(LINUX_OBJ)
249 AC_SUBST(LINUX_VERSION)
250
251 ZFS_AC_MODULE_SYMVERS
252 ])
253
254
255 dnl #
256 dnl # Detect the SPL module to be built against
257 dnl #
258 AC_DEFUN([ZFS_AC_SPL], [
259 AC_ARG_WITH([spl],
260 AS_HELP_STRING([--with-spl=PATH],
261 [Path to spl source]),
262 [splsrc="$withval"])
263
264 AC_ARG_WITH([spl-obj],
265 AS_HELP_STRING([--with-spl-obj=PATH],
266 [Path to spl build objects]),
267 [splbuild="$withval"])
268
269 AC_ARG_WITH([spl-timeout],
270 AS_HELP_STRING([--with-spl-timeout=SECS],
271 [Wait SECS for SPL header and symver file @<:@default=0@:>@]),
272 [timeout="$withval"], [timeout=0])
273
274 dnl #
275 dnl # The existence of spl.release.in is used to identify a valid
276 dnl # source directory. In order of preference:
277 dnl #
278 splsrc0="/var/lib/dkms/spl/${VERSION}/build"
279 splsrc1="/usr/local/src/spl-${VERSION}/${LINUX_VERSION}"
280 splsrc2="/usr/local/src/spl-${VERSION}"
281 splsrc3="/usr/src/spl-${VERSION}/${LINUX_VERSION}"
282 splsrc4="/usr/src/spl-${VERSION}"
283 splsrc5="../spl/"
284 splsrc6="$LINUX"
285
286 AC_MSG_CHECKING([spl source directory])
287 AS_IF([test -z "${splsrc}"], [
288 AS_IF([ test -e "${splsrc0}/spl.release.in"], [
289 splsrc=${splsrc0}
290 ], [ test -e "${splsrc1}/spl.release.in"], [
291 splsrc=${splsrc1}
292 ], [ test -e "${splsrc2}/spl.release.in"], [
293 splsrc=${splsrc2}
294 ], [ test -e "${splsrc3}/spl.release.in"], [
295 splsrc=$(readlink -f "${splsrc3}")
296 ], [ test -e "${splsrc4}/spl.release.in" ], [
297 splsrc=${splsrc4}
298 ], [ test -e "${splsrc5}/spl.release.in"], [
299 splsrc=$(readlink -f "${splsrc5}")
300 ], [ test -e "${splsrc6}/spl.release.in" ], [
301 splsrc=${splsrc6}
302 ], [
303 splsrc="[Not found]"
304 ])
305 ], [
306 AS_IF([test "$splsrc" = "NONE"], [
307 splbuild=NONE
308 splsrcver=NONE
309 ])
310 ])
311
312 AC_MSG_RESULT([$splsrc])
313 AS_IF([ test ! -e "$splsrc/spl.release.in"], [
314 AC_MSG_ERROR([
315 *** Please make sure the kmod spl devel package for your distribution
316 *** is installed then try again. If that fails you can specify the
317 *** location of the spl source with the '--with-spl=PATH' option.])
318 ])
319
320 dnl #
321 dnl # The existence of the spl_config.h is used to identify a valid
322 dnl # spl object directory. In many cases the object and source
323 dnl # directory are the same, however the objects may also reside
324 dnl # is a subdirectory named after the kernel version.
325 dnl #
326 dnl # This file is supposed to be available after DKMS finishes
327 dnl # building the SPL kernel module for the target kernel. The
328 dnl # '--with-spl-timeout' option can be passed to pause here,
329 dnl # waiting for the file to appear from a concurrently building
330 dnl # SPL package.
331 dnl #
332 AC_MSG_CHECKING([spl build directory])
333 while true; do
334 AS_IF([test -z "$splbuild"], [
335 AS_IF([ test -e "${splsrc}/${LINUX_VERSION}/spl_config.h" ], [
336 splbuild="${splsrc}/${LINUX_VERSION}"
337 ], [ test -e "${splsrc}/spl_config.h" ], [
338 splbuild="${splsrc}"
339 ], [ find -L "${splsrc}" -name spl_config.h 2> /dev/null | grep -wq spl_config.h ], [
340 splbuild=$(find -L "${splsrc}" -name spl_config.h | sed 's,/spl_config.h,,')
341 ], [
342 splbuild="[Not found]"
343 ])
344 ])
345 AS_IF([test -e "$splbuild/spl_config.h" -o $timeout -le 0], [
346 break;
347 ], [
348 sleep 1
349 timeout=$((timeout-1))
350 ])
351 done
352
353 AC_MSG_RESULT([$splbuild])
354 AS_IF([ ! test -e "$splbuild/spl_config.h"], [
355 AC_MSG_ERROR([
356 *** Please make sure the kmod spl devel <kernel> package for your
357 *** distribution is installed then try again. If that fails you
358 *** can specify the location of the spl objects with the
359 *** '--with-spl-obj=PATH' option.])
360 ])
361
362 AC_MSG_CHECKING([spl source version])
363 AS_IF([test -r $splbuild/spl_config.h &&
364 fgrep -q SPL_META_VERSION $splbuild/spl_config.h], [
365
366 splsrcver=`(echo "#include <spl_config.h>";
367 echo "splsrcver=SPL_META_VERSION-SPL_META_RELEASE") |
368 cpp -I $splbuild |
369 grep "^splsrcver=" | tr -d \" | cut -d= -f2`
370 ])
371
372 AS_IF([test -z "$splsrcver"], [
373 AC_MSG_RESULT([Not found])
374 AC_MSG_ERROR([
375 *** Cannot determine the version of the spl source.
376 *** Please prepare the spl source before running this script])
377 ])
378
379 AC_MSG_RESULT([$splsrcver])
380
381 SPL=${splsrc}
382 SPL_OBJ=${splbuild}
383 SPL_VERSION=${splsrcver}
384
385 AC_SUBST(SPL)
386 AC_SUBST(SPL_OBJ)
387 AC_SUBST(SPL_VERSION)
388
389 dnl #
390 dnl # Detect the name used for the SPL Module.symvers file. If one
391 dnl # does not exist this is likely because the SPL has been configured
392 dnl # but not built. The '--with-spl-timeout' option can be passed
393 dnl # to pause here, waiting for the file to appear from a concurrently
394 dnl # building SPL package. If the file does not appear in time, a good
395 dnl # guess is made as to what this file will be named based on what it
396 dnl # is named in the kernel build products. This file will first be
397 dnl # used at link time so if the guess is wrong the build will fail
398 dnl # then. This unfortunately means the ZFS package does not contain a
399 dnl # reliable mechanism to detect symbols exported by the SPL at
400 dnl # configure time.
401 dnl #
402 AC_MSG_CHECKING([spl file name for module symbols])
403 SPL_SYMBOLS=NONE
404
405 while true; do
406 AS_IF([test -r $SPL_OBJ/Module.symvers], [
407 SPL_SYMBOLS=Module.symvers
408 ], [test -r $SPL_OBJ/Modules.symvers], [
409 SPL_SYMBOLS=Modules.symvers
410 ], [test -r $SPL_OBJ/module/Module.symvers], [
411 SPL_SYMBOLS=Module.symvers
412 ], [test -r $SPL_OBJ/module/Modules.symvers], [
413 SPL_SYMBOLS=Modules.symvers
414 ])
415
416 AS_IF([test $SPL_SYMBOLS != NONE -o $timeout -le 0], [
417 break;
418 ], [
419 sleep 1
420 timeout=$((timeout-1))
421 ])
422 done
423
424 AS_IF([test "$SPL_SYMBOLS" = NONE], [
425 SPL_SYMBOLS=$LINUX_SYMBOLS
426 ])
427
428 AC_MSG_RESULT([$SPL_SYMBOLS])
429 AC_SUBST(SPL_SYMBOLS)
430 ])
431
432 dnl #
433 dnl # Basic toolchain sanity check.
434 dnl #
435 AC_DEFUN([ZFS_AC_TEST_MODULE], [
436 AC_MSG_CHECKING([whether modules can be built])
437 ZFS_LINUX_TRY_COMPILE([],[],[
438 AC_MSG_RESULT([yes])
439 ],[
440 AC_MSG_RESULT([no])
441 if test "x$enable_linux_builtin" != xyes; then
442 AC_MSG_ERROR([*** Unable to build an empty module.])
443 else
444 AC_MSG_ERROR([
445 *** Unable to build an empty module.
446 *** Please run 'make scripts' inside the kernel source tree.])
447 fi
448 ])
449 ])
450
451 dnl #
452 dnl # Certain kernel build options are not supported. These must be
453 dnl # detected at configure time and cause a build failure. Otherwise
454 dnl # modules may be successfully built that behave incorrectly.
455 dnl #
456 AC_DEFUN([ZFS_AC_KERNEL_CONFIG], [
457 AS_IF([test "x$cross_compiling" != xyes], [
458 AC_RUN_IFELSE([
459 AC_LANG_PROGRAM([
460 #include "$LINUX/include/linux/license.h"
461 ], [
462 return !license_is_gpl_compatible("$ZFS_META_LICENSE");
463 ])
464 ], [
465 AC_DEFINE([ZFS_IS_GPL_COMPATIBLE], [1],
466 [Define to 1 if GPL-only symbols can be used])
467 ], [
468 ])
469 ])
470
471 ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC
472 ])
473
474 dnl #
475 dnl # Check CONFIG_DEBUG_LOCK_ALLOC
476 dnl #
477 dnl # This is typically only set for debug kernels because it comes with
478 dnl # a performance penalty. However, when it is set it maps the non-GPL
479 dnl # symbol mutex_lock() to the GPL-only mutex_lock_nested() symbol.
480 dnl # This will cause a failure at link time which we'd rather know about
481 dnl # at compile time.
482 dnl #
483 dnl # Since we plan to pursue making mutex_lock_nested() a non-GPL symbol
484 dnl # with the upstream community we add a check to detect this case.
485 dnl #
486 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC], [
487
488 ZFS_LINUX_CONFIG([DEBUG_LOCK_ALLOC], [
489 AC_MSG_CHECKING([whether mutex_lock() is GPL-only])
490 tmp_flags="$EXTRA_KCFLAGS"
491 ZFS_LINUX_TRY_COMPILE([
492 #include <linux/module.h>
493 #include <linux/mutex.h>
494
495 MODULE_LICENSE("$ZFS_META_LICENSE");
496 ],[
497 struct mutex lock;
498
499 mutex_init(&lock);
500 mutex_lock(&lock);
501 mutex_unlock(&lock);
502 ],[
503 AC_MSG_RESULT(no)
504 ],[
505 AC_MSG_RESULT(yes)
506 AC_MSG_ERROR([
507 *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible
508 *** with the CDDL license and will prevent the module linking stage
509 *** from succeeding. You must rebuild your kernel without this
510 *** option enabled.])
511 ])
512 EXTRA_KCFLAGS="$tmp_flags"
513 ], [])
514 ])
515
516 dnl #
517 dnl # ZFS_LINUX_CONFTEST_H
518 dnl #
519 AC_DEFUN([ZFS_LINUX_CONFTEST_H], [
520 cat - <<_ACEOF >conftest.h
521 $1
522 _ACEOF
523 ])
524
525 dnl #
526 dnl # ZFS_LINUX_CONFTEST_C
527 dnl #
528 AC_DEFUN([ZFS_LINUX_CONFTEST_C], [
529 cat confdefs.h - <<_ACEOF >conftest.c
530 $1
531 _ACEOF
532 ])
533
534 dnl #
535 dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY])
536 dnl #
537 m4_define([ZFS_LANG_PROGRAM], [
538 $1
539 int
540 main (void)
541 {
542 dnl Do *not* indent the following line: there may be CPP directives.
543 dnl Don't move the `;' right after for the same reason.
544 $2
545 ;
546 return 0;
547 }
548 ])
549
550 dnl #
551 dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
552 dnl #
553 AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
554 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST_C([$1])])
555 m4_ifvaln([$6], [ZFS_LINUX_CONFTEST_H([$6])], [ZFS_LINUX_CONFTEST_H([])])
556 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
557 echo "obj-m := conftest.o" >build/Makefile
558 modpost_flag=''
559 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
560 AS_IF(
561 [AC_TRY_COMMAND(cp conftest.c conftest.h build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])],
562 [$4],
563 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
564 )
565 rm -Rf build
566 ])
567
568 dnl #
569 dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE
570 dnl #
571 AC_DEFUN([ZFS_LINUX_TRY_COMPILE],
572 [ZFS_LINUX_COMPILE_IFELSE(
573 [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
574 [modules],
575 [test -s build/conftest.o],
576 [$3], [$4])
577 ])
578
579 dnl #
580 dnl # ZFS_LINUX_CONFIG
581 dnl #
582 AC_DEFUN([ZFS_LINUX_CONFIG],
583 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
584 ZFS_LINUX_TRY_COMPILE([
585 #include <linux/module.h>
586 ],[
587 #ifndef CONFIG_$1
588 #error CONFIG_$1 not #defined
589 #endif
590 ],[
591 AC_MSG_RESULT([yes])
592 $2
593 ],[
594 AC_MSG_RESULT([no])
595 $3
596 ])
597 ])
598
599 dnl #
600 dnl # ZFS_CHECK_SYMBOL_EXPORT
601 dnl # check symbol exported or not
602 dnl #
603 AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
604 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
605 $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
606 rc=$?
607 if test $rc -ne 0; then
608 export=0
609 for file in $2; do
610 grep -q -E "EXPORT_SYMBOL.*($1)" \
611 "$LINUX/$file" 2>/dev/null
612 rc=$?
613 if test $rc -eq 0; then
614 export=1
615 break;
616 fi
617 done
618 if test $export -eq 0; then :
619 $4
620 else :
621 $3
622 fi
623 else :
624 $3
625 fi
626 ])
627
628 dnl #
629 dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL
630 dnl # like ZFS_LINUX_TRY_COMPILE, except ZFS_CHECK_SYMBOL_EXPORT
631 dnl # is called if not compiling for builtin
632 dnl #
633 AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [
634 ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
635 if test $rc -ne 0; then :
636 $6
637 else
638 if test "x$enable_linux_builtin" != xyes; then
639 ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
640 fi
641 if test $rc -ne 0; then :
642 $6
643 else :
644 $5
645 fi
646 fi
647 ])
648
649 dnl #
650 dnl # ZFS_LINUX_TRY_COMPILE_HEADER
651 dnl # like ZFS_LINUX_TRY_COMPILE, except the contents conftest.h are
652 dnl # provided via the fifth parameter
653 dnl #
654 AC_DEFUN([ZFS_LINUX_TRY_COMPILE_HEADER],
655 [ZFS_LINUX_COMPILE_IFELSE(
656 [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
657 [modules],
658 [test -s build/conftest.o],
659 [$3], [$4], [$5])
660 ])