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