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