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