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