]> git.proxmox.com Git - mirror_zfs-debian.git/blame - config/kernel.m4
New upstream version 0.7.3
[mirror_zfs-debian.git] / config / kernel.m4
CommitLineData
c9c0d073 1dnl #
cae5b340 2dnl # Default ZFS kernel configuration
c9c0d073
BB
3dnl #
4AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
5 ZFS_AC_KERNEL
6 ZFS_AC_SPL
cae5b340 7 ZFS_AC_QAT
319a99a3 8 ZFS_AC_TEST_MODULE
cae5b340 9 ZFS_AC_KERNEL_OBJTOOL
c9c0d073 10 ZFS_AC_KERNEL_CONFIG
ea04106b 11 ZFS_AC_KERNEL_DECLARE_EVENT_CLASS
e10b0808 12 ZFS_AC_KERNEL_CURRENT_BIO_TAIL
cae5b340 13 ZFS_AC_KERNEL_SUPER_USER_NS
87dac73d 14 ZFS_AC_KERNEL_SUBMIT_BIO
c9c0d073 15 ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS
c06d4368 16 ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID
c9c0d073 17 ZFS_AC_KERNEL_TYPE_FMODE_T
b5a28807 18 ZFS_AC_KERNEL_3ARG_BLKDEV_GET
45066d1f 19 ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH
c9c0d073 20 ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE
2b7ab9d4 21 ZFS_AC_KERNEL_LOOKUP_BDEV
c9c0d073
BB
22 ZFS_AC_KERNEL_INVALIDATE_BDEV_ARGS
23 ZFS_AC_KERNEL_BDEV_LOGICAL_BLOCK_SIZE
2404b014 24 ZFS_AC_KERNEL_BDEV_PHYSICAL_BLOCK_SIZE
ea04106b 25 ZFS_AC_KERNEL_BIO_BVEC_ITER
f4af6bb7 26 ZFS_AC_KERNEL_BIO_FAILFAST_DTD
cae5b340 27 ZFS_AC_KERNEL_BIO_SET_DEV
f4af6bb7 28 ZFS_AC_KERNEL_REQ_FAILFAST_MASK
87dac73d
AX
29 ZFS_AC_KERNEL_REQ_OP_DISCARD
30 ZFS_AC_KERNEL_REQ_OP_SECURE_ERASE
31 ZFS_AC_KERNEL_REQ_OP_FLUSH
32 ZFS_AC_KERNEL_BIO_BI_OPF
c9c0d073 33 ZFS_AC_KERNEL_BIO_END_IO_T_ARGS
cae5b340 34 ZFS_AC_KERNEL_BIO_BI_STATUS
e10b0808
AX
35 ZFS_AC_KERNEL_BIO_RW_BARRIER
36 ZFS_AC_KERNEL_BIO_RW_DISCARD
cae5b340 37 ZFS_AC_KERNEL_BLK_QUEUE_BDI
b18019d2 38 ZFS_AC_KERNEL_BLK_QUEUE_FLUSH
34037afe
ED
39 ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS
40 ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS
68d83c55
AX
41 ZFS_AC_KERNEL_BLK_QUEUE_HAVE_BIO_RW_UNPLUG
42 ZFS_AC_KERNEL_BLK_QUEUE_HAVE_BLK_PLUG
c9c0d073 43 ZFS_AC_KERNEL_GET_DISK_RO
b5a28807 44 ZFS_AC_KERNEL_GET_GENDISK
68d83c55
AX
45 ZFS_AC_KERNEL_HAVE_BIO_SET_OP_ATTRS
46 ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL
ee5fd0bb 47 ZFS_AC_KERNEL_DISCARD_GRANULARITY
777d4af8 48 ZFS_AC_KERNEL_CONST_XATTR_HANDLER
5eacc075 49 ZFS_AC_KERNEL_XATTR_HANDLER_NAME
f9637c6c
BB
50 ZFS_AC_KERNEL_XATTR_HANDLER_GET
51 ZFS_AC_KERNEL_XATTR_HANDLER_SET
a08ee875
LG
52 ZFS_AC_KERNEL_XATTR_HANDLER_LIST
53 ZFS_AC_KERNEL_INODE_OWNER_OR_CAPABLE
54 ZFS_AC_KERNEL_POSIX_ACL_FROM_XATTR_USERNS
55 ZFS_AC_KERNEL_POSIX_ACL_RELEASE
68d83c55 56 ZFS_AC_KERNEL_SET_CACHED_ACL_USABLE
a08ee875 57 ZFS_AC_KERNEL_POSIX_ACL_CHMOD
a08ee875 58 ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T
87dac73d 59 ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS
a08ee875
LG
60 ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION
61 ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION_WITH_NAMEIDATA
62 ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL
63 ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL_WITH_FLAGS
64 ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL
68d83c55 65 ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL
22929307 66 ZFS_AC_KERNEL_INODE_OPERATIONS_GETATTR
cae5b340 67 ZFS_AC_KERNEL_INODE_SET_FLAGS
68d83c55 68 ZFS_AC_KERNEL_GET_ACL_HANDLE_CACHE
47621f3d 69 ZFS_AC_KERNEL_SHOW_OPTIONS
ea04106b 70 ZFS_AC_KERNEL_FILE_INODE
cae5b340 71 ZFS_AC_KERNEL_FILE_DENTRY
adcd70bd 72 ZFS_AC_KERNEL_FSYNC
2c395def 73 ZFS_AC_KERNEL_EVICT_INODE
8780c539 74 ZFS_AC_KERNEL_DIRTY_INODE_WITH_FLAGS
ab26409d
BB
75 ZFS_AC_KERNEL_NR_CACHED_OBJECTS
76 ZFS_AC_KERNEL_FREE_CACHED_OBJECTS
cb2d1901 77 ZFS_AC_KERNEL_FALLOCATE
68d83c55 78 ZFS_AC_KERNEL_AIO_FSYNC
95f5c63b 79 ZFS_AC_KERNEL_MKDIR_UMODE_T
8f195a90 80 ZFS_AC_KERNEL_LOOKUP_NAMEIDATA
558ef6d0 81 ZFS_AC_KERNEL_CREATE_NAMEIDATA
4d815aed 82 ZFS_AC_KERNEL_GET_LINK
e10b0808 83 ZFS_AC_KERNEL_PUT_LINK
cae5b340 84 ZFS_AC_KERNEL_TMPFILE
ea1fdf46 85 ZFS_AC_KERNEL_TRUNCATE_RANGE
ebe7e575 86 ZFS_AC_KERNEL_AUTOMOUNT
756c3e5a 87 ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
393b44c7 88 ZFS_AC_KERNEL_COMMIT_METADATA
739a1a82 89 ZFS_AC_KERNEL_CLEAR_INODE
68d83c55 90 ZFS_AC_KERNEL_SETATTR_PREPARE
bdf4328b 91 ZFS_AC_KERNEL_INSERT_INODE_LOCKED
6a0936ba 92 ZFS_AC_KERNEL_D_MAKE_ROOT
055656d4 93 ZFS_AC_KERNEL_D_OBTAIN_ALIAS
ea04106b 94 ZFS_AC_KERNEL_D_PRUNE_ALIASES
f1a05fa1
NB
95 ZFS_AC_KERNEL_D_SET_D_OP
96 ZFS_AC_KERNEL_D_REVALIDATE_NAMEIDATA
97 ZFS_AC_KERNEL_CONST_DENTRY_OPERATIONS
b3129792 98 ZFS_AC_KERNEL_TRUNCATE_SETSIZE
5c03efc3 99 ZFS_AC_KERNEL_6ARGS_SECURITY_INODE_INIT_SECURITY
166dd49d 100 ZFS_AC_KERNEL_CALLBACK_SECURITY_INODE_INIT_SECURITY
2cf7f52b 101 ZFS_AC_KERNEL_MOUNT_NODEV
ab26409d 102 ZFS_AC_KERNEL_SHRINK
ea04106b 103 ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
c06d4368 104 ZFS_AC_KERNEL_S_INSTANCES_LIST_HEAD
ee930353 105 ZFS_AC_KERNEL_S_D_OP
22929307 106 ZFS_AC_KERNEL_BDI
28eb9213 107 ZFS_AC_KERNEL_SET_NLINK
6d1d976b 108 ZFS_AC_KERNEL_ELEVATOR_CHANGE
3c203610 109 ZFS_AC_KERNEL_5ARG_SGET
c06d4368
AX
110 ZFS_AC_KERNEL_LSEEK_EXECUTE
111 ZFS_AC_KERNEL_VFS_ITERATE
ea04106b 112 ZFS_AC_KERNEL_VFS_RW_ITERATE
68d83c55 113 ZFS_AC_KERNEL_GENERIC_WRITE_CHECKS
e10b0808
AX
114 ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
115 ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
116 ZFS_AC_KERNEL_MAKE_REQUEST_FN
cae5b340
AX
117 ZFS_AC_KERNEL_GENERIC_IO_ACCT_3ARG
118 ZFS_AC_KERNEL_GENERIC_IO_ACCT_4ARG
119 ZFS_AC_KERNEL_FPU
120 ZFS_AC_KERNEL_KUID_HELPERS
121 ZFS_AC_KERNEL_MODULE_PARAM_CALL_CONST
68d83c55
AX
122 ZFS_AC_KERNEL_RENAME_WANTS_FLAGS
123 ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR
22929307 124 ZFS_AC_KERNEL_CURRENT_TIME
cae5b340 125 ZFS_AC_KERNEL_VM_NODE_STAT
c9c0d073 126
8366cd6a 127 AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
6283f55e 128 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
8366cd6a 129 ])
6283f55e
BB
130 AC_SUBST(KERNELMAKE_PARAMS)
131
132
c9c0d073
BB
133 dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
134 dnl # compiler options are added by the kernel build system.
cae5b340
AX
135 KERNELCPPFLAGS="$KERNELCPPFLAGS -std=gnu99"
136 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wno-declaration-after-statement"
8a7e1cee 137 KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_UNUSED_BUT_SET_VARIABLE"
e10b0808 138 KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_BOOL_COMPARE"
c9c0d073
BB
139 KERNELCPPFLAGS="$KERNELCPPFLAGS -DHAVE_SPL -D_KERNEL"
140 KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\""
c9c0d073 141
c9c0d073
BB
142 AC_SUBST(KERNELCPPFLAGS)
143])
144
145dnl #
146dnl # Detect name used for Module.symvers file in kernel
147dnl #
148AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
149 modpost=$LINUX/scripts/Makefile.modpost
150 AC_MSG_CHECKING([kernel file name for module symbols])
319a99a3 151 AS_IF([test "x$enable_linux_builtin" != xyes -a -f "$modpost"], [
8366cd6a 152 AS_IF([grep -q Modules.symvers $modpost], [
c9c0d073 153 LINUX_SYMBOLS=Modules.symvers
8366cd6a 154 ], [
c9c0d073 155 LINUX_SYMBOLS=Module.symvers
8366cd6a 156 ])
a60b1c0a 157
8366cd6a 158 AS_IF([test ! -f "$LINUX_OBJ/$LINUX_SYMBOLS"], [
a60b1c0a
BB
159 AC_MSG_ERROR([
160 *** Please make sure the kernel devel package for your distribution
c06d4368 161 *** is installed. If you are building with a custom kernel, make sure the
a60b1c0a
BB
162 *** kernel is configured, built, and the '--with-linux=PATH' configure
163 *** option refers to the location of the kernel source.])
8366cd6a
PS
164 ])
165 ], [
c9c0d073 166 LINUX_SYMBOLS=NONE
8366cd6a 167 ])
c9c0d073
BB
168 AC_MSG_RESULT($LINUX_SYMBOLS)
169 AC_SUBST(LINUX_SYMBOLS)
170])
171
172dnl #
173dnl # Detect the kernel to be built against
174dnl #
175AC_DEFUN([ZFS_AC_KERNEL], [
176 AC_ARG_WITH([linux],
177 AS_HELP_STRING([--with-linux=PATH],
178 [Path to kernel source]),
179 [kernelsrc="$withval"])
180
181 AC_ARG_WITH(linux-obj,
182 AS_HELP_STRING([--with-linux-obj=PATH],
183 [Path to kernel build objects]),
184 [kernelbuild="$withval"])
185
186 AC_MSG_CHECKING([kernel source directory])
8366cd6a
PS
187 AS_IF([test -z "$kernelsrc"], [
188 AS_IF([test -e "/lib/modules/$(uname -r)/source"], [
1b94c25c
BB
189 headersdir="/lib/modules/$(uname -r)/source"
190 sourcelink=$(readlink -f "$headersdir")
8366cd6a 191 ], [test -e "/lib/modules/$(uname -r)/build"], [
1b94c25c 192 headersdir="/lib/modules/$(uname -r)/build"
c9c0d073 193 sourcelink=$(readlink -f "$headersdir")
8366cd6a 194 ], [
c9c0d073 195 sourcelink=$(ls -1d /usr/src/kernels/* \
8366cd6a 196 /usr/src/linux-* \
c9c0d073 197 2>/dev/null | grep -v obj | tail -1)
8366cd6a 198 ])
c9c0d073 199
8366cd6a 200 AS_IF([test -n "$sourcelink" && test -e ${sourcelink}], [
c9c0d073 201 kernelsrc=`readlink -f ${sourcelink}`
8366cd6a 202 ], [
56a517ae 203 kernelsrc="[Not found]"
8366cd6a
PS
204 ])
205 ], [
206 AS_IF([test "$kernelsrc" = "NONE"], [
c9c0d073 207 kernsrcver=NONE
8366cd6a 208 ])
cae5b340 209 withlinux=yes
8366cd6a 210 ])
c9c0d073
BB
211
212 AC_MSG_RESULT([$kernelsrc])
56a517ae
BB
213 AS_IF([test ! -d "$kernelsrc"], [
214 AC_MSG_ERROR([
215 *** Please make sure the kernel devel package for your distribution
c06d4368 216 *** is installed and then try again. If that fails, you can specify the
56a517ae
BB
217 *** location of the kernel source with the '--with-linux=PATH' option.])
218 ])
219
c9c0d073 220 AC_MSG_CHECKING([kernel build directory])
8366cd6a 221 AS_IF([test -z "$kernelbuild"], [
cae5b340 222 AS_IF([test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"], [
1b94c25c 223 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
8366cd6a 224 ], [test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}], [
c9c0d073 225 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
8366cd6a 226 ], [test -d ${kernelsrc}-obj/${target_cpu}/default], [
70574182 227 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
8366cd6a 228 ], [test -d `dirname ${kernelsrc}`/build-${target_cpu}], [
c9c0d073 229 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
8366cd6a 230 ], [
c9c0d073 231 kernelbuild=${kernelsrc}
8366cd6a
PS
232 ])
233 ])
c9c0d073
BB
234 AC_MSG_RESULT([$kernelbuild])
235
236 AC_MSG_CHECKING([kernel source version])
237 utsrelease1=$kernelbuild/include/linux/version.h
238 utsrelease2=$kernelbuild/include/linux/utsrelease.h
239 utsrelease3=$kernelbuild/include/generated/utsrelease.h
8366cd6a 240 AS_IF([test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1], [
c9c0d073 241 utsrelease=linux/version.h
8366cd6a 242 ], [test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2], [
c9c0d073 243 utsrelease=linux/utsrelease.h
8366cd6a 244 ], [test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3], [
c9c0d073 245 utsrelease=generated/utsrelease.h
8366cd6a 246 ])
c9c0d073 247
8366cd6a 248 AS_IF([test "$utsrelease"], [
c9c0d073
BB
249 kernsrcver=`(echo "#include <$utsrelease>";
250 echo "kernsrcver=UTS_RELEASE") |
251 cpp -I $kernelbuild/include |
252 grep "^kernsrcver=" | cut -d \" -f 2`
253
8366cd6a 254 AS_IF([test -z "$kernsrcver"], [
c9c0d073
BB
255 AC_MSG_RESULT([Not found])
256 AC_MSG_ERROR([*** Cannot determine kernel version.])
8366cd6a
PS
257 ])
258 ], [
c9c0d073 259 AC_MSG_RESULT([Not found])
319a99a3
ED
260 if test "x$enable_linux_builtin" != xyes; then
261 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
262 else
263 AC_MSG_ERROR([
264 *** Cannot find UTS_RELEASE definition.
265 *** Please run 'make prepare' inside the kernel source tree.])
266 fi
8366cd6a 267 ])
c9c0d073
BB
268
269 AC_MSG_RESULT([$kernsrcver])
270
271 LINUX=${kernelsrc}
272 LINUX_OBJ=${kernelbuild}
273 LINUX_VERSION=${kernsrcver}
274
275 AC_SUBST(LINUX)
276 AC_SUBST(LINUX_OBJ)
277 AC_SUBST(LINUX_VERSION)
278
279 ZFS_AC_MODULE_SYMVERS
280])
281
c9c0d073
BB
282
283dnl #
284dnl # Detect the SPL module to be built against
285dnl #
286AC_DEFUN([ZFS_AC_SPL], [
287 AC_ARG_WITH([spl],
288 AS_HELP_STRING([--with-spl=PATH],
289 [Path to spl source]),
cae5b340
AX
290 AS_IF([test "$withval" = "yes"],
291 AC_MSG_ERROR([--with-spl=PATH requires a PATH]),
292 [splsrc="$withval"]))
c9c0d073
BB
293
294 AC_ARG_WITH([spl-obj],
295 AS_HELP_STRING([--with-spl-obj=PATH],
296 [Path to spl build objects]),
297 [splbuild="$withval"])
298
c06d4368
AX
299 AC_ARG_WITH([spl-timeout],
300 AS_HELP_STRING([--with-spl-timeout=SECS],
301 [Wait SECS for SPL header and symver file @<:@default=0@:>@]),
302 [timeout="$withval"], [timeout=0])
303
9b2af9a0
BB
304 dnl #
305 dnl # The existence of spl.release.in is used to identify a valid
306 dnl # source directory. In order of preference:
307 dnl #
308 splsrc0="/var/lib/dkms/spl/${VERSION}/build"
ea04106b
AX
309 splsrc1="/usr/local/src/spl-${VERSION}/${LINUX_VERSION}"
310 splsrc2="/usr/local/src/spl-${VERSION}"
311 splsrc3="/usr/src/spl-${VERSION}/${LINUX_VERSION}"
312 splsrc4="/usr/src/spl-${VERSION}"
313 splsrc5="../spl/"
314 splsrc6="$LINUX"
c9c0d073
BB
315
316 AC_MSG_CHECKING([spl source directory])
9b2af9a0 317 AS_IF([test -z "${splsrc}"], [
cae5b340
AX
318 [all_spl_sources="
319 ${splsrc0}
320 ${splsrc1}
321 ${splsrc2}
322 ${splsrc3}
323 ${splsrc4}
324 ${splsrc5}
325 ${splsrc6}"],
9b2af9a0
BB
326 AS_IF([ test -e "${splsrc0}/spl.release.in"], [
327 splsrc=${splsrc0}
328 ], [ test -e "${splsrc1}/spl.release.in"], [
329 splsrc=${splsrc1}
330 ], [ test -e "${splsrc2}/spl.release.in"], [
331 splsrc=${splsrc2}
332 ], [ test -e "${splsrc3}/spl.release.in"], [
333 splsrc=$(readlink -f "${splsrc3}")
334 ], [ test -e "${splsrc4}/spl.release.in" ], [
335 splsrc=${splsrc4}
ea04106b
AX
336 ], [ test -e "${splsrc5}/spl.release.in"], [
337 splsrc=$(readlink -f "${splsrc5}")
338 ], [ test -e "${splsrc6}/spl.release.in" ], [
339 splsrc=${splsrc6}
8366cd6a 340 ], [
9b2af9a0 341 splsrc="[Not found]"
8366cd6a
PS
342 ])
343 ], [
cae5b340 344 [all_spl_sources="$withval"],
8366cd6a 345 AS_IF([test "$splsrc" = "NONE"], [
c9c0d073
BB
346 splbuild=NONE
347 splsrcver=NONE
8366cd6a
PS
348 ])
349 ])
c9c0d073
BB
350
351 AC_MSG_RESULT([$splsrc])
9b2af9a0
BB
352 AS_IF([ test ! -e "$splsrc/spl.release.in"], [
353 AC_MSG_ERROR([
354 *** Please make sure the kmod spl devel package for your distribution
355 *** is installed then try again. If that fails you can specify the
cae5b340
AX
356 *** location of the spl source with the '--with-spl=PATH' option.
357 *** The spl version must match the version of ZFS you are building,
358 *** ${VERSION}. Failed to find spl.release.in in the following:
359 $all_spl_sources])
9b2af9a0
BB
360 ])
361
362 dnl #
363 dnl # The existence of the spl_config.h is used to identify a valid
364 dnl # spl object directory. In many cases the object and source
365 dnl # directory are the same, however the objects may also reside
366 dnl # is a subdirectory named after the kernel version.
367 dnl #
c06d4368
AX
368 dnl # This file is supposed to be available after DKMS finishes
369 dnl # building the SPL kernel module for the target kernel. The
370 dnl # '--with-spl-timeout' option can be passed to pause here,
371 dnl # waiting for the file to appear from a concurrently building
372 dnl # SPL package.
373 dnl #
c9c0d073 374 AC_MSG_CHECKING([spl build directory])
cae5b340
AX
375
376 all_spl_config_locs="${splsrc}/${LINUX_VERSION}
377 ${splsrc}"
378
c06d4368
AX
379 while true; do
380 AS_IF([test -z "$splbuild"], [
381 AS_IF([ test -e "${splsrc}/${LINUX_VERSION}/spl_config.h" ], [
382 splbuild="${splsrc}/${LINUX_VERSION}"
383 ], [ test -e "${splsrc}/spl_config.h" ], [
384 splbuild="${splsrc}"
e10b0808
AX
385 ], [ find -L "${splsrc}" -name spl_config.h 2> /dev/null | grep -wq spl_config.h ], [
386 splbuild=$(find -L "${splsrc}" -name spl_config.h | sed 's,/spl_config.h,,')
c06d4368
AX
387 ], [
388 splbuild="[Not found]"
389 ])
390 ])
391 AS_IF([test -e "$splbuild/spl_config.h" -o $timeout -le 0], [
392 break;
9b2af9a0 393 ], [
c06d4368
AX
394 sleep 1
395 timeout=$((timeout-1))
9b2af9a0 396 ])
c06d4368 397 done
9b2af9a0 398
c9c0d073 399 AC_MSG_RESULT([$splbuild])
9b2af9a0
BB
400 AS_IF([ ! test -e "$splbuild/spl_config.h"], [
401 AC_MSG_ERROR([
402 *** Please make sure the kmod spl devel <kernel> package for your
403 *** distribution is installed then try again. If that fails you
404 *** can specify the location of the spl objects with the
cae5b340
AX
405 *** '--with-spl-obj=PATH' option. Failed to find spl_config.h in
406 *** any of the following:
407 $all_spl_config_locs])
9b2af9a0 408 ])
c9c0d073
BB
409
410 AC_MSG_CHECKING([spl source version])
8366cd6a
PS
411 AS_IF([test -r $splbuild/spl_config.h &&
412 fgrep -q SPL_META_VERSION $splbuild/spl_config.h], [
c9c0d073
BB
413
414 splsrcver=`(echo "#include <spl_config.h>";
b40a77ae 415 echo "splsrcver=SPL_META_VERSION-SPL_META_RELEASE") |
5e612145 416 cpp -I $splbuild |
b40a77ae 417 grep "^splsrcver=" | tr -d \" | cut -d= -f2`
8366cd6a 418 ])
c9c0d073 419
8366cd6a 420 AS_IF([test -z "$splsrcver"], [
c9c0d073
BB
421 AC_MSG_RESULT([Not found])
422 AC_MSG_ERROR([
2984e0bb
PS
423 *** Cannot determine the version of the spl source.
424 *** Please prepare the spl source before running this script])
8366cd6a 425 ])
c9c0d073
BB
426
427 AC_MSG_RESULT([$splsrcver])
428
429 SPL=${splsrc}
430 SPL_OBJ=${splbuild}
431 SPL_VERSION=${splsrcver}
432
433 AC_SUBST(SPL)
434 AC_SUBST(SPL_OBJ)
435 AC_SUBST(SPL_VERSION)
436
c06d4368
AX
437 dnl #
438 dnl # Detect the name used for the SPL Module.symvers file. If one
439 dnl # does not exist this is likely because the SPL has been configured
440 dnl # but not built. The '--with-spl-timeout' option can be passed
441 dnl # to pause here, waiting for the file to appear from a concurrently
442 dnl # building SPL package. If the file does not appear in time, a good
443 dnl # guess is made as to what this file will be named based on what it
444 dnl # is named in the kernel build products. This file will first be
445 dnl # used at link time so if the guess is wrong the build will fail
446 dnl # then. This unfortunately means the ZFS package does not contain a
447 dnl # reliable mechanism to detect symbols exported by the SPL at
448 dnl # configure time.
449 dnl #
450 AC_MSG_CHECKING([spl file name for module symbols])
451 SPL_SYMBOLS=NONE
452
453 while true; do
454 AS_IF([test -r $SPL_OBJ/Module.symvers], [
455 SPL_SYMBOLS=Module.symvers
456 ], [test -r $SPL_OBJ/Modules.symvers], [
457 SPL_SYMBOLS=Modules.symvers
458 ], [test -r $SPL_OBJ/module/Module.symvers], [
459 SPL_SYMBOLS=Module.symvers
460 ], [test -r $SPL_OBJ/module/Modules.symvers], [
461 SPL_SYMBOLS=Modules.symvers
462 ])
463
464 AS_IF([test $SPL_SYMBOLS != NONE -o $timeout -le 0], [
465 break;
466 ], [
467 sleep 1
468 timeout=$((timeout-1))
469 ])
470 done
471
472 AS_IF([test "$SPL_SYMBOLS" = NONE], [
473 SPL_SYMBOLS=$LINUX_SYMBOLS
474 ])
475
476 AC_MSG_RESULT([$SPL_SYMBOLS])
477 AC_SUBST(SPL_SYMBOLS)
c9c0d073
BB
478])
479
cae5b340
AX
480dnl #
481dnl # Detect the QAT module to be built against
482dnl # QAT provides hardware acceleration for data compression:
483dnl # https://01.org/intel-quickassist-technology
484dnl # * Download and install QAT driver from the above link
485dnl # * Start QAT driver in your system:
486dnl # service qat_service start
487dnl # * Enable QAT in ZFS, e.g.:
488dnl # ./configure --with-qat=<qat-driver-path>/QAT1.6
489dnl # make
490dnl # * Set GZIP compression in ZFS dataset:
491dnl # zfs set compression = gzip <dataset>
492dnl # Then the data written to this ZFS pool is compressed
493dnl # by QAT accelerator automatically, and de-compressed by
494dnl # QAT when read from the pool.
495dnl # * Get QAT hardware statistics by:
496dnl # cat /proc/icp_dh895xcc_dev/qat
497dnl # * To disable QAT:
498dnl # insmod zfs.ko zfs_qat_disable=1
499dnl #
500AC_DEFUN([ZFS_AC_QAT], [
501 AC_ARG_WITH([qat],
502 AS_HELP_STRING([--with-qat=PATH],
503 [Path to qat source]),
504 AS_IF([test "$withval" = "yes"],
505 AC_MSG_ERROR([--with-qat=PATH requires a PATH]),
506 [qatsrc="$withval"]))
507
508 AC_ARG_WITH([qat-obj],
509 AS_HELP_STRING([--with-qat-obj=PATH],
510 [Path to qat build objects]),
511 [qatbuild="$withval"])
512
513 AS_IF([test ! -z "${qatsrc}"], [
514 AC_MSG_CHECKING([qat source directory])
515 AC_MSG_RESULT([$qatsrc])
516 QAT_SRC="${qatsrc}/quickassist"
517 AS_IF([ test ! -e "$QAT_SRC/include/cpa.h"], [
518 AC_MSG_ERROR([
519 *** Please make sure the qat driver package is installed
520 *** and specify the location of the qat source with the
521 *** '--with-qat=PATH' option then try again. Failed to
522 *** find cpa.h in:
523 ${QAT_SRC}/include])
524 ])
525 ])
526
527 AS_IF([test ! -z "${qatsrc}"], [
528 AC_MSG_CHECKING([qat build directory])
529 AS_IF([test -z "$qatbuild"], [
530 qatbuild="${qatsrc}/build"
531 ])
532
533 AC_MSG_RESULT([$qatbuild])
534 QAT_OBJ=${qatbuild}
535 AS_IF([ ! test -e "$QAT_OBJ/icp_qa_al.ko"], [
536 AC_MSG_ERROR([
537 *** Please make sure the qat driver is installed then try again.
538 *** Failed to find icp_qa_al.ko in:
539 $QAT_OBJ])
540 ])
541
542 AC_SUBST(QAT_SRC)
543 AC_SUBST(QAT_OBJ)
544
545 AC_DEFINE(HAVE_QAT, 1,
546 [qat is enabled and existed])
547 ])
548
549 dnl #
550 dnl # Detect the name used for the QAT Module.symvers file.
551 dnl #
552 AS_IF([test ! -z "${qatsrc}"], [
553 AC_MSG_CHECKING([qat file for module symbols])
554 QAT_SYMBOLS=$QAT_SRC/lookaside/access_layer/src/Module.symvers
555
556 AS_IF([test -r $QAT_SYMBOLS], [
557 AC_MSG_RESULT([$QAT_SYMBOLS])
558 AC_SUBST(QAT_SYMBOLS)
559 ],[
560 AC_MSG_ERROR([
561 *** Please make sure the qat driver is installed then try again.
562 *** Failed to find Module.symvers in:
563 $QAT_SYMBOLS])
564 ])
565 ])
566 ])
567])
568
319a99a3
ED
569dnl #
570dnl # Basic toolchain sanity check.
571dnl #
ea04106b
AX
572AC_DEFUN([ZFS_AC_TEST_MODULE], [
573 AC_MSG_CHECKING([whether modules can be built])
319a99a3
ED
574 ZFS_LINUX_TRY_COMPILE([],[],[
575 AC_MSG_RESULT([yes])
576 ],[
577 AC_MSG_RESULT([no])
578 if test "x$enable_linux_builtin" != xyes; then
579 AC_MSG_ERROR([*** Unable to build an empty module.])
580 else
581 AC_MSG_ERROR([
582 *** Unable to build an empty module.
583 *** Please run 'make scripts' inside the kernel source tree.])
584 fi
585 ])
586])
587
15805c77
BB
588dnl #
589dnl # Certain kernel build options are not supported. These must be
590dnl # detected at configure time and cause a build failure. Otherwise
591dnl # modules may be successfully built that behave incorrectly.
592dnl #
e5b85622 593AC_DEFUN([ZFS_AC_KERNEL_CONFIG], [
94a40997
AX
594 AS_IF([test "x$cross_compiling" != xyes], [
595 AC_RUN_IFELSE([
596 AC_LANG_PROGRAM([
597 #include "$LINUX/include/linux/license.h"
598 ], [
599 return !license_is_gpl_compatible("$ZFS_META_LICENSE");
600 ])
601 ], [
602 AC_DEFINE([ZFS_IS_GPL_COMPATIBLE], [1],
603 [Define to 1 if GPL-only symbols can be used])
ea04106b 604 ], [
ea04106b 605 ])
e5b85622
BB
606 ])
607
68d83c55 608 ZFS_AC_KERNEL_CONFIG_THREAD_SIZE
e5b85622
BB
609 ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC
610])
611
68d83c55
AX
612dnl #
613dnl # Check configured THREAD_SIZE
614dnl #
615dnl # The stack size will vary by architecture, but as of Linux 3.15 on x86_64
616dnl # the default thread stack size was increased to 16K from 8K. Therefore,
617dnl # on newer kernels and some architectures stack usage optimizations can be
618dnl # conditionally applied to improve performance without negatively impacting
619dnl # stability.
620dnl #
621AC_DEFUN([ZFS_AC_KERNEL_CONFIG_THREAD_SIZE], [
622 AC_MSG_CHECKING([whether kernel was built with 16K or larger stacks])
623 ZFS_LINUX_TRY_COMPILE([
624 #include <linux/module.h>
625 ],[
626 #if (THREAD_SIZE < 16384)
627 #error "THREAD_SIZE is less than 16K"
628 #endif
629 ],[
630 AC_MSG_RESULT([yes])
631 AC_DEFINE(HAVE_LARGE_STACKS, 1, [kernel has large stacks])
632 ],[
633 AC_MSG_RESULT([no])
634 ])
635])
636
e5b85622
BB
637dnl #
638dnl # Check CONFIG_DEBUG_LOCK_ALLOC
639dnl #
640dnl # This is typically only set for debug kernels because it comes with
641dnl # a performance penalty. However, when it is set it maps the non-GPL
642dnl # symbol mutex_lock() to the GPL-only mutex_lock_nested() symbol.
643dnl # This will cause a failure at link time which we'd rather know about
644dnl # at compile time.
645dnl #
646dnl # Since we plan to pursue making mutex_lock_nested() a non-GPL symbol
647dnl # with the upstream community we add a check to detect this case.
648dnl #
649AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC], [
650
651 ZFS_LINUX_CONFIG([DEBUG_LOCK_ALLOC], [
652 AC_MSG_CHECKING([whether mutex_lock() is GPL-only])
653 tmp_flags="$EXTRA_KCFLAGS"
654 ZFS_LINUX_TRY_COMPILE([
655 #include <linux/module.h>
656 #include <linux/mutex.h>
657
658 MODULE_LICENSE("$ZFS_META_LICENSE");
659 ],[
660 struct mutex lock;
661
662 mutex_init(&lock);
663 mutex_lock(&lock);
664 mutex_unlock(&lock);
665 ],[
666 AC_MSG_RESULT(no)
667 ],[
668 AC_MSG_RESULT(yes)
669 AC_MSG_ERROR([
670 *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible
cac1f230
NB
671 *** with the CDDL license and will prevent the module linking stage
672 *** from succeeding. You must rebuild your kernel without this
673 *** option enabled.])
e5b85622
BB
674 ])
675 EXTRA_KCFLAGS="$tmp_flags"
676 ], [])
c9c0d073
BB
677])
678
679dnl #
ea04106b
AX
680dnl # ZFS_LINUX_CONFTEST_H
681dnl #
682AC_DEFUN([ZFS_LINUX_CONFTEST_H], [
683cat - <<_ACEOF >conftest.h
684$1
685_ACEOF
686])
687
c9c0d073 688dnl #
ea04106b
AX
689dnl # ZFS_LINUX_CONFTEST_C
690dnl #
691AC_DEFUN([ZFS_LINUX_CONFTEST_C], [
c9c0d073
BB
692cat confdefs.h - <<_ACEOF >conftest.c
693$1
694_ACEOF
695])
696
697dnl #
698dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY])
699dnl #
700m4_define([ZFS_LANG_PROGRAM], [
701$1
702int
703main (void)
704{
705dnl Do *not* indent the following line: there may be CPP directives.
706dnl Don't move the `;' right after for the same reason.
707$2
708 ;
709 return 0;
710}
711])
712
713dnl #
714dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
715dnl #
716AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
ea04106b
AX
717 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST_C([$1])])
718 m4_ifvaln([$6], [ZFS_LINUX_CONFTEST_H([$6])], [ZFS_LINUX_CONFTEST_H([])])
fc88a6dd 719 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
c9c0d073 720 echo "obj-m := conftest.o" >build/Makefile
fc88a6dd
ED
721 modpost_flag=''
722 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
c9c0d073 723 AS_IF(
ea04106b 724 [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])],
c9c0d073
BB
725 [$4],
726 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
727 )
728 rm -Rf build
729])
730
731dnl #
732dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE
733dnl #
734AC_DEFUN([ZFS_LINUX_TRY_COMPILE],
735 [ZFS_LINUX_COMPILE_IFELSE(
736 [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
737 [modules],
738 [test -s build/conftest.o],
739 [$3], [$4])
740])
741
742dnl #
743dnl # ZFS_LINUX_CONFIG
744dnl #
745AC_DEFUN([ZFS_LINUX_CONFIG],
68d83c55 746 [AC_MSG_CHECKING([whether kernel was built with CONFIG_$1])
c9c0d073 747 ZFS_LINUX_TRY_COMPILE([
0da78696 748 #include <linux/module.h>
c9c0d073
BB
749 ],[
750 #ifndef CONFIG_$1
751 #error CONFIG_$1 not #defined
752 #endif
753 ],[
754 AC_MSG_RESULT([yes])
755 $2
756 ],[
757 AC_MSG_RESULT([no])
758 $3
759 ])
760])
761
762dnl #
763dnl # ZFS_CHECK_SYMBOL_EXPORT
764dnl # check symbol exported or not
765dnl #
70574182 766AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
c9c0d073
BB
767 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
768 $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
769 rc=$?
70574182 770 if test $rc -ne 0; then
c9c0d073
BB
771 export=0
772 for file in $2; do
70574182
ED
773 grep -q -E "EXPORT_SYMBOL.*($1)" \
774 "$LINUX/$file" 2>/dev/null
c9c0d073 775 rc=$?
70574182 776 if test $rc -eq 0; then
8366cd6a
PS
777 export=1
778 break;
70574182 779 fi
c9c0d073 780 done
70574182 781 if test $export -eq 0; then :
c9c0d073 782 $4
70574182 783 else :
c9c0d073 784 $3
70574182
ED
785 fi
786 else :
c9c0d073 787 $3
70574182
ED
788 fi
789])
790
791dnl #
792dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL
793dnl # like ZFS_LINUX_TRY_COMPILE, except ZFS_CHECK_SYMBOL_EXPORT
794dnl # is called if not compiling for builtin
795dnl #
796AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [
797 ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
798 if test $rc -ne 0; then :
799 $6
800 else
801 if test "x$enable_linux_builtin" != xyes; then
802 ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
803 fi
804 if test $rc -ne 0; then :
805 $6
806 else :
807 $5
808 fi
809 fi
c9c0d073 810])
ea04106b
AX
811
812dnl #
813dnl # ZFS_LINUX_TRY_COMPILE_HEADER
814dnl # like ZFS_LINUX_TRY_COMPILE, except the contents conftest.h are
815dnl # provided via the fifth parameter
816dnl #
817AC_DEFUN([ZFS_LINUX_TRY_COMPILE_HEADER],
818 [ZFS_LINUX_COMPILE_IFELSE(
819 [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
820 [modules],
821 [test -s build/conftest.o],
822 [$3], [$4], [$5])
823])