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