]>
Commit | Line | Data |
---|---|---|
1 | dnl # | |
2 | dnl # Default ZFS kernel configuration | |
3 | dnl # | |
4 | AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ | |
5 | ZFS_AC_KERNEL | |
6 | ZFS_AC_SPL | |
7 | ZFS_AC_QAT | |
8 | ZFS_AC_TEST_MODULE | |
9 | ZFS_AC_KERNEL_OBJTOOL | |
10 | ZFS_AC_KERNEL_CONFIG | |
11 | ZFS_AC_KERNEL_DECLARE_EVENT_CLASS | |
12 | ZFS_AC_KERNEL_CURRENT_BIO_TAIL | |
13 | ZFS_AC_KERNEL_SUPER_USER_NS | |
14 | ZFS_AC_KERNEL_SUBMIT_BIO | |
15 | ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS | |
16 | ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID | |
17 | ZFS_AC_KERNEL_TYPE_FMODE_T | |
18 | ZFS_AC_KERNEL_3ARG_BLKDEV_GET | |
19 | ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH | |
20 | ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE | |
21 | ZFS_AC_KERNEL_LOOKUP_BDEV | |
22 | ZFS_AC_KERNEL_INVALIDATE_BDEV_ARGS | |
23 | ZFS_AC_KERNEL_BDEV_LOGICAL_BLOCK_SIZE | |
24 | ZFS_AC_KERNEL_BDEV_PHYSICAL_BLOCK_SIZE | |
25 | ZFS_AC_KERNEL_BIO_BVEC_ITER | |
26 | ZFS_AC_KERNEL_BIO_FAILFAST_DTD | |
27 | ZFS_AC_KERNEL_BIO_SET_DEV | |
28 | ZFS_AC_KERNEL_REQ_FAILFAST_MASK | |
29 | ZFS_AC_KERNEL_REQ_OP_DISCARD | |
30 | ZFS_AC_KERNEL_REQ_OP_SECURE_ERASE | |
31 | ZFS_AC_KERNEL_REQ_OP_FLUSH | |
32 | ZFS_AC_KERNEL_BIO_BI_OPF | |
33 | ZFS_AC_KERNEL_BIO_END_IO_T_ARGS | |
34 | ZFS_AC_KERNEL_BIO_BI_STATUS | |
35 | ZFS_AC_KERNEL_BIO_RW_BARRIER | |
36 | ZFS_AC_KERNEL_BIO_RW_DISCARD | |
37 | ZFS_AC_KERNEL_BLK_QUEUE_BDI | |
38 | ZFS_AC_KERNEL_BLK_QUEUE_FLUSH | |
39 | ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS | |
40 | ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS | |
41 | ZFS_AC_KERNEL_BLK_QUEUE_HAVE_BIO_RW_UNPLUG | |
42 | ZFS_AC_KERNEL_BLK_QUEUE_HAVE_BLK_PLUG | |
43 | ZFS_AC_KERNEL_GET_DISK_RO | |
44 | ZFS_AC_KERNEL_GET_GENDISK | |
45 | ZFS_AC_KERNEL_HAVE_BIO_SET_OP_ATTRS | |
46 | ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL | |
47 | ZFS_AC_KERNEL_DISCARD_GRANULARITY | |
48 | ZFS_AC_KERNEL_CONST_XATTR_HANDLER | |
49 | ZFS_AC_KERNEL_XATTR_HANDLER_NAME | |
50 | ZFS_AC_KERNEL_XATTR_HANDLER_GET | |
51 | ZFS_AC_KERNEL_XATTR_HANDLER_SET | |
52 | ZFS_AC_KERNEL_XATTR_HANDLER_LIST | |
53 | ZFS_AC_KERNEL_INODE_OWNER_OR_CAPABLE | |
54 | ZFS_AC_KERNEL_POSIX_ACL_FROM_XATTR_USERNS | |
55 | ZFS_AC_KERNEL_POSIX_ACL_RELEASE | |
56 | ZFS_AC_KERNEL_SET_CACHED_ACL_USABLE | |
57 | ZFS_AC_KERNEL_POSIX_ACL_CHMOD | |
58 | ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T | |
59 | ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS | |
60 | ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION | |
61 | ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION_WITH_NAMEIDATA | |
62 | ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL | |
63 | ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL_WITH_FLAGS | |
64 | ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL | |
65 | ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL | |
66 | ZFS_AC_KERNEL_INODE_OPERATIONS_GETATTR | |
67 | ZFS_AC_KERNEL_INODE_SET_FLAGS | |
68 | ZFS_AC_KERNEL_GET_ACL_HANDLE_CACHE | |
69 | ZFS_AC_KERNEL_SHOW_OPTIONS | |
70 | ZFS_AC_KERNEL_FILE_INODE | |
71 | ZFS_AC_KERNEL_FILE_DENTRY | |
72 | ZFS_AC_KERNEL_FSYNC | |
73 | ZFS_AC_KERNEL_EVICT_INODE | |
74 | ZFS_AC_KERNEL_DIRTY_INODE_WITH_FLAGS | |
75 | ZFS_AC_KERNEL_NR_CACHED_OBJECTS | |
76 | ZFS_AC_KERNEL_FREE_CACHED_OBJECTS | |
77 | ZFS_AC_KERNEL_FALLOCATE | |
78 | ZFS_AC_KERNEL_AIO_FSYNC | |
79 | ZFS_AC_KERNEL_MKDIR_UMODE_T | |
80 | ZFS_AC_KERNEL_LOOKUP_NAMEIDATA | |
81 | ZFS_AC_KERNEL_CREATE_NAMEIDATA | |
82 | ZFS_AC_KERNEL_GET_LINK | |
83 | ZFS_AC_KERNEL_PUT_LINK | |
84 | ZFS_AC_KERNEL_TMPFILE | |
85 | ZFS_AC_KERNEL_TRUNCATE_RANGE | |
86 | ZFS_AC_KERNEL_AUTOMOUNT | |
87 | ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE | |
88 | ZFS_AC_KERNEL_COMMIT_METADATA | |
89 | ZFS_AC_KERNEL_CLEAR_INODE | |
90 | ZFS_AC_KERNEL_SETATTR_PREPARE | |
91 | ZFS_AC_KERNEL_INSERT_INODE_LOCKED | |
92 | ZFS_AC_KERNEL_D_MAKE_ROOT | |
93 | ZFS_AC_KERNEL_D_OBTAIN_ALIAS | |
94 | ZFS_AC_KERNEL_D_PRUNE_ALIASES | |
95 | ZFS_AC_KERNEL_D_SET_D_OP | |
96 | ZFS_AC_KERNEL_D_REVALIDATE_NAMEIDATA | |
97 | ZFS_AC_KERNEL_CONST_DENTRY_OPERATIONS | |
98 | ZFS_AC_KERNEL_TRUNCATE_SETSIZE | |
99 | ZFS_AC_KERNEL_6ARGS_SECURITY_INODE_INIT_SECURITY | |
100 | ZFS_AC_KERNEL_CALLBACK_SECURITY_INODE_INIT_SECURITY | |
101 | ZFS_AC_KERNEL_MOUNT_NODEV | |
102 | ZFS_AC_KERNEL_SHRINK | |
103 | ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID | |
104 | ZFS_AC_KERNEL_S_INSTANCES_LIST_HEAD | |
105 | ZFS_AC_KERNEL_S_D_OP | |
106 | ZFS_AC_KERNEL_BDI | |
107 | ZFS_AC_KERNEL_SET_NLINK | |
108 | ZFS_AC_KERNEL_ELEVATOR_CHANGE | |
109 | ZFS_AC_KERNEL_5ARG_SGET | |
110 | ZFS_AC_KERNEL_LSEEK_EXECUTE | |
111 | ZFS_AC_KERNEL_VFS_ITERATE | |
112 | ZFS_AC_KERNEL_VFS_RW_ITERATE | |
113 | ZFS_AC_KERNEL_GENERIC_WRITE_CHECKS | |
114 | ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS | |
115 | ZFS_AC_KERNEL_FOLLOW_DOWN_ONE | |
116 | ZFS_AC_KERNEL_MAKE_REQUEST_FN | |
117 | ZFS_AC_KERNEL_GENERIC_IO_ACCT_3ARG | |
118 | ZFS_AC_KERNEL_GENERIC_IO_ACCT_4ARG | |
119 | ZFS_AC_KERNEL_FPU | |
120 | ZFS_AC_KERNEL_KUID_HELPERS | |
121 | ZFS_AC_KERNEL_MODULE_PARAM_CALL_CONST | |
122 | ZFS_AC_KERNEL_RENAME_WANTS_FLAGS | |
123 | ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR | |
124 | ZFS_AC_KERNEL_CURRENT_TIME | |
125 | ZFS_AC_KERNEL_VM_NODE_STAT | |
126 | ||
127 | AS_IF([test "$LINUX_OBJ" != "$LINUX"], [ | |
128 | KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" | |
129 | ]) | |
130 | AC_SUBST(KERNELMAKE_PARAMS) | |
131 | ||
132 | ||
133 | dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other | |
134 | dnl # compiler options are added by the kernel build system. | |
135 | KERNELCPPFLAGS="$KERNELCPPFLAGS -std=gnu99" | |
136 | KERNELCPPFLAGS="$KERNELCPPFLAGS -Wno-declaration-after-statement" | |
137 | KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_UNUSED_BUT_SET_VARIABLE" | |
138 | KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_BOOL_COMPARE" | |
139 | KERNELCPPFLAGS="$KERNELCPPFLAGS -DHAVE_SPL -D_KERNEL" | |
140 | KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\"" | |
141 | ||
142 | AC_SUBST(KERNELCPPFLAGS) | |
143 | ]) | |
144 | ||
145 | dnl # | |
146 | dnl # Detect name used for Module.symvers file in kernel | |
147 | dnl # | |
148 | AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [ | |
149 | modpost=$LINUX/scripts/Makefile.modpost | |
150 | AC_MSG_CHECKING([kernel file name for module symbols]) | |
151 | AS_IF([test "x$enable_linux_builtin" != xyes -a -f "$modpost"], [ | |
152 | AS_IF([grep -q Modules.symvers $modpost], [ | |
153 | LINUX_SYMBOLS=Modules.symvers | |
154 | ], [ | |
155 | LINUX_SYMBOLS=Module.symvers | |
156 | ]) | |
157 | ||
158 | AS_IF([test ! -f "$LINUX_OBJ/$LINUX_SYMBOLS"], [ | |
159 | AC_MSG_ERROR([ | |
160 | *** Please make sure the kernel devel package for your distribution | |
161 | *** is installed. If you are building with a custom kernel, make sure the | |
162 | *** kernel is configured, built, and the '--with-linux=PATH' configure | |
163 | *** option refers to the location of the kernel source.]) | |
164 | ]) | |
165 | ], [ | |
166 | LINUX_SYMBOLS=NONE | |
167 | ]) | |
168 | AC_MSG_RESULT($LINUX_SYMBOLS) | |
169 | AC_SUBST(LINUX_SYMBOLS) | |
170 | ]) | |
171 | ||
172 | dnl # | |
173 | dnl # Detect the kernel to be built against | |
174 | dnl # | |
175 | AC_DEFUN([ZFS_AC_KERNEL], [ | |
176 | AC_ARG_WITH([linux], | |
177 | AS_HELP_STRING([--with-linux=PATH], | |
178 | [Path to kernel source]), | |
179 | [kernelsrc="$withval"]) | |
180 | ||
181 | AC_ARG_WITH(linux-obj, | |
182 | AS_HELP_STRING([--with-linux-obj=PATH], | |
183 | [Path to kernel build objects]), | |
184 | [kernelbuild="$withval"]) | |
185 | ||
186 | AC_MSG_CHECKING([kernel source directory]) | |
187 | AS_IF([test -z "$kernelsrc"], [ | |
188 | AS_IF([test -e "/lib/modules/$(uname -r)/source"], [ | |
189 | headersdir="/lib/modules/$(uname -r)/source" | |
190 | sourcelink=$(readlink -f "$headersdir") | |
191 | ], [test -e "/lib/modules/$(uname -r)/build"], [ | |
192 | headersdir="/lib/modules/$(uname -r)/build" | |
193 | sourcelink=$(readlink -f "$headersdir") | |
194 | ], [ | |
195 | sourcelink=$(ls -1d /usr/src/kernels/* \ | |
196 | /usr/src/linux-* \ | |
197 | 2>/dev/null | grep -v obj | tail -1) | |
198 | ]) | |
199 | ||
200 | AS_IF([test -n "$sourcelink" && test -e ${sourcelink}], [ | |
201 | kernelsrc=`readlink -f ${sourcelink}` | |
202 | ], [ | |
203 | kernelsrc="[Not found]" | |
204 | ]) | |
205 | ], [ | |
206 | AS_IF([test "$kernelsrc" = "NONE"], [ | |
207 | kernsrcver=NONE | |
208 | ]) | |
209 | withlinux=yes | |
210 | ]) | |
211 | ||
212 | AC_MSG_RESULT([$kernelsrc]) | |
213 | AS_IF([test ! -d "$kernelsrc"], [ | |
214 | AC_MSG_ERROR([ | |
215 | *** Please make sure the kernel devel package for your distribution | |
216 | *** is installed and then try again. If that fails, you can specify the | |
217 | *** location of the kernel source with the '--with-linux=PATH' option.]) | |
218 | ]) | |
219 | ||
220 | AC_MSG_CHECKING([kernel build directory]) | |
221 | AS_IF([test -z "$kernelbuild"], [ | |
222 | AS_IF([test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"], [ | |
223 | kernelbuild=`readlink -f /lib/modules/$(uname -r)/build` | |
224 | ], [test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}], [ | |
225 | kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu} | |
226 | ], [test -d ${kernelsrc}-obj/${target_cpu}/default], [ | |
227 | kernelbuild=${kernelsrc}-obj/${target_cpu}/default | |
228 | ], [test -d `dirname ${kernelsrc}`/build-${target_cpu}], [ | |
229 | kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu} | |
230 | ], [ | |
231 | kernelbuild=${kernelsrc} | |
232 | ]) | |
233 | ]) | |
234 | AC_MSG_RESULT([$kernelbuild]) | |
235 | ||
236 | AC_MSG_CHECKING([kernel source version]) | |
237 | utsrelease1=$kernelbuild/include/linux/version.h | |
238 | utsrelease2=$kernelbuild/include/linux/utsrelease.h | |
239 | utsrelease3=$kernelbuild/include/generated/utsrelease.h | |
240 | AS_IF([test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1], [ | |
241 | utsrelease=linux/version.h | |
242 | ], [test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2], [ | |
243 | utsrelease=linux/utsrelease.h | |
244 | ], [test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3], [ | |
245 | utsrelease=generated/utsrelease.h | |
246 | ]) | |
247 | ||
248 | AS_IF([test "$utsrelease"], [ | |
249 | kernsrcver=`(echo "#include <$utsrelease>"; | |
250 | echo "kernsrcver=UTS_RELEASE") | | |
251 | cpp -I $kernelbuild/include | | |
252 | grep "^kernsrcver=" | cut -d \" -f 2` | |
253 | ||
254 | AS_IF([test -z "$kernsrcver"], [ | |
255 | AC_MSG_RESULT([Not found]) | |
256 | AC_MSG_ERROR([*** Cannot determine kernel version.]) | |
257 | ]) | |
258 | ], [ | |
259 | AC_MSG_RESULT([Not found]) | |
260 | if test "x$enable_linux_builtin" != xyes; then | |
261 | AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.]) | |
262 | else | |
263 | AC_MSG_ERROR([ | |
264 | *** Cannot find UTS_RELEASE definition. | |
265 | *** Please run 'make prepare' inside the kernel source tree.]) | |
266 | fi | |
267 | ]) | |
268 | ||
269 | AC_MSG_RESULT([$kernsrcver]) | |
270 | ||
271 | LINUX=${kernelsrc} | |
272 | LINUX_OBJ=${kernelbuild} | |
273 | LINUX_VERSION=${kernsrcver} | |
274 | ||
275 | AC_SUBST(LINUX) | |
276 | AC_SUBST(LINUX_OBJ) | |
277 | AC_SUBST(LINUX_VERSION) | |
278 | ||
279 | ZFS_AC_MODULE_SYMVERS | |
280 | ]) | |
281 | ||
282 | ||
283 | dnl # | |
284 | dnl # Detect the SPL module to be built against | |
285 | dnl # | |
286 | AC_DEFUN([ZFS_AC_SPL], [ | |
287 | AC_ARG_WITH([spl], | |
288 | AS_HELP_STRING([--with-spl=PATH], | |
289 | [Path to spl source]), | |
290 | AS_IF([test "$withval" = "yes"], | |
291 | AC_MSG_ERROR([--with-spl=PATH requires a PATH]), | |
292 | [splsrc="$withval"])) | |
293 | ||
294 | AC_ARG_WITH([spl-obj], | |
295 | AS_HELP_STRING([--with-spl-obj=PATH], | |
296 | [Path to spl build objects]), | |
297 | [splbuild="$withval"]) | |
298 | ||
299 | AC_ARG_WITH([spl-timeout], | |
300 | AS_HELP_STRING([--with-spl-timeout=SECS], | |
301 | [Wait SECS for SPL header and symver file @<:@default=0@:>@]), | |
302 | [timeout="$withval"], [timeout=0]) | |
303 | ||
304 | dnl # | |
305 | dnl # The existence of spl.release.in is used to identify a valid | |
306 | dnl # source directory. In order of preference: | |
307 | dnl # | |
308 | splsrc0="/var/lib/dkms/spl/${VERSION}/build" | |
309 | splsrc1="/usr/local/src/spl-${VERSION}/${LINUX_VERSION}" | |
310 | splsrc2="/usr/local/src/spl-${VERSION}" | |
311 | splsrc3="/usr/src/spl-${VERSION}/${LINUX_VERSION}" | |
312 | splsrc4="/usr/src/spl-${VERSION}" | |
313 | splsrc5="../spl/" | |
314 | splsrc6="$LINUX" | |
315 | ||
316 | AC_MSG_CHECKING([spl source directory]) | |
317 | AS_IF([test -z "${splsrc}"], [ | |
318 | [all_spl_sources=" | |
319 | ${splsrc0} | |
320 | ${splsrc1} | |
321 | ${splsrc2} | |
322 | ${splsrc3} | |
323 | ${splsrc4} | |
324 | ${splsrc5} | |
325 | ${splsrc6}"], | |
326 | AS_IF([ test -e "${splsrc0}/spl.release.in"], [ | |
327 | splsrc=${splsrc0} | |
328 | ], [ test -e "${splsrc1}/spl.release.in"], [ | |
329 | splsrc=${splsrc1} | |
330 | ], [ test -e "${splsrc2}/spl.release.in"], [ | |
331 | splsrc=${splsrc2} | |
332 | ], [ test -e "${splsrc3}/spl.release.in"], [ | |
333 | splsrc=$(readlink -f "${splsrc3}") | |
334 | ], [ test -e "${splsrc4}/spl.release.in" ], [ | |
335 | splsrc=${splsrc4} | |
336 | ], [ test -e "${splsrc5}/spl.release.in"], [ | |
337 | splsrc=$(readlink -f "${splsrc5}") | |
338 | ], [ test -e "${splsrc6}/spl.release.in" ], [ | |
339 | splsrc=${splsrc6} | |
340 | ], [ | |
341 | splsrc="[Not found]" | |
342 | ]) | |
343 | ], [ | |
344 | [all_spl_sources="$withval"], | |
345 | AS_IF([test "$splsrc" = "NONE"], [ | |
346 | splbuild=NONE | |
347 | splsrcver=NONE | |
348 | ]) | |
349 | ]) | |
350 | ||
351 | AC_MSG_RESULT([$splsrc]) | |
352 | AS_IF([ test ! -e "$splsrc/spl.release.in"], [ | |
353 | AC_MSG_ERROR([ | |
354 | *** Please make sure the kmod spl devel package for your distribution | |
355 | *** is installed then try again. If that fails you can specify the | |
356 | *** location of the spl source with the '--with-spl=PATH' option. | |
357 | *** The spl version must match the version of ZFS you are building, | |
358 | *** ${VERSION}. Failed to find spl.release.in in the following: | |
359 | $all_spl_sources]) | |
360 | ]) | |
361 | ||
362 | dnl # | |
363 | dnl # The existence of the spl_config.h is used to identify a valid | |
364 | dnl # spl object directory. In many cases the object and source | |
365 | dnl # directory are the same, however the objects may also reside | |
366 | dnl # is a subdirectory named after the kernel version. | |
367 | dnl # | |
368 | dnl # This file is supposed to be available after DKMS finishes | |
369 | dnl # building the SPL kernel module for the target kernel. The | |
370 | dnl # '--with-spl-timeout' option can be passed to pause here, | |
371 | dnl # waiting for the file to appear from a concurrently building | |
372 | dnl # SPL package. | |
373 | dnl # | |
374 | AC_MSG_CHECKING([spl build directory]) | |
375 | ||
376 | all_spl_config_locs="${splsrc}/${LINUX_VERSION} | |
377 | ${splsrc}" | |
378 | ||
379 | while true; do | |
380 | AS_IF([test -z "$splbuild"], [ | |
381 | AS_IF([ test -e "${splsrc}/${LINUX_VERSION}/spl_config.h" ], [ | |
382 | splbuild="${splsrc}/${LINUX_VERSION}" | |
383 | ], [ test -e "${splsrc}/spl_config.h" ], [ | |
384 | splbuild="${splsrc}" | |
385 | ], [ find -L "${splsrc}" -name spl_config.h 2> /dev/null | grep -wq spl_config.h ], [ | |
386 | splbuild=$(find -L "${splsrc}" -name spl_config.h | sed 's,/spl_config.h,,') | |
387 | ], [ | |
388 | splbuild="[Not found]" | |
389 | ]) | |
390 | ]) | |
391 | AS_IF([test -e "$splbuild/spl_config.h" -o $timeout -le 0], [ | |
392 | break; | |
393 | ], [ | |
394 | sleep 1 | |
395 | timeout=$((timeout-1)) | |
396 | ]) | |
397 | done | |
398 | ||
399 | AC_MSG_RESULT([$splbuild]) | |
400 | AS_IF([ ! test -e "$splbuild/spl_config.h"], [ | |
401 | AC_MSG_ERROR([ | |
402 | *** Please make sure the kmod spl devel <kernel> package for your | |
403 | *** distribution is installed then try again. If that fails you | |
404 | *** can specify the location of the spl objects with the | |
405 | *** '--with-spl-obj=PATH' option. Failed to find spl_config.h in | |
406 | *** any of the following: | |
407 | $all_spl_config_locs]) | |
408 | ]) | |
409 | ||
410 | AC_MSG_CHECKING([spl source version]) | |
411 | AS_IF([test -r $splbuild/spl_config.h && | |
412 | fgrep -q SPL_META_VERSION $splbuild/spl_config.h], [ | |
413 | ||
414 | splsrcver=`(echo "#include <spl_config.h>"; | |
415 | echo "splsrcver=SPL_META_VERSION-SPL_META_RELEASE") | | |
416 | cpp -I $splbuild | | |
417 | grep "^splsrcver=" | tr -d \" | cut -d= -f2` | |
418 | ]) | |
419 | ||
420 | AS_IF([test -z "$splsrcver"], [ | |
421 | AC_MSG_RESULT([Not found]) | |
422 | AC_MSG_ERROR([ | |
423 | *** Cannot determine the version of the spl source. | |
424 | *** Please prepare the spl source before running this script]) | |
425 | ]) | |
426 | ||
427 | AC_MSG_RESULT([$splsrcver]) | |
428 | ||
429 | SPL=${splsrc} | |
430 | SPL_OBJ=${splbuild} | |
431 | SPL_VERSION=${splsrcver} | |
432 | ||
433 | AC_SUBST(SPL) | |
434 | AC_SUBST(SPL_OBJ) | |
435 | AC_SUBST(SPL_VERSION) | |
436 | ||
437 | dnl # | |
438 | dnl # Detect the name used for the SPL Module.symvers file. If one | |
439 | dnl # does not exist this is likely because the SPL has been configured | |
440 | dnl # but not built. The '--with-spl-timeout' option can be passed | |
441 | dnl # to pause here, waiting for the file to appear from a concurrently | |
442 | dnl # building SPL package. If the file does not appear in time, a good | |
443 | dnl # guess is made as to what this file will be named based on what it | |
444 | dnl # is named in the kernel build products. This file will first be | |
445 | dnl # used at link time so if the guess is wrong the build will fail | |
446 | dnl # then. This unfortunately means the ZFS package does not contain a | |
447 | dnl # reliable mechanism to detect symbols exported by the SPL at | |
448 | dnl # configure time. | |
449 | dnl # | |
450 | AC_MSG_CHECKING([spl file name for module symbols]) | |
451 | SPL_SYMBOLS=NONE | |
452 | ||
453 | while true; do | |
454 | AS_IF([test -r $SPL_OBJ/Module.symvers], [ | |
455 | SPL_SYMBOLS=Module.symvers | |
456 | ], [test -r $SPL_OBJ/Modules.symvers], [ | |
457 | SPL_SYMBOLS=Modules.symvers | |
458 | ], [test -r $SPL_OBJ/module/Module.symvers], [ | |
459 | SPL_SYMBOLS=Module.symvers | |
460 | ], [test -r $SPL_OBJ/module/Modules.symvers], [ | |
461 | SPL_SYMBOLS=Modules.symvers | |
462 | ]) | |
463 | ||
464 | AS_IF([test $SPL_SYMBOLS != NONE -o $timeout -le 0], [ | |
465 | break; | |
466 | ], [ | |
467 | sleep 1 | |
468 | timeout=$((timeout-1)) | |
469 | ]) | |
470 | done | |
471 | ||
472 | AS_IF([test "$SPL_SYMBOLS" = NONE], [ | |
473 | SPL_SYMBOLS=$LINUX_SYMBOLS | |
474 | ]) | |
475 | ||
476 | AC_MSG_RESULT([$SPL_SYMBOLS]) | |
477 | AC_SUBST(SPL_SYMBOLS) | |
478 | ]) | |
479 | ||
480 | dnl # | |
481 | dnl # Detect the QAT module to be built against | |
482 | dnl # QAT provides hardware acceleration for data compression: | |
483 | dnl # https://01.org/intel-quickassist-technology | |
484 | dnl # * Download and install QAT driver from the above link | |
485 | dnl # * Start QAT driver in your system: | |
486 | dnl # service qat_service start | |
487 | dnl # * Enable QAT in ZFS, e.g.: | |
488 | dnl # ./configure --with-qat=<qat-driver-path>/QAT1.6 | |
489 | dnl # make | |
490 | dnl # * Set GZIP compression in ZFS dataset: | |
491 | dnl # zfs set compression = gzip <dataset> | |
492 | dnl # Then the data written to this ZFS pool is compressed | |
493 | dnl # by QAT accelerator automatically, and de-compressed by | |
494 | dnl # QAT when read from the pool. | |
495 | dnl # * Get QAT hardware statistics by: | |
496 | dnl # cat /proc/icp_dh895xcc_dev/qat | |
497 | dnl # * To disable QAT: | |
498 | dnl # insmod zfs.ko zfs_qat_disable=1 | |
499 | dnl # | |
500 | AC_DEFUN([ZFS_AC_QAT], [ | |
501 | AC_ARG_WITH([qat], | |
502 | AS_HELP_STRING([--with-qat=PATH], | |
503 | [Path to qat source]), | |
504 | AS_IF([test "$withval" = "yes"], | |
505 | AC_MSG_ERROR([--with-qat=PATH requires a PATH]), | |
506 | [qatsrc="$withval"])) | |
507 | ||
508 | AC_ARG_WITH([qat-obj], | |
509 | AS_HELP_STRING([--with-qat-obj=PATH], | |
510 | [Path to qat build objects]), | |
511 | [qatbuild="$withval"]) | |
512 | ||
513 | AS_IF([test ! -z "${qatsrc}"], [ | |
514 | AC_MSG_CHECKING([qat source directory]) | |
515 | AC_MSG_RESULT([$qatsrc]) | |
516 | QAT_SRC="${qatsrc}/quickassist" | |
517 | AS_IF([ test ! -e "$QAT_SRC/include/cpa.h"], [ | |
518 | AC_MSG_ERROR([ | |
519 | *** Please make sure the qat driver package is installed | |
520 | *** and specify the location of the qat source with the | |
521 | *** '--with-qat=PATH' option then try again. Failed to | |
522 | *** find cpa.h in: | |
523 | ${QAT_SRC}/include]) | |
524 | ]) | |
525 | ]) | |
526 | ||
527 | AS_IF([test ! -z "${qatsrc}"], [ | |
528 | AC_MSG_CHECKING([qat build directory]) | |
529 | AS_IF([test -z "$qatbuild"], [ | |
530 | qatbuild="${qatsrc}/build" | |
531 | ]) | |
532 | ||
533 | AC_MSG_RESULT([$qatbuild]) | |
534 | QAT_OBJ=${qatbuild} | |
535 | AS_IF([ ! test -e "$QAT_OBJ/icp_qa_al.ko"], [ | |
536 | AC_MSG_ERROR([ | |
537 | *** Please make sure the qat driver is installed then try again. | |
538 | *** Failed to find icp_qa_al.ko in: | |
539 | $QAT_OBJ]) | |
540 | ]) | |
541 | ||
542 | AC_SUBST(QAT_SRC) | |
543 | AC_SUBST(QAT_OBJ) | |
544 | ||
545 | AC_DEFINE(HAVE_QAT, 1, | |
546 | [qat is enabled and existed]) | |
547 | ]) | |
548 | ||
549 | dnl # | |
550 | dnl # Detect the name used for the QAT Module.symvers file. | |
551 | dnl # | |
552 | AS_IF([test ! -z "${qatsrc}"], [ | |
553 | AC_MSG_CHECKING([qat file for module symbols]) | |
554 | QAT_SYMBOLS=$QAT_SRC/lookaside/access_layer/src/Module.symvers | |
555 | ||
556 | AS_IF([test -r $QAT_SYMBOLS], [ | |
557 | AC_MSG_RESULT([$QAT_SYMBOLS]) | |
558 | AC_SUBST(QAT_SYMBOLS) | |
559 | ],[ | |
560 | AC_MSG_ERROR([ | |
561 | *** Please make sure the qat driver is installed then try again. | |
562 | *** Failed to find Module.symvers in: | |
563 | $QAT_SYMBOLS]) | |
564 | ]) | |
565 | ]) | |
566 | ]) | |
567 | ]) | |
568 | ||
569 | dnl # | |
570 | dnl # Basic toolchain sanity check. | |
571 | dnl # | |
572 | AC_DEFUN([ZFS_AC_TEST_MODULE], [ | |
573 | AC_MSG_CHECKING([whether modules can be built]) | |
574 | ZFS_LINUX_TRY_COMPILE([],[],[ | |
575 | AC_MSG_RESULT([yes]) | |
576 | ],[ | |
577 | AC_MSG_RESULT([no]) | |
578 | if test "x$enable_linux_builtin" != xyes; then | |
579 | AC_MSG_ERROR([*** Unable to build an empty module.]) | |
580 | else | |
581 | AC_MSG_ERROR([ | |
582 | *** Unable to build an empty module. | |
583 | *** Please run 'make scripts' inside the kernel source tree.]) | |
584 | fi | |
585 | ]) | |
586 | ]) | |
587 | ||
588 | dnl # | |
589 | dnl # Certain kernel build options are not supported. These must be | |
590 | dnl # detected at configure time and cause a build failure. Otherwise | |
591 | dnl # modules may be successfully built that behave incorrectly. | |
592 | dnl # | |
593 | AC_DEFUN([ZFS_AC_KERNEL_CONFIG], [ | |
594 | AS_IF([test "x$cross_compiling" != xyes], [ | |
595 | AC_RUN_IFELSE([ | |
596 | AC_LANG_PROGRAM([ | |
597 | #include "$LINUX/include/linux/license.h" | |
598 | ], [ | |
599 | return !license_is_gpl_compatible("$ZFS_META_LICENSE"); | |
600 | ]) | |
601 | ], [ | |
602 | AC_DEFINE([ZFS_IS_GPL_COMPATIBLE], [1], | |
603 | [Define to 1 if GPL-only symbols can be used]) | |
604 | ], [ | |
605 | ]) | |
606 | ]) | |
607 | ||
608 | ZFS_AC_KERNEL_CONFIG_THREAD_SIZE | |
609 | ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC | |
610 | ]) | |
611 | ||
612 | dnl # | |
613 | dnl # Check configured THREAD_SIZE | |
614 | dnl # | |
615 | dnl # The stack size will vary by architecture, but as of Linux 3.15 on x86_64 | |
616 | dnl # the default thread stack size was increased to 16K from 8K. Therefore, | |
617 | dnl # on newer kernels and some architectures stack usage optimizations can be | |
618 | dnl # conditionally applied to improve performance without negatively impacting | |
619 | dnl # stability. | |
620 | dnl # | |
621 | AC_DEFUN([ZFS_AC_KERNEL_CONFIG_THREAD_SIZE], [ | |
622 | AC_MSG_CHECKING([whether kernel was built with 16K or larger stacks]) | |
623 | ZFS_LINUX_TRY_COMPILE([ | |
624 | #include <linux/module.h> | |
625 | ],[ | |
626 | #if (THREAD_SIZE < 16384) | |
627 | #error "THREAD_SIZE is less than 16K" | |
628 | #endif | |
629 | ],[ | |
630 | AC_MSG_RESULT([yes]) | |
631 | AC_DEFINE(HAVE_LARGE_STACKS, 1, [kernel has large stacks]) | |
632 | ],[ | |
633 | AC_MSG_RESULT([no]) | |
634 | ]) | |
635 | ]) | |
636 | ||
637 | dnl # | |
638 | dnl # Check CONFIG_DEBUG_LOCK_ALLOC | |
639 | dnl # | |
640 | dnl # This is typically only set for debug kernels because it comes with | |
641 | dnl # a performance penalty. However, when it is set it maps the non-GPL | |
642 | dnl # symbol mutex_lock() to the GPL-only mutex_lock_nested() symbol. | |
643 | dnl # This will cause a failure at link time which we'd rather know about | |
644 | dnl # at compile time. | |
645 | dnl # | |
646 | dnl # Since we plan to pursue making mutex_lock_nested() a non-GPL symbol | |
647 | dnl # with the upstream community we add a check to detect this case. | |
648 | dnl # | |
649 | AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC], [ | |
650 | ||
651 | ZFS_LINUX_CONFIG([DEBUG_LOCK_ALLOC], [ | |
652 | AC_MSG_CHECKING([whether mutex_lock() is GPL-only]) | |
653 | tmp_flags="$EXTRA_KCFLAGS" | |
654 | ZFS_LINUX_TRY_COMPILE([ | |
655 | #include <linux/module.h> | |
656 | #include <linux/mutex.h> | |
657 | ||
658 | MODULE_LICENSE("$ZFS_META_LICENSE"); | |
659 | ],[ | |
660 | struct mutex lock; | |
661 | ||
662 | mutex_init(&lock); | |
663 | mutex_lock(&lock); | |
664 | mutex_unlock(&lock); | |
665 | ],[ | |
666 | AC_MSG_RESULT(no) | |
667 | ],[ | |
668 | AC_MSG_RESULT(yes) | |
669 | AC_MSG_ERROR([ | |
670 | *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible | |
671 | *** with the CDDL license and will prevent the module linking stage | |
672 | *** from succeeding. You must rebuild your kernel without this | |
673 | *** option enabled.]) | |
674 | ]) | |
675 | EXTRA_KCFLAGS="$tmp_flags" | |
676 | ], []) | |
677 | ]) | |
678 | ||
679 | dnl # | |
680 | dnl # ZFS_LINUX_CONFTEST_H | |
681 | dnl # | |
682 | AC_DEFUN([ZFS_LINUX_CONFTEST_H], [ | |
683 | cat - <<_ACEOF >conftest.h | |
684 | $1 | |
685 | _ACEOF | |
686 | ]) | |
687 | ||
688 | dnl # | |
689 | dnl # ZFS_LINUX_CONFTEST_C | |
690 | dnl # | |
691 | AC_DEFUN([ZFS_LINUX_CONFTEST_C], [ | |
692 | cat confdefs.h - <<_ACEOF >conftest.c | |
693 | $1 | |
694 | _ACEOF | |
695 | ]) | |
696 | ||
697 | dnl # | |
698 | dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY]) | |
699 | dnl # | |
700 | m4_define([ZFS_LANG_PROGRAM], [ | |
701 | $1 | |
702 | int | |
703 | main (void) | |
704 | { | |
705 | dnl Do *not* indent the following line: there may be CPP directives. | |
706 | dnl Don't move the `;' right after for the same reason. | |
707 | $2 | |
708 | ; | |
709 | return 0; | |
710 | } | |
711 | ]) | |
712 | ||
713 | dnl # | |
714 | dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE | |
715 | dnl # | |
716 | AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [ | |
717 | m4_ifvaln([$1], [ZFS_LINUX_CONFTEST_C([$1])]) | |
718 | m4_ifvaln([$6], [ZFS_LINUX_CONFTEST_H([$6])], [ZFS_LINUX_CONFTEST_H([])]) | |
719 | rm -Rf build && mkdir -p build && touch build/conftest.mod.c | |
720 | echo "obj-m := conftest.o" >build/Makefile | |
721 | modpost_flag='' | |
722 | test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage | |
723 | AS_IF( | |
724 | [AC_TRY_COMMAND(cp conftest.c conftest.h build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])], | |
725 | [$4], | |
726 | [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])] | |
727 | ) | |
728 | rm -Rf build | |
729 | ]) | |
730 | ||
731 | dnl # | |
732 | dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE | |
733 | dnl # | |
734 | AC_DEFUN([ZFS_LINUX_TRY_COMPILE], | |
735 | [ZFS_LINUX_COMPILE_IFELSE( | |
736 | [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])], | |
737 | [modules], | |
738 | [test -s build/conftest.o], | |
739 | [$3], [$4]) | |
740 | ]) | |
741 | ||
742 | dnl # | |
743 | dnl # ZFS_LINUX_CONFIG | |
744 | dnl # | |
745 | AC_DEFUN([ZFS_LINUX_CONFIG], | |
746 | [AC_MSG_CHECKING([whether kernel was built with CONFIG_$1]) | |
747 | ZFS_LINUX_TRY_COMPILE([ | |
748 | #include <linux/module.h> | |
749 | ],[ | |
750 | #ifndef CONFIG_$1 | |
751 | #error CONFIG_$1 not #defined | |
752 | #endif | |
753 | ],[ | |
754 | AC_MSG_RESULT([yes]) | |
755 | $2 | |
756 | ],[ | |
757 | AC_MSG_RESULT([no]) | |
758 | $3 | |
759 | ]) | |
760 | ]) | |
761 | ||
762 | dnl # | |
763 | dnl # ZFS_CHECK_SYMBOL_EXPORT | |
764 | dnl # check symbol exported or not | |
765 | dnl # | |
766 | AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [ | |
767 | grep -q -E '[[[:space:]]]$1[[[:space:]]]' \ | |
768 | $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null | |
769 | rc=$? | |
770 | if test $rc -ne 0; then | |
771 | export=0 | |
772 | for file in $2; do | |
773 | grep -q -E "EXPORT_SYMBOL.*($1)" \ | |
774 | "$LINUX/$file" 2>/dev/null | |
775 | rc=$? | |
776 | if test $rc -eq 0; then | |
777 | export=1 | |
778 | break; | |
779 | fi | |
780 | done | |
781 | if test $export -eq 0; then : | |
782 | $4 | |
783 | else : | |
784 | $3 | |
785 | fi | |
786 | else : | |
787 | $3 | |
788 | fi | |
789 | ]) | |
790 | ||
791 | dnl # | |
792 | dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL | |
793 | dnl # like ZFS_LINUX_TRY_COMPILE, except ZFS_CHECK_SYMBOL_EXPORT | |
794 | dnl # is called if not compiling for builtin | |
795 | dnl # | |
796 | AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [ | |
797 | ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1]) | |
798 | if test $rc -ne 0; then : | |
799 | $6 | |
800 | else | |
801 | if test "x$enable_linux_builtin" != xyes; then | |
802 | ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1]) | |
803 | fi | |
804 | if test $rc -ne 0; then : | |
805 | $6 | |
806 | else : | |
807 | $5 | |
808 | fi | |
809 | fi | |
810 | ]) | |
811 | ||
812 | dnl # | |
813 | dnl # ZFS_LINUX_TRY_COMPILE_HEADER | |
814 | dnl # like ZFS_LINUX_TRY_COMPILE, except the contents conftest.h are | |
815 | dnl # provided via the fifth parameter | |
816 | dnl # | |
817 | AC_DEFUN([ZFS_LINUX_TRY_COMPILE_HEADER], | |
818 | [ZFS_LINUX_COMPILE_IFELSE( | |
819 | [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])], | |
820 | [modules], | |
821 | [test -s build/conftest.o], | |
822 | [$3], [$4], [$5]) | |
823 | ]) |