]> git.proxmox.com Git - mirror_spl-debian.git/blob - config/spl-build.m4
Remove LINUXINCLUDE from autoconf wrapper, breaks 2.6.28+ kernels.
[mirror_spl-debian.git] / config / spl-build.m4
1 dnl #
2 dnl # Default SPL kernel configuration
3 dnl #
4 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
5 SPL_AC_KERNEL
6
7 dnl # Kernel build make options
8 dnl # KERNELMAKE_PARAMS="V=1" # Enable verbose module build
9 KERNELMAKE_PARAMS="V=1"
10
11 dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
12 dnl # compiler options are added by the kernel build system.
13 abs_srcdir=`readlink -f ${srcdir}`
14 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes -Werror"
15 KERNELCPPFLAGS="$KERNELCPPFLAGS -I${abs_srcdir} -I${abs_srcdir}/include"
16
17 if test "${LINUX_OBJ}" != "${LINUX}"; then
18 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
19 fi
20
21 AC_SUBST(KERNELMAKE_PARAMS)
22 AC_SUBST(KERNELCPPFLAGS)
23
24 SPL_AC_DEBUG
25 SPL_AC_DEBUG_KMEM
26 SPL_AC_DEBUG_MUTEX
27 SPL_AC_DEBUG_KSTAT
28 SPL_AC_DEBUG_CALLB
29 SPL_AC_TYPE_UINTPTR_T
30 SPL_AC_TYPE_ATOMIC64_T
31 SPL_AC_3ARGS_INIT_WORK
32 SPL_AC_2ARGS_REGISTER_SYSCTL
33 SPL_AC_SET_SHRINKER
34 SPL_AC_PATH_IN_NAMEIDATA
35 SPL_AC_TASK_CURR
36 SPL_AC_CTL_UNNUMBERED
37 SPL_AC_FLS64
38 SPL_AC_DEVICE_CREATE
39 SPL_AC_5ARGS_DEVICE_CREATE
40 SPL_AC_CLASS_DEVICE_CREATE
41 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
42 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
43 SPL_AC_TIMESPEC_SUB
44 SPL_AC_INIT_UTSNAME
45 SPL_AC_FDTABLE_HEADER
46 SPL_AC_FILES_FDTABLE
47 SPL_AC_UACCESS_HEADER
48 SPL_AC_KMALLOC_NODE
49 SPL_AC_MONOTONIC_CLOCK
50 SPL_AC_INODE_I_MUTEX
51 SPL_AC_MUTEX_LOCK_NESTED
52 SPL_AC_DIV64_64
53 SPL_AC_DIV64_U64
54 SPL_AC_3ARGS_ON_EACH_CPU
55 SPL_AC_KALLSYMS_LOOKUP_NAME
56 SPL_AC_GET_VMALLOC_INFO
57 SPL_AC_PGDAT_HELPERS
58 SPL_AC_FIRST_ONLINE_PGDAT
59 SPL_AC_NEXT_ONLINE_PGDAT
60 SPL_AC_NEXT_ZONE
61 SPL_AC_PGDAT_LIST
62 SPL_AC_GET_ZONE_COUNTS
63 SPL_AC_GLOBAL_PAGE_STATE
64 SPL_AC_ZONE_STAT_ITEM_FIA
65 SPL_AC_2ARGS_VFS_UNLINK
66 SPL_AC_4ARGS_VFS_RENAME
67 ])
68
69 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
70 modpost=$LINUX/scripts/Makefile.modpost
71 AC_MSG_CHECKING([kernel file name for module symbols])
72 if test -f "$modpost"; then
73 if grep -q Modules.symvers $modpost; then
74 LINUX_SYMBOLS=Modules.symvers
75 else
76 LINUX_SYMBOLS=Module.symvers
77 fi
78 else
79 LINUX_SYMBOLS=NONE
80 fi
81 AC_MSG_RESULT($LINUX_SYMBOLS)
82 AC_SUBST(LINUX_SYMBOLS)
83 ])
84
85 AC_DEFUN([SPL_AC_KERNEL], [
86 AC_ARG_WITH([linux],
87 AS_HELP_STRING([--with-linux=PATH],
88 [Path to kernel source]),
89 [kernelsrc="$withval"])
90
91 AC_ARG_WITH([linux-obj],
92 AS_HELP_STRING([--with-linux-obj=PATH],
93 [Path to kernel build objects]),
94 [kernelbuild="$withval"])
95
96 AC_MSG_CHECKING([kernel source directory])
97 if test -z "$kernelsrc"; then
98 sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \
99 2>/dev/null | grep -v obj | tail -1`
100
101 if test -e ${sourcelink}; then
102 kernelsrc=`readlink -f ${sourcelink}`
103 else
104 AC_MSG_RESULT([Not found])
105 AC_MSG_ERROR([
106 *** Please specify the location of the kernel source
107 *** with the '--with-linux=PATH' option])
108 fi
109 else
110 if test "$kernelsrc" = "NONE"; then
111 kernsrcver=NONE
112 fi
113 fi
114
115 AC_MSG_RESULT([$kernelsrc])
116 AC_MSG_CHECKING([kernel build directory])
117 if test -z "$kernelbuild"; then
118 if test -d ${kernelsrc}-obj/`arch`/`arch`; then
119 kernelbuild=${kernelsrc}-obj/`arch`/`arch`
120 elif test -d ${kernelsrc}-obj/`arch`/default; then
121 kernelbuild=${kernelsrc}-obj/`arch`/default
122 elif test -d `dirname ${kernelsrc}`/build-`arch`; then
123 kernelbuild=`dirname ${kernelsrc}`/build-`arch`
124 else
125 kernelbuild=${kernelsrc}
126 fi
127 fi
128 AC_MSG_RESULT([$kernelbuild])
129
130 AC_MSG_CHECKING([kernel source version])
131 if test -r $kernelbuild/include/linux/version.h &&
132 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
133
134 kernsrcver=`(echo "#include <linux/version.h>";
135 echo "kernsrcver=UTS_RELEASE") |
136 cpp -I $kernelbuild/include |
137 grep "^kernsrcver=" | cut -d \" -f 2`
138
139 elif test -r $kernelbuild/include/linux/utsrelease.h &&
140 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
141
142 kernsrcver=`(echo "#include <linux/utsrelease.h>";
143 echo "kernsrcver=UTS_RELEASE") |
144 cpp -I $kernelbuild/include |
145 grep "^kernsrcver=" | cut -d \" -f 2`
146 fi
147
148 if test -z "$kernsrcver"; then
149 AC_MSG_RESULT([Not found])
150 AC_MSG_ERROR([
151 *** Cannot determine the version of the linux kernel source.
152 *** Please prepare the kernel before running this script])
153 fi
154
155 AC_MSG_RESULT([$kernsrcver])
156
157 LINUX=${kernelsrc}
158 LINUX_OBJ=${kernelbuild}
159 LINUX_VERSION=${kernsrcver}
160
161 AC_SUBST(LINUX)
162 AC_SUBST(LINUX_OBJ)
163 AC_SUBST(LINUX_VERSION)
164
165 SPL_AC_MODULE_SYMVERS
166 ])
167
168 dnl #
169 dnl # Default SPL user configuration
170 dnl #
171 AC_DEFUN([SPL_AC_CONFIG_USER], [])
172
173 AC_DEFUN([SPL_AC_LICENSE], [
174 AC_MSG_CHECKING([spl license])
175 LICENSE=GPL
176 AC_MSG_RESULT([$LICENSE])
177 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
178 AC_SUBST(LICENSE)
179 ])
180
181 AC_DEFUN([SPL_AC_CONFIG], [
182 SPL_CONFIG=all
183 AC_ARG_WITH([config],
184 AS_HELP_STRING([--with-config=CONFIG],
185 [Config file 'kernel|user|all']),
186 [SPL_CONFIG="$withval"])
187
188 AC_MSG_CHECKING([spl config])
189 AC_MSG_RESULT([$SPL_CONFIG]);
190 AC_SUBST(SPL_CONFIG)
191
192 case "$SPL_CONFIG" in
193 kernel) SPL_AC_CONFIG_KERNEL ;;
194 user) SPL_AC_CONFIG_USER ;;
195 all) SPL_AC_CONFIG_KERNEL
196 SPL_AC_CONFIG_USER ;;
197 *)
198 AC_MSG_RESULT([Error!])
199 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
200 user kernel|user|all]) ;;
201 esac
202
203 AM_CONDITIONAL([CONFIG_USER],
204 [test "$SPL_CONFIG" = user] ||
205 [test "$SPL_CONFIG" = all])
206 AM_CONDITIONAL([CONFIG_KERNEL],
207 [test "$SPL_CONFIG" = kernel] ||
208 [test "$SPL_CONFIG" = all])
209 ])
210
211 AC_DEFUN([SPL_AC_DEBUG], [
212 AC_MSG_CHECKING([whether debugging is enabled])
213 AC_ARG_ENABLE( [debug],
214 AS_HELP_STRING([--enable-debug],
215 [Enable generic debug support (default off)]),
216 [ case "$enableval" in
217 yes) spl_ac_debug=yes ;;
218 no) spl_ac_debug=no ;;
219 *) AC_MSG_RESULT([Error!])
220 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
221 esac ]
222 )
223 if test "$spl_ac_debug" = yes; then
224 AC_MSG_RESULT([yes])
225 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"
226 else
227 AC_MSG_RESULT([no])
228 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
229 fi
230 ])
231
232 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
233 AC_MSG_CHECKING([whether kmem debugging is enabled])
234 AC_ARG_ENABLE( [debug-kmem],
235 AS_HELP_STRING([--enable-debug-kmem],
236 [Enable kmem debug support (default off)]),
237 [ case "$enableval" in
238 yes) spl_ac_debug_kmem=yes ;;
239 no) spl_ac_debug_kmem=no ;;
240 *) AC_MSG_RESULT([Error!])
241 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;;
242 esac ]
243 )
244 if test "$spl_ac_debug_kmem" = yes; then
245 AC_MSG_RESULT([yes])
246 AC_DEFINE([DEBUG_KMEM], [1],
247 [Define to 1 to enable kmem debugging])
248 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
249 else
250 AC_MSG_RESULT([no])
251 fi
252 ])
253
254 AC_DEFUN([SPL_AC_DEBUG_MUTEX], [
255 AC_MSG_CHECKING([whether mutex debugging is enabled])
256 AC_ARG_ENABLE( [debug-mutex],
257 AS_HELP_STRING([--enable-debug-mutex],
258 [Enable mutex debug support (default off)]),
259 [ case "$enableval" in
260 yes) spl_ac_debug_mutex=yes ;;
261 no) spl_ac_debug_mutex=no ;;
262 *) AC_MSG_RESULT([Error!])
263 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;;
264 esac ]
265 )
266 if test "$spl_ac_debug_mutex" = yes; then
267 AC_MSG_RESULT([yes])
268 AC_DEFINE([DEBUG_MUTEX], [1],
269 [Define to 1 to enable mutex debugging])
270 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX"
271 else
272 AC_MSG_RESULT([no])
273 fi
274 ])
275
276 AC_DEFUN([SPL_AC_DEBUG_KSTAT], [
277 AC_MSG_CHECKING([whether kstat debugging is enabled])
278 AC_ARG_ENABLE( [debug-kstat],
279 AS_HELP_STRING([--enable-debug-kstat],
280 [Enable kstat debug support (default off)]),
281 [ case "$enableval" in
282 yes) spl_ac_debug_kstat=yes ;;
283 no) spl_ac_debug_kstat=no ;;
284 *) AC_MSG_RESULT([Error!])
285 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;;
286 esac ]
287 )
288 if test "$spl_ac_debug_kstat" = yes; then
289 AC_MSG_RESULT([yes])
290 AC_DEFINE([DEBUG_KSTAT], [1],
291 [Define to 1 to enable kstat debugging])
292 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT"
293 else
294 AC_MSG_RESULT([no])
295 fi
296 ])
297
298 AC_DEFUN([SPL_AC_DEBUG_CALLB], [
299 AC_MSG_CHECKING([whether callb debugging is enabled])
300 AC_ARG_ENABLE( [debug-callb],
301 AS_HELP_STRING([--enable-debug-callb],
302 [Enable callb debug support (default off)]),
303 [ case "$enableval" in
304 yes) spl_ac_debug_callb=yes ;;
305 no) spl_ac_debug_callb=no ;;
306 *) AC_MSG_RESULT([Error!])
307 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;;
308 esac ]
309 )
310 if test "$spl_ac_debug_callb" = yes; then
311 AC_MSG_RESULT([yes])
312 AC_DEFINE([DEBUG_CALLB], [1],
313 [Define to 1 to enable callb debugging])
314 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB"
315 else
316 AC_MSG_RESULT([no])
317 fi
318 ])
319
320 dnl #
321 dnl # SPL_LINUX_CONFTEST
322 dnl #
323 AC_DEFUN([SPL_LINUX_CONFTEST], [
324 cat >conftest.c <<_ACEOF
325 $1
326 _ACEOF
327 ])
328
329 dnl #
330 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
331 dnl #
332 m4_define([SPL_LANG_PROGRAM], [
333 $1
334 int
335 main (void)
336 {
337 dnl Do *not* indent the following line: there may be CPP directives.
338 dnl Don't move the `;' right after for the same reason.
339 $2
340 ;
341 return 0;
342 }
343 ])
344
345 dnl #
346 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
347 dnl #
348 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
349 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
350 rm -Rf build && mkdir -p build
351 echo "obj-m := conftest.o" >build/Makefile
352 AS_IF(
353 [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])],
354 [$4],
355 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
356 )
357 rm -Rf build
358 ])
359
360 dnl #
361 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
362 dnl #
363 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
364 [SPL_LINUX_COMPILE_IFELSE(
365 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
366 [modules],
367 [test -s build/conftest.o],
368 [$3], [$4])
369 ])
370
371 dnl #
372 dnl # SPL_LINUX_CONFIG
373 dnl #
374 AC_DEFUN([SPL_LINUX_CONFIG],
375 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
376 SPL_LINUX_TRY_COMPILE([
377 #ifndef AUTOCONF_INCLUDED
378 #include <linux/config.h>
379 #endif
380 ],[
381 #ifndef CONFIG_$1
382 #error CONFIG_$1 not #defined
383 #endif
384 ],[
385 AC_MSG_RESULT([yes])
386 $2
387 ],[
388 AC_MSG_RESULT([no])
389 $3
390 ])
391 ])
392
393 dnl #
394 dnl # SPL_CHECK_SYMBOL_EXPORT
395 dnl # check symbol exported or not
396 dnl #
397 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
398 [AC_MSG_CHECKING([whether symbol $1 is exported])
399 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
400 $LINUX_OBJ/Module*.symvers 2>/dev/null
401 rc=$?
402 if test $rc -ne 0; then
403 export=0
404 for file in $2; do
405 grep -q -E "EXPORT_SYMBOL.*($1)" \
406 "$LINUX_OBJ/$file" 2>/dev/null
407 rc=$?
408 if test $rc -eq 0; then
409 export=1
410 break;
411 fi
412 done
413 if test $export -eq 0; then
414 AC_MSG_RESULT([no])
415 $4
416 else
417 AC_MSG_RESULT([yes])
418 $3
419 fi
420 else
421 AC_MSG_RESULT([yes])
422 $3
423 fi
424 ])
425
426 dnl #
427 dnl # SPL_CHECK_HEADER
428 dnl # check whether header exists and define HAVE_$2_HEADER
429 dnl #
430 AC_DEFUN([SPL_CHECK_HEADER],
431 [AC_MSG_CHECKING([whether header $1 exists])
432 SPL_LINUX_TRY_COMPILE([
433 #include <$1>
434 ],[
435 return 0;
436 ],[
437 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
438 AC_MSG_RESULT(yes)
439 $3
440 ],[
441 AC_MSG_RESULT(no)
442 $4
443 ])
444 ])
445
446 dnl #
447 dnl # 2.6.24 API change,
448 dnl # check if uintptr_t typedef is defined
449 dnl #
450 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
451 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
452 SPL_LINUX_TRY_COMPILE([
453 #include <linux/types.h>
454 ],[
455 uintptr_t *ptr;
456 ],[
457 AC_MSG_RESULT([yes])
458 AC_DEFINE(HAVE_UINTPTR_T, 1,
459 [kernel defines uintptr_t])
460 ],[
461 AC_MSG_RESULT([no])
462 ])
463 ])
464
465 dnl #
466 dnl # 2.6.x API change,
467 dnl # check if atomic64_t typedef is defined
468 dnl #
469 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_T],
470 [AC_MSG_CHECKING([whether kernel defines atomic64_t])
471 SPL_LINUX_TRY_COMPILE([
472 #include <asm/atomic.h>
473 ],[
474 atomic64_t *ptr;
475 ],[
476 AC_MSG_RESULT([yes])
477 AC_DEFINE(HAVE_ATOMIC64_T, 1,
478 [kernel defines atomic64_t])
479 ],[
480 AC_MSG_RESULT([no])
481 ])
482 ])
483
484 dnl #
485 dnl # 2.6.20 API change,
486 dnl # INIT_WORK use 2 args and not store data inside
487 dnl #
488 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
489 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
490 SPL_LINUX_TRY_COMPILE([
491 #include <linux/workqueue.h>
492 ],[
493 struct work_struct work;
494 INIT_WORK(&work, NULL, NULL);
495 ],[
496 AC_MSG_RESULT(yes)
497 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
498 [INIT_WORK wants 3 args])
499 ],[
500 AC_MSG_RESULT(no)
501 ])
502 ])
503
504 dnl #
505 dnl # 2.6.21 API change,
506 dnl # 'register_sysctl_table' use only one argument instead of two
507 dnl #
508 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
509 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
510 SPL_LINUX_TRY_COMPILE([
511 #include <linux/sysctl.h>
512 ],[
513 return register_sysctl_table(NULL,0);
514 ],[
515 AC_MSG_RESULT(yes)
516 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
517 [register_sysctl_table() wants 2 args])
518 ],[
519 AC_MSG_RESULT(no)
520 ])
521 ])
522
523 dnl #
524 dnl # 2.6.23 API change
525 dnl # Old set_shrinker API replaced with register_shrinker
526 dnl #
527 AC_DEFUN([SPL_AC_SET_SHRINKER], [
528 AC_MSG_CHECKING([whether set_shrinker() available])
529 SPL_LINUX_TRY_COMPILE([
530 #include <linux/mm.h>
531 ],[
532 return set_shrinker(DEFAULT_SEEKS, NULL);
533 ],[
534 AC_MSG_RESULT([yes])
535 AC_DEFINE(HAVE_SET_SHRINKER, 1,
536 [set_shrinker() available])
537 ],[
538 AC_MSG_RESULT([no])
539 ])
540 ])
541
542 dnl #
543 dnl # 2.6.25 API change,
544 dnl # struct path entry added to struct nameidata
545 dnl #
546 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
547 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
548 SPL_LINUX_TRY_COMPILE([
549 #include <linux/namei.h>
550 ],[
551 struct nameidata nd;
552
553 nd.path.mnt = NULL;
554 nd.path.dentry = NULL;
555 ],[
556 AC_MSG_RESULT(yes)
557 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
558 [struct path used in struct nameidata])
559 ],[
560 AC_MSG_RESULT(no)
561 ])
562 ])
563
564 dnl #
565 dnl # Custom SPL patch may export this system it is not required
566 dnl #
567 AC_DEFUN([SPL_AC_TASK_CURR], [
568 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
569 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
570 [])
571 ])
572
573 dnl #
574 dnl # 2.6.19 API change,
575 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
576 dnl #
577 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
578 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
579 SPL_LINUX_TRY_COMPILE([
580 #include <linux/sysctl.h>
581 ],[
582 #ifndef CTL_UNNUMBERED
583 #error CTL_UNNUMBERED undefined
584 #endif
585 ],[
586 AC_MSG_RESULT(yes)
587 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
588 [unnumbered sysctl support exists])
589 ],[
590 AC_MSG_RESULT(no)
591 ])
592 ])
593
594 dnl #
595 dnl # 2.6.16 API change.
596 dnl # Check if 'fls64()' is available
597 dnl #
598 AC_DEFUN([SPL_AC_FLS64],
599 [AC_MSG_CHECKING([whether fls64() is available])
600 SPL_LINUX_TRY_COMPILE([
601 #include <linux/bitops.h>
602 ],[
603 return fls64(0);
604 ],[
605 AC_MSG_RESULT(yes)
606 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
607 ],[
608 AC_MSG_RESULT(no)
609 ])
610 ])
611
612 dnl #
613 dnl # 2.6.18 API change, check whether device_create() is available.
614 dnl # Device_create() was introduced in 2.6.18 and depricated
615 dnl # class_device_create() which was fully removed in 2.6.26.
616 dnl #
617 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
618 SPL_CHECK_SYMBOL_EXPORT(
619 [device_create],
620 [drivers/base/core.c],
621 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
622 [device_create() is available])],
623 [])
624 ])
625
626 dnl #
627 dnl # 2.6.27 API change,
628 dnl # device_create() uses 5 args, new 'drvdata' argument.
629 dnl #
630 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
631 AC_MSG_CHECKING([whether device_create() wants 5 args])
632 tmp_flags="$EXTRA_KCFLAGS"
633 EXTRA_KCFLAGS="-Werror"
634 SPL_LINUX_TRY_COMPILE([
635 #include <linux/device.h>
636 ],[
637 device_create(NULL, NULL, 0, NULL, "%d", 1);
638 ],[
639 AC_MSG_RESULT(yes)
640 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
641 [device_create wants 5 args])
642 ],[
643 AC_MSG_RESULT(no)
644 ])
645 EXTRA_KCFLAGS="$tmp_flags"
646 ])
647
648 dnl #
649 dnl # 2.6.13 API change, check whether class_device_create() is available.
650 dnl # Class_device_create() was introduced in 2.6.13 and depricated
651 dnl # class_simple_device_add() which was fully removed in 2.6.13.
652 dnl #
653 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
654 SPL_CHECK_SYMBOL_EXPORT(
655 [class_device_create],
656 [drivers/base/class.c],
657 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
658 [class_device_create() is available])],
659 [])
660 ])
661
662 dnl #
663 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
664 dnl #
665 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
666 SPL_CHECK_SYMBOL_EXPORT(
667 [set_normalized_timespec],
668 [kernel/time.c],
669 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
670 [set_normalized_timespec() is available as export])],
671 [])
672 ])
673
674 dnl #
675 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
676 dnl # previously it was available in time.h as an inline.
677 dnl #
678 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
679 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
680 SPL_LINUX_TRY_COMPILE([
681 #include <linux/time.h>
682 void set_normalized_timespec(struct timespec *ts,
683 time_t sec, long nsec) { }
684 ],
685 [],
686 [
687 AC_MSG_RESULT(no)
688 ],[
689 AC_MSG_RESULT(yes)
690 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
691 [set_normalized_timespec() is available as inline])
692 ])
693 ])
694
695 dnl #
696 dnl # 2.6.18 API change,
697 dnl # timespec_sub() inline function available in linux/time.h
698 dnl #
699 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
700 AC_MSG_CHECKING([whether timespec_sub() is available])
701 SPL_LINUX_TRY_COMPILE([
702 #include <linux/time.h>
703 ],[
704 struct timespec a, b, c = { 0 };
705 c = timespec_sub(a, b);
706 ],[
707 AC_MSG_RESULT(yes)
708 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
709 ],[
710 AC_MSG_RESULT(no)
711 ])
712 ])
713
714 dnl #
715 dnl # 2.6.19 API change,
716 dnl # check if init_utsname() is available in linux/utsname.h
717 dnl #
718 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
719 AC_MSG_CHECKING([whether init_utsname() is available])
720 SPL_LINUX_TRY_COMPILE([
721 #include <linux/utsname.h>
722 ],[
723 struct new_utsname *a = init_utsname();
724 ],[
725 AC_MSG_RESULT(yes)
726 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
727 ],[
728 AC_MSG_RESULT(no)
729 ])
730 ])
731
732 dnl #
733 dnl # 2.6.26 API change,
734 dnl # definition of struct fdtable relocated to linux/fdtable.h
735 dnl #
736 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
737 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
738 ])
739
740 dnl #
741 dnl # 2.6.14 API change,
742 dnl # check whether 'files_fdtable()' exists
743 dnl #
744 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
745 AC_MSG_CHECKING([whether files_fdtable() is available])
746 SPL_LINUX_TRY_COMPILE([
747 #include <linux/sched.h>
748 #include <linux/file.h>
749 #ifdef HAVE_FDTABLE_HEADER
750 #include <linux/fdtable.h>
751 #endif
752 ],[
753 struct files_struct *files = current->files;
754 struct fdtable *fdt = files_fdtable(files);
755 ],[
756 AC_MSG_RESULT(yes)
757 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
758 ],[
759 AC_MSG_RESULT(no)
760 ])
761 ])
762
763 dnl #
764 dnl # 2.6.18 API change,
765 dnl # added linux/uaccess.h
766 dnl #
767 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
768 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
769 ])
770
771 dnl #
772 dnl # 2.6.12 API change,
773 dnl # check whether 'kmalloc_node()' is available.
774 dnl #
775 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
776 AC_MSG_CHECKING([whether kmalloc_node() is available])
777 SPL_LINUX_TRY_COMPILE([
778 #include <linux/slab.h>
779 ],[
780 void *a = kmalloc_node(1, GFP_KERNEL, 0);
781 ],[
782 AC_MSG_RESULT(yes)
783 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
784 ],[
785 AC_MSG_RESULT(no)
786 ])
787 ])
788
789 dnl #
790 dnl # 2.6.9 API change,
791 dnl # check whether 'monotonic_clock()' is available it may
792 dnl # be available for some archs but not others.
793 dnl #
794 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
795 SPL_CHECK_SYMBOL_EXPORT(
796 [monotonic_clock],
797 [],
798 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
799 [monotonic_clock() is available])],
800 [])
801 ])
802
803 dnl #
804 dnl # 2.6.16 API change,
805 dnl # check whether 'struct inode' has i_mutex
806 dnl #
807 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
808 AC_MSG_CHECKING([whether struct inode has i_mutex])
809 SPL_LINUX_TRY_COMPILE([
810 #include <linux/fs.h>
811 #include <linux/mutex.h>
812 ],[
813 struct inode i;
814 mutex_init(&i.i_mutex);
815 ],[
816 AC_MSG_RESULT(yes)
817 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
818 ],[
819 AC_MSG_RESULT(no)
820 ])
821 ])
822
823 dnl #
824 dnl # 2.6.18 API change,
825 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
826 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
827 dnl # if the mutex validator is disabled or otherwise unavailable.
828 dnl #
829 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
830 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
831 SPL_LINUX_TRY_COMPILE([
832 #include <linux/mutex.h>
833 ],[
834 struct mutex mutex;
835 mutex_init(&mutex);
836 mutex_lock_nested(&mutex, 0);
837 ],[
838 AC_MSG_RESULT(yes)
839 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
840 [mutex_lock_nested() is available])
841 ],[
842 AC_MSG_RESULT(no)
843 ])
844 ])
845
846 dnl #
847 dnl # 2.6.22 API change,
848 dnl # First introduced 'div64_64()' in lib/div64.c
849 dnl
850 AC_DEFUN([SPL_AC_DIV64_64], [
851 SPL_CHECK_SYMBOL_EXPORT(
852 [div64_64],
853 [],
854 [AC_DEFINE(HAVE_DIV64_64, 1,
855 [div64_64() is available])],
856 [])
857 ])
858
859 dnl #
860 dnl # 2.6.26 API change,
861 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
862 dnl #
863 AC_DEFUN([SPL_AC_DIV64_U64], [
864 SPL_CHECK_SYMBOL_EXPORT(
865 [div64_u64],
866 [],
867 [AC_DEFINE(HAVE_DIV64_U64, 1,
868 [div64_u64() is available])],
869 [])
870 ])
871
872 dnl #
873 dnl # 2.6.27 API change,
874 dnl # on_each_cpu() uses 3 args, no 'retry' argument
875 dnl #
876 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
877 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
878 SPL_LINUX_TRY_COMPILE([
879 #include <linux/smp.h>
880 ],[
881 on_each_cpu(NULL, NULL, 0);
882 ],[
883 AC_MSG_RESULT(yes)
884 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
885 [on_each_cpu wants 3 args])
886 ],[
887 AC_MSG_RESULT(no)
888 ])
889 ])
890
891 dnl #
892 dnl # 2.6.18 API change,
893 dnl # kallsyms_lookup_name no longer exported
894 dnl #
895 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
896 SPL_CHECK_SYMBOL_EXPORT(
897 [kallsyms_lookup_name],
898 [],
899 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
900 [kallsyms_lookup_name() is available])],
901 [])
902 ])
903
904 dnl #
905 dnl # Proposed API change,
906 dnl # This symbol is not available in stock kernels. You may build a
907 dnl # custom kernel with the *-spl-export-symbols.patch which will export
908 dnl # these symbols for use. If your already rolling a custom kernel for
909 dnl # your environment this is recommended.
910 dnl #
911 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
912 SPL_CHECK_SYMBOL_EXPORT(
913 [get_vmalloc_info],
914 [],
915 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
916 [get_vmalloc_info() is available])],
917 [])
918 ])
919
920 dnl #
921 dnl # 2.6.17 API change
922 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
923 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
924 dnl # were exported in 2.6.17 for use by modules which was consistent with
925 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
926 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
927 dnl # were dropped entirely leaving modules no way to directly iterate over
928 dnl # the zone list. Because we need access to the zone helpers we check
929 dnl # if the kernel contains the old or new implementation. Then we check
930 dnl # to see if the symbols we need for each version are available. If they
931 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
932 dnl #
933 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
934 AC_MSG_CHECKING([whether symbol *_pgdat exist])
935 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
936 rc=$?
937 if test $rc -eq 0; then
938 AC_MSG_RESULT([yes])
939 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
940 else
941 AC_MSG_RESULT([no])
942 fi
943 ])
944
945 dnl #
946 dnl # Proposed API change,
947 dnl # This symbol is not available in stock kernels. You may build a
948 dnl # custom kernel with the *-spl-export-symbols.patch which will export
949 dnl # these symbols for use. If your already rolling a custom kernel for
950 dnl # your environment this is recommended.
951 dnl #
952 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
953 SPL_CHECK_SYMBOL_EXPORT(
954 [first_online_pgdat],
955 [],
956 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
957 [first_online_pgdat() is available])],
958 [])
959 ])
960
961 dnl #
962 dnl # Proposed API change,
963 dnl # This symbol is not available in stock kernels. You may build a
964 dnl # custom kernel with the *-spl-export-symbols.patch which will export
965 dnl # these symbols for use. If your already rolling a custom kernel for
966 dnl # your environment this is recommended.
967 dnl #
968 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
969 SPL_CHECK_SYMBOL_EXPORT(
970 [next_online_pgdat],
971 [],
972 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
973 [next_online_pgdat() is available])],
974 [])
975 ])
976
977 dnl #
978 dnl # Proposed API change,
979 dnl # This symbol is not available in stock kernels. You may build a
980 dnl # custom kernel with the *-spl-export-symbols.patch which will export
981 dnl # these symbols for use. If your already rolling a custom kernel for
982 dnl # your environment this is recommended.
983 dnl #
984 AC_DEFUN([SPL_AC_NEXT_ZONE], [
985 SPL_CHECK_SYMBOL_EXPORT(
986 [next_zone],
987 [],
988 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
989 [next_zone() is available])],
990 [])
991 ])
992
993 dnl #
994 dnl # 2.6.17 API change,
995 dnl # See SPL_AC_PGDAT_HELPERS for details.
996 dnl #
997 AC_DEFUN([SPL_AC_PGDAT_LIST], [
998 SPL_CHECK_SYMBOL_EXPORT(
999 [pgdat_list],
1000 [],
1001 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1002 [pgdat_list is available])],
1003 [])
1004 ])
1005
1006 dnl #
1007 dnl # Proposed API change,
1008 dnl # This symbol is not available in stock kernels. You may build a
1009 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1010 dnl # these symbols for use. If your already rolling a custom kernel for
1011 dnl # your environment this is recommended.
1012 dnl #
1013 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1014 SPL_CHECK_SYMBOL_EXPORT(
1015 [get_zone_counts],
1016 [],
1017 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1018 [get_zone_counts() is available])],
1019 [])
1020 ])
1021
1022 dnl #
1023 dnl # 2.6.18 API change,
1024 dnl # First introduced global_page_state() support as an inline.
1025 dnl #
1026 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1027 AC_MSG_CHECKING([whether global_page_state() is available])
1028 SPL_LINUX_TRY_COMPILE([
1029 #include <linux/vmstat.h>
1030 ],[
1031 unsigned long state;
1032 state = global_page_state(NR_FREE_PAGES);
1033 ],[
1034 AC_MSG_RESULT(yes)
1035 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1036 [global_page_state() is available])
1037 ],[
1038 AC_MSG_RESULT(no)
1039 ])
1040 ])
1041
1042 dnl #
1043 dnl # 2.6.21 API change,
1044 dnl # Public global zone stats now include free/inactive/active page
1045 dnl # counts. This replaced the priviate get_zone_counts() interface.
1046 dnl #
1047 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FIA], [
1048 AC_MSG_CHECKING([whether free/inactive/active page state is available])
1049 SPL_LINUX_TRY_COMPILE([
1050 #include <linux/mmzone.h>
1051 ],[
1052 enum zone_stat_item i1, i2, i3;
1053 i1 = NR_FREE_PAGES;
1054 i2 = NR_INACTIVE;
1055 i3 = NR_ACTIVE;
1056 ],[
1057 AC_MSG_RESULT(yes)
1058 AC_DEFINE(HAVE_ZONE_STAT_ITEM_FIA, 1,
1059 [free/inactive/active page state is available])
1060 ],[
1061 AC_MSG_RESULT(no)
1062 ])
1063 ])
1064
1065 dnl #
1066 dnl # SLES API change, never adopted in mainline,
1067 dnl # Third 'struct vfsmount *' argument removed.
1068 dnl #
1069 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1070 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1071 SPL_LINUX_TRY_COMPILE([
1072 #include <linux/fs.h>
1073 ],[
1074 vfs_unlink(NULL, NULL);
1075 ],[
1076 AC_MSG_RESULT(yes)
1077 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1078 [vfs_unlink() wants 2 args])
1079 ],[
1080 AC_MSG_RESULT(no)
1081 ])
1082 ])
1083
1084 dnl #
1085 dnl # SLES API change, never adopted in mainline,
1086 dnl # Third and sixth 'struct vfsmount *' argument removed.
1087 dnl #
1088 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1089 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1090 SPL_LINUX_TRY_COMPILE([
1091 #include <linux/fs.h>
1092 ],[
1093 vfs_rename(NULL, NULL, NULL, NULL);
1094 ],[
1095 AC_MSG_RESULT(yes)
1096 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1097 [vfs_rename() wants 4 args])
1098 ],[
1099 AC_MSG_RESULT(no)
1100 ])
1101 ])