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