]>
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 | |
7 | ZFS_AC_KERNEL_CONFIG | |
8 | ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS | |
9 | ZFS_AC_KERNEL_TYPE_FMODE_T | |
10 | ZFS_AC_KERNEL_KOBJ_NAME_LEN | |
45066d1f | 11 | ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH |
c9c0d073 BB |
12 | ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE |
13 | ZFS_AC_KERNEL_INVALIDATE_BDEV_ARGS | |
14 | ZFS_AC_KERNEL_BDEV_LOGICAL_BLOCK_SIZE | |
15 | ZFS_AC_KERNEL_BIO_EMPTY_BARRIER | |
2959d94a | 16 | ZFS_AC_KERNEL_BIO_FAILFAST |
f4af6bb7 BB |
17 | ZFS_AC_KERNEL_BIO_FAILFAST_DTD |
18 | ZFS_AC_KERNEL_REQ_FAILFAST_MASK | |
c9c0d073 | 19 | ZFS_AC_KERNEL_BIO_END_IO_T_ARGS |
675de5aa | 20 | ZFS_AC_KERNEL_BIO_RW_SYNC |
c9c0d073 | 21 | ZFS_AC_KERNEL_BIO_RW_SYNCIO |
675de5aa | 22 | ZFS_AC_KERNEL_REQ_SYNC |
c9c0d073 BB |
23 | ZFS_AC_KERNEL_BLK_END_REQUEST |
24 | ZFS_AC_KERNEL_BLK_FETCH_REQUEST | |
25 | ZFS_AC_KERNEL_BLK_REQUEUE_REQUEST | |
26 | ZFS_AC_KERNEL_BLK_RQ_BYTES | |
27 | ZFS_AC_KERNEL_BLK_RQ_POS | |
28 | ZFS_AC_KERNEL_BLK_RQ_SECTORS | |
29 | ZFS_AC_KERNEL_GET_DISK_RO | |
30 | ZFS_AC_KERNEL_RQ_IS_SYNC | |
31 | ZFS_AC_KERNEL_RQ_FOR_EACH_SEGMENT | |
777d4af8 | 32 | ZFS_AC_KERNEL_CONST_XATTR_HANDLER |
f9637c6c BB |
33 | ZFS_AC_KERNEL_XATTR_HANDLER_GET |
34 | ZFS_AC_KERNEL_XATTR_HANDLER_SET | |
7268e1be | 35 | ZFS_AC_KERNEL_FSYNC_2ARGS |
2c395def | 36 | ZFS_AC_KERNEL_EVICT_INODE |
bdf4328b | 37 | ZFS_AC_KERNEL_INSERT_INODE_LOCKED |
055656d4 | 38 | ZFS_AC_KERNEL_D_OBTAIN_ALIAS |
df554c14 | 39 | ZFS_AC_KERNEL_CHECK_DISK_SIZE_CHANGE |
b3129792 | 40 | ZFS_AC_KERNEL_TRUNCATE_SETSIZE |
5c03efc3 | 41 | ZFS_AC_KERNEL_6ARGS_SECURITY_INODE_INIT_SECURITY |
2cf7f52b | 42 | ZFS_AC_KERNEL_MOUNT_NODEV |
76659dc1 | 43 | ZFS_AC_KERNEL_BDI |
c9c0d073 | 44 | |
6283f55e BB |
45 | if test "$LINUX_OBJ" != "$LINUX"; then |
46 | KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" | |
47 | fi | |
48 | AC_SUBST(KERNELMAKE_PARAMS) | |
49 | ||
50 | ||
c9c0d073 BB |
51 | dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other |
52 | dnl # compiler options are added by the kernel build system. | |
8a7e1cee | 53 | KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_UNUSED_BUT_SET_VARIABLE" |
c9c0d073 BB |
54 | KERNELCPPFLAGS="$KERNELCPPFLAGS -DHAVE_SPL -D_KERNEL" |
55 | KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\"" | |
c9c0d073 | 56 | |
c9c0d073 BB |
57 | AC_SUBST(KERNELCPPFLAGS) |
58 | ]) | |
59 | ||
60 | dnl # | |
61 | dnl # Detect name used for Module.symvers file in kernel | |
62 | dnl # | |
63 | AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [ | |
64 | modpost=$LINUX/scripts/Makefile.modpost | |
65 | AC_MSG_CHECKING([kernel file name for module symbols]) | |
66 | if test -f "$modpost"; then | |
67 | if grep -q Modules.symvers $modpost; then | |
68 | LINUX_SYMBOLS=Modules.symvers | |
69 | else | |
70 | LINUX_SYMBOLS=Module.symvers | |
71 | fi | |
a60b1c0a BB |
72 | |
73 | if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then | |
74 | AC_MSG_ERROR([ | |
75 | *** Please make sure the kernel devel package for your distribution | |
76 | *** is installed. If your building with a custom kernel make sure the | |
77 | *** kernel is configured, built, and the '--with-linux=PATH' configure | |
78 | *** option refers to the location of the kernel source.]) | |
79 | fi | |
c9c0d073 BB |
80 | else |
81 | LINUX_SYMBOLS=NONE | |
82 | fi | |
83 | AC_MSG_RESULT($LINUX_SYMBOLS) | |
84 | AC_SUBST(LINUX_SYMBOLS) | |
85 | ]) | |
86 | ||
87 | dnl # | |
88 | dnl # Detect the kernel to be built against | |
89 | dnl # | |
90 | AC_DEFUN([ZFS_AC_KERNEL], [ | |
91 | AC_ARG_WITH([linux], | |
92 | AS_HELP_STRING([--with-linux=PATH], | |
93 | [Path to kernel source]), | |
94 | [kernelsrc="$withval"]) | |
95 | ||
96 | AC_ARG_WITH(linux-obj, | |
97 | AS_HELP_STRING([--with-linux-obj=PATH], | |
98 | [Path to kernel build objects]), | |
99 | [kernelbuild="$withval"]) | |
100 | ||
101 | AC_MSG_CHECKING([kernel source directory]) | |
102 | if test -z "$kernelsrc"; then | |
1b94c25c BB |
103 | if test -e "/lib/modules/$(uname -r)/source"; then |
104 | headersdir="/lib/modules/$(uname -r)/source" | |
105 | sourcelink=$(readlink -f "$headersdir") | |
106 | elif test -e "/lib/modules/$(uname -r)/build"; then | |
107 | headersdir="/lib/modules/$(uname -r)/build" | |
c9c0d073 BB |
108 | sourcelink=$(readlink -f "$headersdir") |
109 | else | |
110 | sourcelink=$(ls -1d /usr/src/kernels/* \ | |
111 | /usr/src/linux-* \ | |
112 | 2>/dev/null | grep -v obj | tail -1) | |
113 | fi | |
114 | ||
115 | if test -n "$sourcelink" && test -e ${sourcelink}; then | |
116 | kernelsrc=`readlink -f ${sourcelink}` | |
117 | else | |
118 | AC_MSG_RESULT([Not found]) | |
119 | AC_MSG_ERROR([ | |
120 | *** Please make sure the kernel devel package for your distribution | |
121 | *** is installed then try again. If that fails you can specify the | |
122 | *** location of the kernel source with the '--with-linux=PATH' option.]) | |
123 | fi | |
124 | else | |
125 | if test "$kernelsrc" = "NONE"; then | |
126 | kernsrcver=NONE | |
127 | fi | |
128 | fi | |
129 | ||
130 | AC_MSG_RESULT([$kernelsrc]) | |
131 | AC_MSG_CHECKING([kernel build directory]) | |
132 | if test -z "$kernelbuild"; then | |
1b94c25c BB |
133 | if test -e "/lib/modules/$(uname -r)/build"; then |
134 | kernelbuild=`readlink -f /lib/modules/$(uname -r)/build` | |
135 | elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then | |
c9c0d073 BB |
136 | kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu} |
137 | elif test -d ${kernelsrc}-obj/${target_cpu}/default; then | |
138 | kernelbuild=${kernelsrc}-obj/${target_cpu}/default | |
139 | elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then | |
140 | kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu} | |
141 | else | |
142 | kernelbuild=${kernelsrc} | |
143 | fi | |
144 | fi | |
145 | AC_MSG_RESULT([$kernelbuild]) | |
146 | ||
147 | AC_MSG_CHECKING([kernel source version]) | |
148 | utsrelease1=$kernelbuild/include/linux/version.h | |
149 | utsrelease2=$kernelbuild/include/linux/utsrelease.h | |
150 | utsrelease3=$kernelbuild/include/generated/utsrelease.h | |
151 | if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then | |
152 | utsrelease=linux/version.h | |
153 | elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then | |
154 | utsrelease=linux/utsrelease.h | |
155 | elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then | |
156 | utsrelease=generated/utsrelease.h | |
157 | fi | |
158 | ||
159 | if test "$utsrelease"; then | |
160 | kernsrcver=`(echo "#include <$utsrelease>"; | |
161 | echo "kernsrcver=UTS_RELEASE") | | |
162 | cpp -I $kernelbuild/include | | |
163 | grep "^kernsrcver=" | cut -d \" -f 2` | |
164 | ||
165 | if test -z "$kernsrcver"; then | |
166 | AC_MSG_RESULT([Not found]) | |
167 | AC_MSG_ERROR([*** Cannot determine kernel version.]) | |
168 | fi | |
169 | else | |
170 | AC_MSG_RESULT([Not found]) | |
171 | AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.]) | |
172 | fi | |
173 | ||
174 | AC_MSG_RESULT([$kernsrcver]) | |
175 | ||
176 | LINUX=${kernelsrc} | |
177 | LINUX_OBJ=${kernelbuild} | |
178 | LINUX_VERSION=${kernsrcver} | |
179 | ||
180 | AC_SUBST(LINUX) | |
181 | AC_SUBST(LINUX_OBJ) | |
182 | AC_SUBST(LINUX_VERSION) | |
183 | ||
184 | ZFS_AC_MODULE_SYMVERS | |
185 | ]) | |
186 | ||
187 | dnl # | |
188 | dnl # Detect name used for the additional SPL Module.symvers file. If one | |
189 | dnl # does not exist this is likely because the SPL has been configured | |
190 | dnl # but not built. To allow recursive builds a good guess is made as to | |
191 | dnl # what this file will be named based on what it is named in the kernel | |
192 | dnl # build products. This file will first be used at link time so if | |
193 | dnl # the guess is wrong the build will fail then. This unfortunately | |
194 | dnl # means the ZFS package does not contain a reliable mechanism to | |
195 | dnl # detect symbols exported by the SPL at configure time. | |
196 | dnl # | |
197 | AC_DEFUN([ZFS_AC_SPL_MODULE_SYMVERS], [ | |
198 | AC_MSG_CHECKING([spl file name for module symbols]) | |
199 | if test -r $SPL_OBJ/Module.symvers; then | |
200 | SPL_SYMBOLS=Module.symvers | |
201 | elif test -r $SPL_OBJ/Modules.symvers; then | |
202 | SPL_SYMBOLS=Modules.symvers | |
6283f55e BB |
203 | elif test -r $SPL_OBJ/module/Module.symvers; then |
204 | SPL_SYMBOLS=Module.symvers | |
205 | elif test -r $SPL_OBJ/module/Modules.symvers; then | |
206 | SPL_SYMBOLS=Modules.symvers | |
c9c0d073 BB |
207 | else |
208 | SPL_SYMBOLS=$LINUX_SYMBOLS | |
209 | fi | |
210 | ||
211 | AC_MSG_RESULT([$SPL_SYMBOLS]) | |
212 | AC_SUBST(SPL_SYMBOLS) | |
213 | ]) | |
214 | ||
215 | dnl # | |
216 | dnl # Detect the SPL module to be built against | |
217 | dnl # | |
218 | AC_DEFUN([ZFS_AC_SPL], [ | |
219 | AC_ARG_WITH([spl], | |
220 | AS_HELP_STRING([--with-spl=PATH], | |
221 | [Path to spl source]), | |
222 | [splsrc="$withval"]) | |
223 | ||
224 | AC_ARG_WITH([spl-obj], | |
225 | AS_HELP_STRING([--with-spl-obj=PATH], | |
226 | [Path to spl build objects]), | |
227 | [splbuild="$withval"]) | |
228 | ||
229 | ||
230 | AC_MSG_CHECKING([spl source directory]) | |
231 | if test -z "$splsrc"; then | |
232 | sourcelink=`ls -1d /usr/src/spl-*/${LINUX_VERSION} \ | |
233 | 2>/dev/null | tail -1` | |
234 | ||
235 | if test -z "$sourcelink" || test ! -e $sourcelink; then | |
236 | sourcelink=../spl | |
237 | fi | |
238 | ||
239 | if test -e $sourcelink; then | |
240 | splsrc=`readlink -f ${sourcelink}` | |
241 | else | |
242 | AC_MSG_RESULT([Not found]) | |
243 | AC_MSG_ERROR([ | |
244 | *** Please make sure the spl devel package for your distribution | |
245 | *** is installed then try again. If that fails you can specify the | |
246 | *** location of the spl source with the '--with-spl=PATH' option.]) | |
247 | fi | |
248 | else | |
249 | if test "$splsrc" = "NONE"; then | |
250 | splbuild=NONE | |
251 | splsrcver=NONE | |
252 | fi | |
253 | fi | |
254 | ||
255 | AC_MSG_RESULT([$splsrc]) | |
256 | AC_MSG_CHECKING([spl build directory]) | |
257 | if test -z "$splbuild"; then | |
6283f55e | 258 | splbuild=${splsrc} |
c9c0d073 BB |
259 | fi |
260 | AC_MSG_RESULT([$splbuild]) | |
261 | ||
262 | AC_MSG_CHECKING([spl source version]) | |
5e612145 BB |
263 | if test -r $splbuild/spl_config.h && |
264 | fgrep -q SPL_META_VERSION $splbuild/spl_config.h; then | |
c9c0d073 BB |
265 | |
266 | splsrcver=`(echo "#include <spl_config.h>"; | |
267 | echo "splsrcver=SPL_META_VERSION") | | |
5e612145 | 268 | cpp -I $splbuild | |
c9c0d073 BB |
269 | grep "^splsrcver=" | cut -d \" -f 2` |
270 | fi | |
271 | ||
272 | if test -z "$splsrcver"; then | |
273 | AC_MSG_RESULT([Not found]) | |
274 | AC_MSG_ERROR([ | |
275 | *** Cannot determine the version of the spl source. | |
276 | *** Please prepare the spl source before running this script]) | |
277 | fi | |
278 | ||
279 | AC_MSG_RESULT([$splsrcver]) | |
280 | ||
281 | SPL=${splsrc} | |
282 | SPL_OBJ=${splbuild} | |
283 | SPL_VERSION=${splsrcver} | |
284 | ||
285 | AC_SUBST(SPL) | |
286 | AC_SUBST(SPL_OBJ) | |
287 | AC_SUBST(SPL_VERSION) | |
288 | ||
289 | ZFS_AC_SPL_MODULE_SYMVERS | |
290 | ]) | |
291 | ||
15805c77 BB |
292 | dnl # |
293 | dnl # Certain kernel build options are not supported. These must be | |
294 | dnl # detected at configure time and cause a build failure. Otherwise | |
295 | dnl # modules may be successfully built that behave incorrectly. | |
296 | dnl # | |
297 | dnl # CONFIG_PREEMPT - Preempt kernels require special handling. | |
c9c0d073 BB |
298 | dnl # |
299 | dnl # There are certain kernel build options which when enabled are | |
300 | dnl # completely incompatible with non GPL kernel modules. It is best | |
301 | dnl # to detect these at configure time and fail with a clear error | |
302 | dnl # rather than build everything and fail during linking. | |
303 | dnl # | |
304 | dnl # CONFIG_DEBUG_LOCK_ALLOC - Maps mutex_lock() to mutex_lock_nested() | |
305 | dnl # | |
306 | AC_DEFUN([ZFS_AC_KERNEL_CONFIG], [ | |
307 | ||
15805c77 BB |
308 | ZFS_LINUX_CONFIG([PREEMPT], |
309 | AC_MSG_ERROR([ | |
310 | *** Kernel built with CONFIG_PREEMPT which is not supported. | |
311 | ** You must rebuild your kernel without this option.]), []) | |
312 | ||
c9c0d073 BB |
313 | if test "$ZFS_META_LICENSE" = CDDL; then |
314 | ZFS_LINUX_CONFIG([DEBUG_LOCK_ALLOC], | |
315 | AC_MSG_ERROR([ | |
316 | *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is | |
317 | *** incompatible with the CDDL license. You must rebuild | |
318 | *** your kernel without this option.]), []) | |
319 | fi | |
320 | ||
321 | if test "$ZFS_META_LICENSE" = GPL; then | |
322 | AC_DEFINE([HAVE_GPL_ONLY_SYMBOLS], [1], | |
323 | [Define to 1 if licensed under the GPL]) | |
324 | fi | |
325 | ]) | |
326 | ||
327 | dnl # | |
328 | dnl # ZFS_LINUX_CONFTEST | |
329 | dnl # | |
330 | AC_DEFUN([ZFS_LINUX_CONFTEST], [ | |
331 | cat confdefs.h - <<_ACEOF >conftest.c | |
332 | $1 | |
333 | _ACEOF | |
334 | ]) | |
335 | ||
336 | dnl # | |
337 | dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY]) | |
338 | dnl # | |
339 | m4_define([ZFS_LANG_PROGRAM], [ | |
340 | $1 | |
341 | int | |
342 | main (void) | |
343 | { | |
344 | dnl Do *not* indent the following line: there may be CPP directives. | |
345 | dnl Don't move the `;' right after for the same reason. | |
346 | $2 | |
347 | ; | |
348 | return 0; | |
349 | } | |
350 | ]) | |
351 | ||
352 | dnl # | |
353 | dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE | |
354 | dnl # | |
355 | AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [ | |
356 | m4_ifvaln([$1], [ZFS_LINUX_CONFTEST([$1])]) | |
357 | rm -Rf build && mkdir -p build | |
358 | echo "obj-m := conftest.o" >build/Makefile | |
359 | AS_IF( | |
360 | [AC_TRY_COMMAND(cp conftest.c build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])], | |
361 | [$4], | |
362 | [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])] | |
363 | ) | |
364 | rm -Rf build | |
365 | ]) | |
366 | ||
367 | dnl # | |
368 | dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE | |
369 | dnl # | |
370 | AC_DEFUN([ZFS_LINUX_TRY_COMPILE], | |
371 | [ZFS_LINUX_COMPILE_IFELSE( | |
372 | [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])], | |
373 | [modules], | |
374 | [test -s build/conftest.o], | |
375 | [$3], [$4]) | |
376 | ]) | |
377 | ||
378 | dnl # | |
379 | dnl # ZFS_LINUX_CONFIG | |
380 | dnl # | |
381 | AC_DEFUN([ZFS_LINUX_CONFIG], | |
382 | [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1]) | |
383 | ZFS_LINUX_TRY_COMPILE([ | |
0da78696 | 384 | #include <linux/module.h> |
c9c0d073 BB |
385 | ],[ |
386 | #ifndef CONFIG_$1 | |
387 | #error CONFIG_$1 not #defined | |
388 | #endif | |
389 | ],[ | |
390 | AC_MSG_RESULT([yes]) | |
391 | $2 | |
392 | ],[ | |
393 | AC_MSG_RESULT([no]) | |
394 | $3 | |
395 | ]) | |
396 | ]) | |
397 | ||
398 | dnl # | |
399 | dnl # ZFS_CHECK_SYMBOL_EXPORT | |
400 | dnl # check symbol exported or not | |
401 | dnl # | |
402 | AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], | |
403 | [AC_MSG_CHECKING([whether symbol $1 is exported]) | |
404 | grep -q -E '[[[:space:]]]$1[[[:space:]]]' \ | |
405 | $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null | |
406 | rc=$? | |
407 | if test $rc -ne 0; then | |
408 | export=0 | |
409 | for file in $2; do | |
410 | grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX/$file" 2>/dev/null | |
411 | rc=$? | |
412 | if test $rc -eq 0; then | |
413 | export=1 | |
414 | break; | |
415 | fi | |
416 | done | |
417 | if test $export -eq 0; then | |
418 | AC_MSG_RESULT([no]) | |
419 | $4 | |
420 | else | |
421 | AC_MSG_RESULT([yes]) | |
422 | $3 | |
423 | fi | |
424 | else | |
425 | AC_MSG_RESULT([yes]) | |
426 | $3 | |
427 | fi | |
428 | ]) |