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