]> git.proxmox.com Git - mirror_zfs.git/blob - config/kernel.m4
Linux 6.8 compat: implement strlcpy fallback
[mirror_zfs.git] / config / kernel.m4
1 dnl #
2 dnl # Default ZFS kernel configuration
3 dnl #
4 AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
5 AM_COND_IF([BUILD_LINUX], [
6 dnl # Setup the kernel build environment.
7 ZFS_AC_KERNEL
8 ZFS_AC_QAT
9
10 dnl # Sanity checks for module building and CONFIG_* defines
11 ZFS_AC_KERNEL_CONFIG_DEFINED
12 ZFS_AC_MODULE_SYMVERS
13
14 dnl # Sequential ZFS_LINUX_TRY_COMPILE tests
15 ZFS_AC_KERNEL_FPU_HEADER
16 ZFS_AC_KERNEL_OBJTOOL_HEADER
17 ZFS_AC_KERNEL_WAIT_QUEUE_ENTRY_T
18 ZFS_AC_KERNEL_MISC_MINOR
19 ZFS_AC_KERNEL_DECLARE_EVENT_CLASS
20
21 dnl # Parallel ZFS_LINUX_TEST_SRC / ZFS_LINUX_TEST_RESULT tests
22 ZFS_AC_KERNEL_TEST_SRC
23 ZFS_AC_KERNEL_TEST_RESULT
24
25 AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
26 KERNEL_MAKE="$KERNEL_MAKE O=$LINUX_OBJ"
27 ])
28
29 AC_SUBST(KERNEL_MAKE)
30 ])
31 ])
32
33 dnl #
34 dnl # Generate and compile all of the kernel API test cases to determine
35 dnl # which interfaces are available. By invoking the kernel build system
36 dnl # only once the compilation can be done in parallel significantly
37 dnl # speeding up the process.
38 dnl #
39 AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
40 ZFS_AC_KERNEL_SRC_OBJTOOL
41 ZFS_AC_KERNEL_SRC_GLOBAL_PAGE_STATE
42 ZFS_AC_KERNEL_SRC_ACCESS_OK_TYPE
43 ZFS_AC_KERNEL_SRC_PDE_DATA
44 ZFS_AC_KERNEL_SRC_FALLOCATE
45 ZFS_AC_KERNEL_SRC_FADVISE
46 ZFS_AC_KERNEL_SRC_GENERIC_FADVISE
47 ZFS_AC_KERNEL_SRC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
48 ZFS_AC_KERNEL_SRC_RWSEM
49 ZFS_AC_KERNEL_SRC_SCHED
50 ZFS_AC_KERNEL_SRC_USLEEP_RANGE
51 ZFS_AC_KERNEL_SRC_KMEM_CACHE
52 ZFS_AC_KERNEL_SRC_KVMALLOC
53 ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL
54 ZFS_AC_KERNEL_SRC_WAIT
55 ZFS_AC_KERNEL_SRC_INODE_TIMES
56 ZFS_AC_KERNEL_SRC_INODE_LOCK
57 ZFS_AC_KERNEL_SRC_GROUP_INFO_GID
58 ZFS_AC_KERNEL_SRC_RW
59 ZFS_AC_KERNEL_SRC_TIMER_SETUP
60 ZFS_AC_KERNEL_SRC_SUPER_USER_NS
61 ZFS_AC_KERNEL_SRC_PROC_OPERATIONS
62 ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS
63 ZFS_AC_KERNEL_SRC_BIO
64 ZFS_AC_KERNEL_SRC_BLKDEV
65 ZFS_AC_KERNEL_SRC_BLK_QUEUE
66 ZFS_AC_KERNEL_SRC_GENHD_FLAGS
67 ZFS_AC_KERNEL_SRC_REVALIDATE_DISK
68 ZFS_AC_KERNEL_SRC_GET_DISK_RO
69 ZFS_AC_KERNEL_SRC_GENERIC_READLINK_GLOBAL
70 ZFS_AC_KERNEL_SRC_DISCARD_GRANULARITY
71 ZFS_AC_KERNEL_SRC_INODE_OWNER_OR_CAPABLE
72 ZFS_AC_KERNEL_SRC_XATTR
73 ZFS_AC_KERNEL_SRC_ACL
74 ZFS_AC_KERNEL_SRC_INODE_SETATTR
75 ZFS_AC_KERNEL_SRC_INODE_GETATTR
76 ZFS_AC_KERNEL_SRC_INODE_SET_FLAGS
77 ZFS_AC_KERNEL_SRC_INODE_SET_IVERSION
78 ZFS_AC_KERNEL_SRC_SHOW_OPTIONS
79 ZFS_AC_KERNEL_SRC_FILE_INODE
80 ZFS_AC_KERNEL_SRC_FILE_DENTRY
81 ZFS_AC_KERNEL_SRC_FSYNC
82 ZFS_AC_KERNEL_SRC_AIO_FSYNC
83 ZFS_AC_KERNEL_SRC_EVICT_INODE
84 ZFS_AC_KERNEL_SRC_DIRTY_INODE
85 ZFS_AC_KERNEL_SRC_SHRINKER
86 ZFS_AC_KERNEL_SRC_MKDIR
87 ZFS_AC_KERNEL_SRC_LOOKUP_FLAGS
88 ZFS_AC_KERNEL_SRC_CREATE
89 ZFS_AC_KERNEL_SRC_PERMISSION
90 ZFS_AC_KERNEL_SRC_GET_LINK
91 ZFS_AC_KERNEL_SRC_PUT_LINK
92 ZFS_AC_KERNEL_SRC_TMPFILE
93 ZFS_AC_KERNEL_SRC_AUTOMOUNT
94 ZFS_AC_KERNEL_SRC_ENCODE_FH_WITH_INODE
95 ZFS_AC_KERNEL_SRC_COMMIT_METADATA
96 ZFS_AC_KERNEL_SRC_CLEAR_INODE
97 ZFS_AC_KERNEL_SRC_SETATTR_PREPARE
98 ZFS_AC_KERNEL_SRC_INSERT_INODE_LOCKED
99 ZFS_AC_KERNEL_SRC_DENTRY
100 ZFS_AC_KERNEL_SRC_DENTRY_ALIAS_D_U
101 ZFS_AC_KERNEL_SRC_TRUNCATE_SETSIZE
102 ZFS_AC_KERNEL_SRC_SECURITY_INODE
103 ZFS_AC_KERNEL_SRC_FST_MOUNT
104 ZFS_AC_KERNEL_SRC_BDI
105 ZFS_AC_KERNEL_SRC_SET_NLINK
106 ZFS_AC_KERNEL_SRC_SGET
107 ZFS_AC_KERNEL_SRC_LSEEK_EXECUTE
108 ZFS_AC_KERNEL_SRC_VFS_FILEMAP_DIRTY_FOLIO
109 ZFS_AC_KERNEL_SRC_VFS_READ_FOLIO
110 ZFS_AC_KERNEL_SRC_VFS_GETATTR
111 ZFS_AC_KERNEL_SRC_VFS_FSYNC_2ARGS
112 ZFS_AC_KERNEL_SRC_VFS_ITERATE
113 ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO
114 ZFS_AC_KERNEL_SRC_VFS_READPAGES
115 ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS
116 ZFS_AC_KERNEL_SRC_VFS_RW_ITERATE
117 ZFS_AC_KERNEL_SRC_VFS_GENERIC_WRITE_CHECKS
118 ZFS_AC_KERNEL_SRC_VFS_IOV_ITER
119 ZFS_AC_KERNEL_SRC_VFS_COPY_FILE_RANGE
120 ZFS_AC_KERNEL_SRC_VFS_GENERIC_COPY_FILE_RANGE
121 ZFS_AC_KERNEL_SRC_VFS_REMAP_FILE_RANGE
122 ZFS_AC_KERNEL_SRC_VFS_CLONE_FILE_RANGE
123 ZFS_AC_KERNEL_SRC_VFS_DEDUPE_FILE_RANGE
124 ZFS_AC_KERNEL_SRC_VFS_FILE_OPERATIONS_EXTEND
125 ZFS_AC_KERNEL_SRC_KMAP_ATOMIC_ARGS
126 ZFS_AC_KERNEL_SRC_FOLLOW_DOWN_ONE
127 ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN
128 ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT
129 ZFS_AC_KERNEL_SRC_FPU
130 ZFS_AC_KERNEL_SRC_FMODE_T
131 ZFS_AC_KERNEL_SRC_KUIDGID_T
132 ZFS_AC_KERNEL_SRC_KUID_HELPERS
133 ZFS_AC_KERNEL_SRC_RENAME
134 ZFS_AC_KERNEL_SRC_CURRENT_TIME
135 ZFS_AC_KERNEL_SRC_USERNS_CAPABILITIES
136 ZFS_AC_KERNEL_SRC_IN_COMPAT_SYSCALL
137 ZFS_AC_KERNEL_SRC_KTIME
138 ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC
139 ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES
140 ZFS_AC_KERNEL_SRC_KSTRTOUL
141 ZFS_AC_KERNEL_SRC_PERCPU
142 ZFS_AC_KERNEL_SRC_CPU_HOTPLUG
143 ZFS_AC_KERNEL_SRC_GENERIC_FILLATTR
144 ZFS_AC_KERNEL_SRC_MKNOD
145 ZFS_AC_KERNEL_SRC_SYMLINK
146 ZFS_AC_KERNEL_SRC_BIO_MAX_SEGS
147 ZFS_AC_KERNEL_SRC_SIGNAL_STOP
148 ZFS_AC_KERNEL_SRC_SIGINFO
149 ZFS_AC_KERNEL_SRC_SYSFS
150 ZFS_AC_KERNEL_SRC_SET_SPECIAL_STATE
151 ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG
152 ZFS_AC_KERNEL_SRC_STRLCPY
153 ZFS_AC_KERNEL_SRC_STRSCPY
154 ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT
155 ZFS_AC_KERNEL_SRC_ADD_DISK
156 ZFS_AC_KERNEL_SRC_KTHREAD
157 ZFS_AC_KERNEL_SRC_ZERO_PAGE
158 ZFS_AC_KERNEL_SRC___COPY_FROM_USER_INATOMIC
159 ZFS_AC_KERNEL_SRC_USER_NS_COMMON_INUM
160 ZFS_AC_KERNEL_SRC_IDMAP_MNT_API
161 ZFS_AC_KERNEL_SRC_IATTR_VFSID
162 ZFS_AC_KERNEL_SRC_FILEMAP
163 ZFS_AC_KERNEL_SRC_WRITEPAGE_T
164 ZFS_AC_KERNEL_SRC_RECLAIMED
165 ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_TABLE
166 ZFS_AC_KERNEL_SRC_COPY_SPLICE_READ
167 ZFS_AC_KERNEL_SRC_SYNC_BDEV
168 case "$host_cpu" in
169 powerpc*)
170 ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE
171 ZFS_AC_KERNEL_SRC_FLUSH_DCACHE_PAGE
172 ;;
173 riscv*)
174 ZFS_AC_KERNEL_SRC_FLUSH_DCACHE_PAGE
175 ;;
176 esac
177
178 AC_MSG_CHECKING([for available kernel interfaces])
179 ZFS_LINUX_TEST_COMPILE_ALL([kabi])
180 AC_MSG_RESULT([done])
181 ])
182
183 dnl #
184 dnl # Check results of kernel interface tests.
185 dnl #
186 AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
187 ZFS_AC_KERNEL_ACCESS_OK_TYPE
188 ZFS_AC_KERNEL_GLOBAL_PAGE_STATE
189 ZFS_AC_KERNEL_OBJTOOL
190 ZFS_AC_KERNEL_PDE_DATA
191 ZFS_AC_KERNEL_FALLOCATE
192 ZFS_AC_KERNEL_FADVISE
193 ZFS_AC_KERNEL_GENERIC_FADVISE
194 ZFS_AC_KERNEL_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
195 ZFS_AC_KERNEL_RWSEM
196 ZFS_AC_KERNEL_SCHED
197 ZFS_AC_KERNEL_USLEEP_RANGE
198 ZFS_AC_KERNEL_KMEM_CACHE
199 ZFS_AC_KERNEL_KVMALLOC
200 ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL
201 ZFS_AC_KERNEL_WAIT
202 ZFS_AC_KERNEL_INODE_TIMES
203 ZFS_AC_KERNEL_INODE_LOCK
204 ZFS_AC_KERNEL_GROUP_INFO_GID
205 ZFS_AC_KERNEL_RW
206 ZFS_AC_KERNEL_TIMER_SETUP
207 ZFS_AC_KERNEL_SUPER_USER_NS
208 ZFS_AC_KERNEL_PROC_OPERATIONS
209 ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS
210 ZFS_AC_KERNEL_BIO
211 ZFS_AC_KERNEL_BLKDEV
212 ZFS_AC_KERNEL_BLK_QUEUE
213 ZFS_AC_KERNEL_GENHD_FLAGS
214 ZFS_AC_KERNEL_REVALIDATE_DISK
215 ZFS_AC_KERNEL_GET_DISK_RO
216 ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL
217 ZFS_AC_KERNEL_DISCARD_GRANULARITY
218 ZFS_AC_KERNEL_INODE_OWNER_OR_CAPABLE
219 ZFS_AC_KERNEL_XATTR
220 ZFS_AC_KERNEL_ACL
221 ZFS_AC_KERNEL_INODE_SETATTR
222 ZFS_AC_KERNEL_INODE_GETATTR
223 ZFS_AC_KERNEL_INODE_SET_FLAGS
224 ZFS_AC_KERNEL_INODE_SET_IVERSION
225 ZFS_AC_KERNEL_SHOW_OPTIONS
226 ZFS_AC_KERNEL_FILE_INODE
227 ZFS_AC_KERNEL_FILE_DENTRY
228 ZFS_AC_KERNEL_FSYNC
229 ZFS_AC_KERNEL_AIO_FSYNC
230 ZFS_AC_KERNEL_EVICT_INODE
231 ZFS_AC_KERNEL_DIRTY_INODE
232 ZFS_AC_KERNEL_SHRINKER
233 ZFS_AC_KERNEL_MKDIR
234 ZFS_AC_KERNEL_LOOKUP_FLAGS
235 ZFS_AC_KERNEL_CREATE
236 ZFS_AC_KERNEL_PERMISSION
237 ZFS_AC_KERNEL_GET_LINK
238 ZFS_AC_KERNEL_PUT_LINK
239 ZFS_AC_KERNEL_TMPFILE
240 ZFS_AC_KERNEL_AUTOMOUNT
241 ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
242 ZFS_AC_KERNEL_COMMIT_METADATA
243 ZFS_AC_KERNEL_CLEAR_INODE
244 ZFS_AC_KERNEL_SETATTR_PREPARE
245 ZFS_AC_KERNEL_INSERT_INODE_LOCKED
246 ZFS_AC_KERNEL_DENTRY
247 ZFS_AC_KERNEL_DENTRY_ALIAS_D_U
248 ZFS_AC_KERNEL_TRUNCATE_SETSIZE
249 ZFS_AC_KERNEL_SECURITY_INODE
250 ZFS_AC_KERNEL_FST_MOUNT
251 ZFS_AC_KERNEL_BDI
252 ZFS_AC_KERNEL_SET_NLINK
253 ZFS_AC_KERNEL_SGET
254 ZFS_AC_KERNEL_LSEEK_EXECUTE
255 ZFS_AC_KERNEL_VFS_FILEMAP_DIRTY_FOLIO
256 ZFS_AC_KERNEL_VFS_READ_FOLIO
257 ZFS_AC_KERNEL_VFS_GETATTR
258 ZFS_AC_KERNEL_VFS_FSYNC_2ARGS
259 ZFS_AC_KERNEL_VFS_ITERATE
260 ZFS_AC_KERNEL_VFS_DIRECT_IO
261 ZFS_AC_KERNEL_VFS_READPAGES
262 ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS
263 ZFS_AC_KERNEL_VFS_RW_ITERATE
264 ZFS_AC_KERNEL_VFS_GENERIC_WRITE_CHECKS
265 ZFS_AC_KERNEL_VFS_IOV_ITER
266 ZFS_AC_KERNEL_VFS_COPY_FILE_RANGE
267 ZFS_AC_KERNEL_VFS_GENERIC_COPY_FILE_RANGE
268 ZFS_AC_KERNEL_VFS_REMAP_FILE_RANGE
269 ZFS_AC_KERNEL_VFS_CLONE_FILE_RANGE
270 ZFS_AC_KERNEL_VFS_DEDUPE_FILE_RANGE
271 ZFS_AC_KERNEL_VFS_FILE_OPERATIONS_EXTEND
272 ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
273 ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
274 ZFS_AC_KERNEL_MAKE_REQUEST_FN
275 ZFS_AC_KERNEL_GENERIC_IO_ACCT
276 ZFS_AC_KERNEL_FPU
277 ZFS_AC_KERNEL_FMODE_T
278 ZFS_AC_KERNEL_KUIDGID_T
279 ZFS_AC_KERNEL_KUID_HELPERS
280 ZFS_AC_KERNEL_RENAME
281 ZFS_AC_KERNEL_CURRENT_TIME
282 ZFS_AC_KERNEL_USERNS_CAPABILITIES
283 ZFS_AC_KERNEL_IN_COMPAT_SYSCALL
284 ZFS_AC_KERNEL_KTIME
285 ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC
286 ZFS_AC_KERNEL_TOTALHIGH_PAGES
287 ZFS_AC_KERNEL_KSTRTOUL
288 ZFS_AC_KERNEL_PERCPU
289 ZFS_AC_KERNEL_CPU_HOTPLUG
290 ZFS_AC_KERNEL_GENERIC_FILLATTR
291 ZFS_AC_KERNEL_MKNOD
292 ZFS_AC_KERNEL_SYMLINK
293 ZFS_AC_KERNEL_BIO_MAX_SEGS
294 ZFS_AC_KERNEL_SIGNAL_STOP
295 ZFS_AC_KERNEL_SIGINFO
296 ZFS_AC_KERNEL_SYSFS
297 ZFS_AC_KERNEL_SET_SPECIAL_STATE
298 ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG
299 ZFS_AC_KERNEL_STRLCPY
300 ZFS_AC_KERNEL_STRSCPY
301 ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT
302 ZFS_AC_KERNEL_ADD_DISK
303 ZFS_AC_KERNEL_KTHREAD
304 ZFS_AC_KERNEL_ZERO_PAGE
305 ZFS_AC_KERNEL___COPY_FROM_USER_INATOMIC
306 ZFS_AC_KERNEL_USER_NS_COMMON_INUM
307 ZFS_AC_KERNEL_IDMAP_MNT_API
308 ZFS_AC_KERNEL_IATTR_VFSID
309 ZFS_AC_KERNEL_FILEMAP
310 ZFS_AC_KERNEL_WRITEPAGE_T
311 ZFS_AC_KERNEL_RECLAIMED
312 ZFS_AC_KERNEL_REGISTER_SYSCTL_TABLE
313 ZFS_AC_KERNEL_COPY_SPLICE_READ
314 ZFS_AC_KERNEL_SYNC_BDEV
315 case "$host_cpu" in
316 powerpc*)
317 ZFS_AC_KERNEL_CPU_HAS_FEATURE
318 ZFS_AC_KERNEL_FLUSH_DCACHE_PAGE
319 ;;
320 riscv*)
321 ZFS_AC_KERNEL_FLUSH_DCACHE_PAGE
322 ;;
323 esac
324 ])
325
326 dnl #
327 dnl # Detect name used for Module.symvers file in kernel
328 dnl #
329 AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
330 modpost=$LINUX/scripts/Makefile.modpost
331 AC_MSG_CHECKING([kernel file name for module symbols])
332 AS_IF([test "x$enable_linux_builtin" != xyes -a -f "$modpost"], [
333 AS_IF([grep -q Modules.symvers $modpost], [
334 LINUX_SYMBOLS=Modules.symvers
335 ], [
336 LINUX_SYMBOLS=Module.symvers
337 ])
338
339 AS_IF([test ! -f "$LINUX_OBJ/$LINUX_SYMBOLS"], [
340 AC_MSG_ERROR([
341 *** Please make sure the kernel devel package for your distribution
342 *** is installed. If you are building with a custom kernel, make sure
343 *** the kernel is configured, built, and the '--with-linux=PATH'
344 *** configure option refers to the location of the kernel source.
345 ])
346 ])
347 ], [
348 LINUX_SYMBOLS=NONE
349 ])
350 AC_MSG_RESULT($LINUX_SYMBOLS)
351 AC_SUBST(LINUX_SYMBOLS)
352 ])
353
354 dnl #
355 dnl # Detect the kernel to be built against
356 dnl #
357 dnl # Most modern Linux distributions have separate locations for bare
358 dnl # source (source) and prebuilt (build) files. Additionally, there are
359 dnl # `source` and `build` symlinks in `/lib/modules/$(KERNEL_VERSION)`
360 dnl # pointing to them. The directory search order is now:
361 dnl #
362 dnl # - `configure` command line values if both `--with-linux` and
363 dnl # `--with-linux-obj` were defined
364 dnl #
365 dnl # - If only `--with-linux` was defined, `--with-linux-obj` is assumed
366 dnl # to have the same value as `--with-linux`
367 dnl #
368 dnl # - If neither `--with-linux` nor `--with-linux-obj` were defined
369 dnl # autodetection is used:
370 dnl #
371 dnl # - `/lib/modules/$(uname -r)/{source,build}` respectively, if exist.
372 dnl #
373 dnl # - If only `/lib/modules/$(uname -r)/build` exists, it is assumed
374 dnl # to be both source and build directory.
375 dnl #
376 dnl # - The first directory in `/lib/modules` with the highest version
377 dnl # number according to `sort -V` which contains both `source` and
378 dnl # `build` symlinks/directories. If module directory contains only
379 dnl # `build` component, it is assumed to be both source and build
380 dnl # directory.
381 dnl #
382 dnl # - Last resort: the first directory matching `/usr/src/kernels/*`
383 dnl # and `/usr/src/linux-*` with the highest version number according
384 dnl # to `sort -V` is assumed to be both source and build directory.
385 dnl #
386 AC_DEFUN([ZFS_AC_KERNEL], [
387 AC_ARG_WITH([linux],
388 AS_HELP_STRING([--with-linux=PATH],
389 [Path to kernel source]),
390 [kernelsrc="$withval"])
391
392 AC_ARG_WITH(linux-obj,
393 AS_HELP_STRING([--with-linux-obj=PATH],
394 [Path to kernel build objects]),
395 [kernelbuild="$withval"])
396
397 AC_MSG_CHECKING([kernel source and build directories])
398 AS_IF([test -n "$kernelsrc" && test -z "$kernelbuild"], [
399 kernelbuild="$kernelsrc"
400 ], [test -z "$kernelsrc"], [
401 AS_IF([test -e "/lib/modules/$(uname -r)/source" && \
402 test -e "/lib/modules/$(uname -r)/build"], [
403 src="/lib/modules/$(uname -r)/source"
404 build="/lib/modules/$(uname -r)/build"
405 ], [test -e "/lib/modules/$(uname -r)/build"], [
406 build="/lib/modules/$(uname -r)/build"
407 src="$build"
408 ], [
409 src=
410
411 for d in $(ls -1d /lib/modules/* 2>/dev/null | sort -Vr); do
412 if test -e "$d/source" && test -e "$d/build"; then
413 src="$d/source"
414 build="$d/build"
415 break
416 fi
417
418 if test -e "$d/build"; then
419 src="$d/build"
420 build="$d/build"
421 break
422 fi
423 done
424
425 # the least reliable method
426 if test -z "$src"; then
427 src=$(ls -1d /usr/src/kernels/* /usr/src/linux-* \
428 2>/dev/null | grep -v obj | sort -Vr | head -1)
429 build="$src"
430 fi
431 ])
432
433 AS_IF([test -n "$src" && test -e "$src"], [
434 kernelsrc=$(readlink -e "$src")
435 ], [
436 kernelsrc="[Not found]"
437 ])
438 AS_IF([test -n "$build" && test -e "$build"], [
439 kernelbuild=$(readlink -e "$build")
440 ], [
441 kernelbuild="[Not found]"
442 ])
443 ], [
444 AS_IF([test "$kernelsrc" = "NONE"], [
445 kernsrcver=NONE
446 ])
447 withlinux=yes
448 ])
449
450 AC_MSG_RESULT([done])
451 AC_MSG_CHECKING([kernel source directory])
452 AC_MSG_RESULT([$kernelsrc])
453 AC_MSG_CHECKING([kernel build directory])
454 AC_MSG_RESULT([$kernelbuild])
455 AS_IF([test ! -d "$kernelsrc" || test ! -d "$kernelbuild"], [
456 AC_MSG_ERROR([
457 *** Please make sure the kernel devel package for your distribution
458 *** is installed and then try again. If that fails, you can specify the
459 *** location of the kernel source and build with the '--with-linux=PATH' and
460 *** '--with-linux-obj=PATH' options respectively.])
461 ])
462
463 AC_MSG_CHECKING([kernel source version])
464 utsrelease1=$kernelbuild/include/linux/version.h
465 utsrelease2=$kernelbuild/include/linux/utsrelease.h
466 utsrelease3=$kernelbuild/include/generated/utsrelease.h
467 AS_IF([test -r $utsrelease1 && grep -qF UTS_RELEASE $utsrelease1], [
468 utsrelease=$utsrelease1
469 ], [test -r $utsrelease2 && grep -qF UTS_RELEASE $utsrelease2], [
470 utsrelease=$utsrelease2
471 ], [test -r $utsrelease3 && grep -qF UTS_RELEASE $utsrelease3], [
472 utsrelease=$utsrelease3
473 ])
474
475 AS_IF([test -n "$utsrelease"], [
476 kernsrcver=$($AWK '/UTS_RELEASE/ { gsub(/"/, "", $[3]); print $[3] }' $utsrelease)
477 AS_IF([test -z "$kernsrcver"], [
478 AC_MSG_RESULT([Not found])
479 AC_MSG_ERROR([
480 *** Cannot determine kernel version.
481 ])
482 ])
483 ], [
484 AC_MSG_RESULT([Not found])
485 if test "x$enable_linux_builtin" != xyes; then
486 AC_MSG_ERROR([
487 *** Cannot find UTS_RELEASE definition.
488 ])
489 else
490 AC_MSG_ERROR([
491 *** Cannot find UTS_RELEASE definition.
492 *** Please run 'make prepare' inside the kernel source tree.])
493 fi
494 ])
495
496 AC_MSG_RESULT([$kernsrcver])
497
498 AS_VERSION_COMPARE([$kernsrcver], [$ZFS_META_KVER_MIN], [
499 AC_MSG_ERROR([
500 *** Cannot build against kernel version $kernsrcver.
501 *** The minimum supported kernel version is $ZFS_META_KVER_MIN.
502 ])
503 ])
504
505 LINUX=${kernelsrc}
506 LINUX_OBJ=${kernelbuild}
507 LINUX_VERSION=${kernsrcver}
508
509 AC_SUBST(LINUX)
510 AC_SUBST(LINUX_OBJ)
511 AC_SUBST(LINUX_VERSION)
512 ])
513
514 dnl #
515 dnl # Detect the QAT module to be built against, QAT provides hardware
516 dnl # acceleration for data compression:
517 dnl #
518 dnl # https://01.org/intel-quickassist-technology
519 dnl #
520 dnl # 1) Download and install QAT driver from the above link
521 dnl # 2) Start QAT driver in your system:
522 dnl # service qat_service start
523 dnl # 3) Enable QAT in ZFS, e.g.:
524 dnl # ./configure --with-qat=<qat-driver-path>/QAT1.6
525 dnl # make
526 dnl # 4) Set GZIP compression in ZFS dataset:
527 dnl # zfs set compression = gzip <dataset>
528 dnl #
529 dnl # Then the data written to this ZFS pool is compressed by QAT accelerator
530 dnl # automatically, and de-compressed by QAT when read from the pool.
531 dnl #
532 dnl # 1) Get QAT hardware statistics with:
533 dnl # cat /proc/icp_dh895xcc_dev/qat
534 dnl # 2) To disable QAT:
535 dnl # insmod zfs.ko zfs_qat_disable=1
536 dnl #
537 AC_DEFUN([ZFS_AC_QAT], [
538 AC_ARG_WITH([qat],
539 AS_HELP_STRING([--with-qat=PATH],
540 [Path to qat source]),
541 AS_IF([test "$withval" = "yes"],
542 AC_MSG_ERROR([--with-qat=PATH requires a PATH]),
543 [qatsrc="$withval"]))
544
545 AC_ARG_WITH([qat-obj],
546 AS_HELP_STRING([--with-qat-obj=PATH],
547 [Path to qat build objects]),
548 [qatbuild="$withval"])
549
550 AS_IF([test ! -z "${qatsrc}"], [
551 AC_MSG_CHECKING([qat source directory])
552 AC_MSG_RESULT([$qatsrc])
553 QAT_SRC="${qatsrc}/quickassist"
554 AS_IF([ test ! -e "$QAT_SRC/include/cpa.h"], [
555 AC_MSG_ERROR([
556 *** Please make sure the qat driver package is installed
557 *** and specify the location of the qat source with the
558 *** '--with-qat=PATH' option then try again. Failed to
559 *** find cpa.h in:
560 ${QAT_SRC}/include])
561 ])
562 ])
563
564 AS_IF([test ! -z "${qatsrc}"], [
565 AC_MSG_CHECKING([qat build directory])
566 AS_IF([test -z "$qatbuild"], [
567 qatbuild="${qatsrc}/build"
568 ])
569
570 AC_MSG_RESULT([$qatbuild])
571 QAT_OBJ=${qatbuild}
572 AS_IF([ ! test -e "$QAT_OBJ/icp_qa_al.ko" && ! test -e "$QAT_OBJ/qat_api.ko"], [
573 AC_MSG_ERROR([
574 *** Please make sure the qat driver is installed then try again.
575 *** Failed to find icp_qa_al.ko or qat_api.ko in:
576 $QAT_OBJ])
577 ])
578
579 AC_SUBST(QAT_SRC)
580 AC_SUBST(QAT_OBJ)
581
582 AC_DEFINE(HAVE_QAT, 1,
583 [qat is enabled and existed])
584 ])
585
586 dnl #
587 dnl # Detect the name used for the QAT Module.symvers file.
588 dnl #
589 AS_IF([test ! -z "${qatsrc}"], [
590 AC_MSG_CHECKING([qat file for module symbols])
591 QAT_SYMBOLS=$QAT_SRC/lookaside/access_layer/src/Module.symvers
592
593 AS_IF([test -r $QAT_SYMBOLS], [
594 AC_MSG_RESULT([$QAT_SYMBOLS])
595 AC_SUBST(QAT_SYMBOLS)
596 ],[
597 AC_MSG_ERROR([
598 *** Please make sure the qat driver is installed then try again.
599 *** Failed to find Module.symvers in:
600 $QAT_SYMBOLS
601 ])
602 ])
603 ])
604 ])
605
606 dnl #
607 dnl # ZFS_LINUX_CONFTEST_H
608 dnl #
609 AC_DEFUN([ZFS_LINUX_CONFTEST_H], [
610 test -d build/$2 || mkdir -p build/$2
611 cat - <<_ACEOF >build/$2/$2.h
612 $1
613 _ACEOF
614 ])
615
616 dnl #
617 dnl # ZFS_LINUX_CONFTEST_C
618 dnl #
619 AC_DEFUN([ZFS_LINUX_CONFTEST_C], [
620 test -d build/$2 || mkdir -p build/$2
621 cat confdefs.h - <<_ACEOF >build/$2/$2.c
622 $1
623 _ACEOF
624 ])
625
626 dnl #
627 dnl # ZFS_LINUX_CONFTEST_MAKEFILE
628 dnl #
629 dnl # $1 - test case name
630 dnl # $2 - add to top-level Makefile
631 dnl # $3 - additional build flags
632 dnl #
633 AC_DEFUN([ZFS_LINUX_CONFTEST_MAKEFILE], [
634 test -d build || mkdir -p build
635 test -d build/$1 || mkdir -p build/$1
636
637 file=build/$1/Makefile
638
639 dnl # Example command line to manually build source.
640 cat - <<_ACEOF >$file
641 # Example command line to manually build source
642 # make modules -C $LINUX_OBJ $ARCH_UM M=$PWD/build/$1
643
644 ccflags-y := -Werror $FRAME_LARGER_THAN
645 _ACEOF
646
647 dnl # Additional custom CFLAGS as requested.
648 m4_ifval($3, [echo "ccflags-y += $3" >>$file], [])
649
650 dnl # Test case source
651 echo "obj-m := $1.o" >>$file
652
653 AS_IF([test "x$2" = "xyes"], [echo "obj-m += $1/" >>build/Makefile], [])
654 ])
655
656 dnl #
657 dnl # ZFS_LINUX_TEST_PROGRAM(C)([PROLOGUE], [BODY])
658 dnl #
659 m4_define([ZFS_LINUX_TEST_PROGRAM], [
660 #include <linux/module.h>
661 $1
662
663 int
664 main (void)
665 {
666 $2
667 ;
668 return 0;
669 }
670
671 MODULE_DESCRIPTION("conftest");
672 MODULE_AUTHOR(ZFS_META_AUTHOR);
673 MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE);
674 MODULE_LICENSE($3);
675 ])
676
677 dnl #
678 dnl # ZFS_LINUX_TEST_REMOVE
679 dnl #
680 dnl # Removes the specified test source and results.
681 dnl #
682 AC_DEFUN([ZFS_LINUX_TEST_REMOVE], [
683 test -d build/$1 && rm -Rf build/$1
684 test -f build/Makefile && sed '/$1/d' build/Makefile
685 ])
686
687 dnl #
688 dnl # ZFS_LINUX_COMPILE
689 dnl #
690 dnl # $1 - build dir
691 dnl # $2 - test command
692 dnl # $3 - pass command
693 dnl # $4 - fail command
694 dnl # $5 - set KBUILD_MODPOST_NOFINAL='yes'
695 dnl # $6 - set KBUILD_MODPOST_WARN='yes'
696 dnl #
697 dnl # Used internally by ZFS_LINUX_TEST_{COMPILE,MODPOST}
698 dnl #
699 AC_DEFUN([ZFS_LINUX_COMPILE], [
700 AC_ARG_VAR([KERNEL_CC], [C compiler for
701 building kernel modules])
702 AC_ARG_VAR([KERNEL_LD], [Linker for
703 building kernel modules])
704 AC_ARG_VAR([KERNEL_LLVM], [Binary option to
705 build kernel modules with LLVM/CLANG toolchain])
706 AC_TRY_COMMAND([
707 KBUILD_MODPOST_NOFINAL="$5" KBUILD_MODPOST_WARN="$6"
708 make modules -k -j$TEST_JOBS ${KERNEL_CC:+CC=$KERNEL_CC}
709 ${KERNEL_LD:+LD=$KERNEL_LD} ${KERNEL_LLVM:+LLVM=$KERNEL_LLVM}
710 CONFIG_MODULES=y CFLAGS_MODULE=-DCONFIG_MODULES
711 -C $LINUX_OBJ $ARCH_UM M=$PWD/$1 >$1/build.log 2>&1])
712 AS_IF([AC_TRY_COMMAND([$2])], [$3], [$4])
713 ])
714
715 dnl #
716 dnl # ZFS_LINUX_TEST_COMPILE
717 dnl #
718 dnl # Perform a full compile excluding the final modpost phase.
719 dnl #
720 AC_DEFUN([ZFS_LINUX_TEST_COMPILE], [
721 ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [
722 mv $2/Makefile $2/Makefile.compile.$1
723 mv $2/build.log $2/build.log.$1
724 ],[
725 AC_MSG_ERROR([
726 *** Unable to compile test source to determine kernel interfaces.])
727 ], [yes], [])
728 ])
729
730 dnl #
731 dnl # ZFS_LINUX_TEST_MODPOST
732 dnl #
733 dnl # Perform a full compile including the modpost phase. This may
734 dnl # be an incremental build if the objects have already been built.
735 dnl #
736 AC_DEFUN([ZFS_LINUX_TEST_MODPOST], [
737 ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [
738 mv $2/Makefile $2/Makefile.modpost.$1
739 cat $2/build.log >>build/build.log.$1
740 ],[
741 AC_MSG_ERROR([
742 *** Unable to modpost test source to determine kernel interfaces.])
743 ], [], [yes])
744 ])
745
746 dnl #
747 dnl # Perform the compilation of the test cases in two phases.
748 dnl #
749 dnl # Phase 1) attempt to build the object files for all of the tests
750 dnl # defined by the ZFS_LINUX_TEST_SRC macro. But do not
751 dnl # perform the final modpost stage.
752 dnl #
753 dnl # Phase 2) disable all tests which failed the initial compilation,
754 dnl # then invoke the final modpost step for the remaining tests.
755 dnl #
756 dnl # This allows us efficiently build the test cases in parallel while
757 dnl # remaining resilient to build failures which are expected when
758 dnl # detecting the available kernel interfaces.
759 dnl #
760 dnl # The maximum allowed parallelism can be controlled by setting the
761 dnl # TEST_JOBS environment variable. Otherwise, it default to $(nproc).
762 dnl #
763 AC_DEFUN([ZFS_LINUX_TEST_COMPILE_ALL], [
764 dnl # Phase 1 - Compilation only, final linking is skipped.
765 ZFS_LINUX_TEST_COMPILE([$1], [build])
766
767 dnl #
768 dnl # Phase 2 - When building external modules disable test cases
769 dnl # which failed to compile and invoke modpost to verify the
770 dnl # final linking.
771 dnl #
772 dnl # Test names suffixed with '_license' call modpost independently
773 dnl # to ensure that a single incompatibility does not result in the
774 dnl # modpost phase exiting early. This check is not performed on
775 dnl # every symbol since the majority are compatible and doing so
776 dnl # would significantly slow down this phase.
777 dnl #
778 dnl # When configuring for builtin (--enable-linux-builtin)
779 dnl # fake the linking step artificially create the expected .ko
780 dnl # files for tests which did compile. This is required for
781 dnl # kernels which do not have loadable module support or have
782 dnl # not yet been built.
783 dnl #
784 AS_IF([test "x$enable_linux_builtin" = "xno"], [
785 for dir in $(awk '/^obj-m/ { print [$]3 }' \
786 build/Makefile.compile.$1); do
787 name=${dir%/}
788 AS_IF([test -f build/$name/$name.o], [
789 AS_IF([test "${name##*_}" = "license"], [
790 ZFS_LINUX_TEST_MODPOST([$1],
791 [build/$name])
792 echo "obj-n += $dir" >>build/Makefile
793 ], [
794 echo "obj-m += $dir" >>build/Makefile
795 ])
796 ], [
797 echo "obj-n += $dir" >>build/Makefile
798 ])
799 done
800
801 ZFS_LINUX_TEST_MODPOST([$1], [build])
802 ], [
803 for dir in $(awk '/^obj-m/ { print [$]3 }' \
804 build/Makefile.compile.$1); do
805 name=${dir%/}
806 AS_IF([test -f build/$name/$name.o], [
807 touch build/$name/$name.ko
808 ])
809 done
810 ])
811 ])
812
813 dnl #
814 dnl # ZFS_LINUX_TEST_SRC
815 dnl #
816 dnl # $1 - name
817 dnl # $2 - global
818 dnl # $3 - source
819 dnl # $4 - extra cflags
820 dnl # $5 - check license-compatibility
821 dnl #
822 dnl # Check if the test source is buildable at all and then if it is
823 dnl # license compatible.
824 dnl #
825 dnl # N.B because all of the test cases are compiled in parallel they
826 dnl # must never depend on the results of previous tests. Each test
827 dnl # needs to be entirely independent.
828 dnl #
829 AC_DEFUN([ZFS_LINUX_TEST_SRC], [
830 ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM([[$2]], [[$3]],
831 [["Dual BSD/GPL"]])], [$1])
832 ZFS_LINUX_CONFTEST_MAKEFILE([$1], [yes], [$4])
833
834 AS_IF([ test -n "$5" ], [
835 ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM(
836 [[$2]], [[$3]], [[$5]])], [$1_license])
837 ZFS_LINUX_CONFTEST_MAKEFILE([$1_license], [yes], [$4])
838 ])
839 ])
840
841 dnl #
842 dnl # ZFS_LINUX_TEST_RESULT
843 dnl #
844 dnl # $1 - name of a test source (ZFS_LINUX_TEST_SRC)
845 dnl # $2 - run on success (valid .ko generated)
846 dnl # $3 - run on failure (unable to compile)
847 dnl #
848 AC_DEFUN([ZFS_LINUX_TEST_RESULT], [
849 AS_IF([test -d build/$1], [
850 AS_IF([test -f build/$1/$1.ko], [$2], [$3])
851 ], [
852 AC_MSG_ERROR([
853 *** No matching source for the "$1" test, check that
854 *** both the test source and result macros refer to the same name.
855 ])
856 ])
857 ])
858
859 dnl #
860 dnl # ZFS_LINUX_TEST_ERROR
861 dnl #
862 dnl # Generic error message which can be used when none of the expected
863 dnl # kernel interfaces were detected.
864 dnl #
865 AC_DEFUN([ZFS_LINUX_TEST_ERROR], [
866 AC_MSG_ERROR([
867 *** None of the expected "$1" interfaces were detected.
868 *** This may be because your kernel version is newer than what is
869 *** supported, or you are using a patched custom kernel with
870 *** incompatible modifications.
871 ***
872 *** ZFS Version: $ZFS_META_ALIAS
873 *** Compatible Kernels: $ZFS_META_KVER_MIN - $ZFS_META_KVER_MAX
874 ])
875 ])
876
877 dnl #
878 dnl # ZFS_LINUX_TEST_RESULT_SYMBOL
879 dnl #
880 dnl # Like ZFS_LINUX_TEST_RESULT except ZFS_CHECK_SYMBOL_EXPORT is called to
881 dnl # verify symbol exports, unless --enable-linux-builtin was provided to
882 dnl # configure.
883 dnl #
884 AC_DEFUN([ZFS_LINUX_TEST_RESULT_SYMBOL], [
885 AS_IF([ ! test -f build/$1/$1.ko], [
886 $5
887 ], [
888 AS_IF([test "x$enable_linux_builtin" != "xyes"], [
889 ZFS_CHECK_SYMBOL_EXPORT([$2], [$3], [$4], [$5])
890 ], [
891 $4
892 ])
893 ])
894 ])
895
896 dnl #
897 dnl # ZFS_LINUX_COMPILE_IFELSE
898 dnl #
899 AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
900 ZFS_LINUX_TEST_REMOVE([conftest])
901
902 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST_C([$1], [conftest])])
903 m4_ifvaln([$5], [ZFS_LINUX_CONFTEST_H([$5], [conftest])],
904 [ZFS_LINUX_CONFTEST_H([], [conftest])])
905
906 ZFS_LINUX_CONFTEST_MAKEFILE([conftest], [no],
907 [m4_ifvaln([$5], [-I$PWD/build/conftest], [])])
908 ZFS_LINUX_COMPILE([build/conftest], [$2], [$3], [$4], [], [])
909 ])
910
911 dnl #
912 dnl # ZFS_LINUX_TRY_COMPILE
913 dnl #
914 dnl # $1 - global
915 dnl # $2 - source
916 dnl # $3 - run on success (valid .ko generated)
917 dnl # $4 - run on failure (unable to compile)
918 dnl #
919 dnl # When configuring as builtin (--enable-linux-builtin) for kernels
920 dnl # without loadable module support (CONFIG_MODULES=n) only the object
921 dnl # file is created. See ZFS_LINUX_TEST_COMPILE_ALL for details.
922 dnl #
923 AC_DEFUN([ZFS_LINUX_TRY_COMPILE], [
924 AS_IF([test "x$enable_linux_builtin" = "xyes"], [
925 ZFS_LINUX_COMPILE_IFELSE(
926 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
927 [[ZFS_META_LICENSE]])],
928 [test -f build/conftest/conftest.o], [$3], [$4])
929 ], [
930 ZFS_LINUX_COMPILE_IFELSE(
931 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
932 [[ZFS_META_LICENSE]])],
933 [test -f build/conftest/conftest.ko], [$3], [$4])
934 ])
935 ])
936
937 dnl #
938 dnl # ZFS_CHECK_SYMBOL_EXPORT
939 dnl #
940 dnl # Check if a symbol is exported on not by consulting the symbols
941 dnl # file, or optionally the source code.
942 dnl #
943 AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
944 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
945 $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
946 rc=$?
947 if test $rc -ne 0; then
948 export=0
949 for file in $2; do
950 grep -q -E "EXPORT_SYMBOL.*($1)" \
951 "$LINUX/$file" 2>/dev/null
952 rc=$?
953 if test $rc -eq 0; then
954 export=1
955 break;
956 fi
957 done
958 if test $export -eq 0; then :
959 $4
960 else :
961 $3
962 fi
963 else :
964 $3
965 fi
966 ])
967
968 dnl #
969 dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL
970 dnl #
971 dnl # Like ZFS_LINUX_TRY_COMPILER except ZFS_CHECK_SYMBOL_EXPORT is called
972 dnl # to verify symbol exports, unless --enable-linux-builtin was provided
973 dnl # to configure.
974 dnl #
975 AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [
976 ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
977 if test $rc -ne 0; then :
978 $6
979 else
980 if test "x$enable_linux_builtin" != xyes; then
981 ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
982 fi
983 if test $rc -ne 0; then :
984 $6
985 else :
986 $5
987 fi
988 fi
989 ])
990
991 dnl #
992 dnl # ZFS_LINUX_TRY_COMPILE_HEADER
993 dnl # like ZFS_LINUX_TRY_COMPILE, except the contents conftest.h are
994 dnl # provided via the fifth parameter
995 dnl #
996 AC_DEFUN([ZFS_LINUX_TRY_COMPILE_HEADER], [
997 AS_IF([test "x$enable_linux_builtin" = "xyes"], [
998 ZFS_LINUX_COMPILE_IFELSE(
999 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
1000 [[ZFS_META_LICENSE]])],
1001 [test -f build/conftest/conftest.o], [$3], [$4], [$5])
1002 ], [
1003 ZFS_LINUX_COMPILE_IFELSE(
1004 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
1005 [[ZFS_META_LICENSE]])],
1006 [test -f build/conftest/conftest.ko], [$3], [$4], [$5])
1007 ])
1008 ])
1009
1010 dnl #
1011 dnl # AS_VERSION_COMPARE_LE
1012 dnl # like AS_VERSION_COMPARE_LE, but runs $3 if (and only if) $1 <= $2
1013 dnl # AS_VERSION_COMPARE_LE (version-1, version-2, [action-if-less-or-equal], [action-if-greater])
1014 dnl #
1015 AC_DEFUN([AS_VERSION_COMPARE_LE], [
1016 AS_VERSION_COMPARE([$1], [$2], [$3], [$3], [$4])
1017 ])
1018
1019 dnl #
1020 dnl # ZFS_LINUX_REQUIRE_API
1021 dnl # like ZFS_LINUX_TEST_ERROR, except only fails if the kernel is
1022 dnl # at least some specified version.
1023 dnl #
1024 AC_DEFUN([ZFS_LINUX_REQUIRE_API], [
1025 AS_VERSION_COMPARE_LE([$2], [$kernsrcver], [
1026 AC_MSG_ERROR([
1027 *** None of the expected "$1" interfaces were detected. This
1028 *** interface is expected for kernels version "$2" and above.
1029 *** This may be because your kernel version is newer than what is
1030 *** supported, or you are using a patched custom kernel with
1031 *** incompatible modifications. Newer kernels may have incompatible
1032 *** APIs.
1033 ***
1034 *** ZFS Version: $ZFS_META_ALIAS
1035 *** Compatible Kernels: $ZFS_META_KVER_MIN - $ZFS_META_KVER_MAX
1036 ])
1037 ], [
1038 AC_MSG_RESULT(no)
1039 ])
1040 ])