]> git.proxmox.com Git - mirror_spl-debian.git/blob - config/spl-build.m4
d0cf86d9abbc89dcf059f8cbb6c79494108c6af6
[mirror_spl-debian.git] / config / spl-build.m4
1 AC_DEFUN([SPL_AC_KERNEL], [
2 AC_ARG_WITH([linux],
3 AS_HELP_STRING([--with-linux=PATH],
4 [Path to kernel source]),
5 [kernelsrc="$withval"; kernelbuild="$withval"])
6
7 AC_ARG_WITH([linux-obj],
8 AS_HELP_STRING([--with-linux-obj=PATH],
9 [Path to kernel build objects]),
10 [kernelbuild="$withval"])
11
12 AC_MSG_CHECKING([kernel source directory])
13 if test -z "$kernelsrc"; then
14 kernelbuild=
15 sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* 2>/dev/null | tail -1`
16
17 if test -e ${sourcelink}; then
18 kernelsrc=`readlink -f ${sourcelink}`
19 kernelbuild=${kernelsrc}
20 else
21 AC_MSG_RESULT([Not found])
22 AC_MSG_ERROR([
23 *** Please specify the location of the kernel source
24 *** with the '--with-linux=PATH' option])
25 fi
26 else
27 if test "$kernelsrc" = "NONE"; then
28 kernsrcver=NONE
29 fi
30 fi
31
32 AC_MSG_RESULT([$kernelsrc])
33 AC_MSG_CHECKING([kernel build directory])
34 AC_MSG_RESULT([$kernelbuild])
35
36 AC_MSG_CHECKING([kernel source version])
37 if test -r $kernelbuild/include/linux/version.h &&
38 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
39
40 kernsrcver=`(echo "#include <linux/version.h>";
41 echo "kernsrcver=UTS_RELEASE") |
42 cpp -I $kernelbuild/include |
43 grep "^kernsrcver=" | cut -d \" -f 2`
44
45 elif test -r $kernelbuild/include/linux/utsrelease.h &&
46 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
47
48 kernsrcver=`(echo "#include <linux/utsrelease.h>";
49 echo "kernsrcver=UTS_RELEASE") |
50 cpp -I $kernelbuild/include |
51 grep "^kernsrcver=" | cut -d \" -f 2`
52 fi
53
54 if test -z "$kernsrcver"; then
55 AC_MSG_RESULT([Not found])
56 AC_MSG_ERROR([
57 *** Cannot determine the version of the linux kernel source.
58 *** Please prepare the kernel before running this script])
59 fi
60
61 AC_MSG_RESULT([$kernsrcver])
62
63 LINUX=${kernelsrc}
64 LINUX_OBJ=${kernelbuild}
65 LINUX_VERSION=${kernsrcver}
66
67 abs_srcdir=`readlink -f ${srcdir}`
68 kerninclude="-I${abs_srcdir} -I${abs_srcdir}/include"
69 kernwarn="-Wstrict-prototypes -Werror"
70
71 if test "${LINUX_OBJ}" != "${LINUX}"; then
72 kernobjs="O=$kernelbuild"
73 fi
74
75 KERNELCFLAGS=
76 KERNELCPPFLAGS="${kerninclude} ${kernwarn}"
77 KERNELMAKE_PARAMS="${kernobjs}"
78
79 AC_SUBST(LINUX)
80 AC_SUBST(LINUX_OBJ)
81 AC_SUBST(LINUX_VERSION)
82 AC_SUBST(KERNELMAKE_PARAMS)
83 AC_SUBST(KERNELCPPFLAGS)
84 AC_SUBST(KERNELCFLAGS)
85 ])
86
87 AC_DEFUN([SPL_AC_LICENSE], [
88 AC_MSG_CHECKING([license])
89 AC_MSG_RESULT([GPL])
90 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
91 ])
92
93 AC_DEFUN([SPL_AC_DEBUG], [
94 AC_MSG_CHECKING([whether debugging is enabled])
95 AC_ARG_ENABLE( [debug],
96 AS_HELP_STRING([--enable-debug],
97 [Enable generic debug support (default off)]),
98 [ case "$enableval" in
99 yes) spl_ac_debug=yes ;;
100 no) spl_ac_debug=no ;;
101 *) AC_MSG_RESULT([Error!])
102 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
103 esac ]
104 )
105 if test "$spl_ac_debug" = yes; then
106 AC_MSG_RESULT([yes])
107 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"
108 else
109 AC_MSG_RESULT([no])
110 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
111 fi
112 ])
113
114 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
115 AC_MSG_CHECKING([whether kmem debugging is enabled])
116 AC_ARG_ENABLE( [debug-kmem],
117 AS_HELP_STRING([--enable-debug-kmem],
118 [Enable kmem debug support (default off)]),
119 [ case "$enableval" in
120 yes) spl_ac_debug_kmem=yes ;;
121 no) spl_ac_debug_kmem=no ;;
122 *) AC_MSG_RESULT([Error!])
123 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;;
124 esac ]
125 )
126 if test "$spl_ac_debug_kmem" = yes; then
127 AC_MSG_RESULT([yes])
128 AC_DEFINE([DEBUG_KMEM], [1],
129 [Define to 1 to enable kmem debugging])
130 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
131 else
132 AC_MSG_RESULT([no])
133 fi
134 ])
135
136 AC_DEFUN([SPL_AC_DEBUG_MUTEX], [
137 AC_MSG_CHECKING([whether mutex debugging is enabled])
138 AC_ARG_ENABLE( [debug-mutex],
139 AS_HELP_STRING([--enable-debug-mutex],
140 [Enable mutex debug support (default off)]),
141 [ case "$enableval" in
142 yes) spl_ac_debug_mutex=yes ;;
143 no) spl_ac_debug_mutex=no ;;
144 *) AC_MSG_RESULT([Error!])
145 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;;
146 esac ]
147 )
148 if test "$spl_ac_debug_mutex" = yes; then
149 AC_MSG_RESULT([yes])
150 AC_DEFINE([DEBUG_MUTEX], [1],
151 [Define to 1 to enable mutex debugging])
152 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX"
153 else
154 AC_MSG_RESULT([no])
155 fi
156 ])
157
158 AC_DEFUN([SPL_AC_DEBUG_KSTAT], [
159 AC_MSG_CHECKING([whether kstat debugging is enabled])
160 AC_ARG_ENABLE( [debug-kstat],
161 AS_HELP_STRING([--enable-debug-kstat],
162 [Enable kstat debug support (default off)]),
163 [ case "$enableval" in
164 yes) spl_ac_debug_kstat=yes ;;
165 no) spl_ac_debug_kstat=no ;;
166 *) AC_MSG_RESULT([Error!])
167 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;;
168 esac ]
169 )
170 if test "$spl_ac_debug_kstat" = yes; then
171 AC_MSG_RESULT([yes])
172 AC_DEFINE([DEBUG_KSTAT], [1],
173 [Define to 1 to enable kstat debugging])
174 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT"
175 else
176 AC_MSG_RESULT([no])
177 fi
178 ])
179
180 AC_DEFUN([SPL_AC_DEBUG_CALLB], [
181 AC_MSG_CHECKING([whether callb debugging is enabled])
182 AC_ARG_ENABLE( [debug-callb],
183 AS_HELP_STRING([--enable-debug-callb],
184 [Enable callb debug support (default off)]),
185 [ case "$enableval" in
186 yes) spl_ac_debug_callb=yes ;;
187 no) spl_ac_debug_callb=no ;;
188 *) AC_MSG_RESULT([Error!])
189 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;;
190 esac ]
191 )
192 if test "$spl_ac_debug_callb" = yes; then
193 AC_MSG_RESULT([yes])
194 AC_DEFINE([DEBUG_CALLB], [1],
195 [Define to 1 to enable callb debugging])
196 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB"
197 else
198 AC_MSG_RESULT([no])
199 fi
200 ])
201
202 dnl #
203 dnl # SPL_LINUX_CONFTEST
204 dnl #
205 AC_DEFUN([SPL_LINUX_CONFTEST], [
206 cat >conftest.c <<_ACEOF
207 $1
208 _ACEOF
209 ])
210
211 dnl #
212 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
213 dnl #
214 m4_define([SPL_LANG_PROGRAM], [
215 $1
216 int
217 main (void)
218 {
219 dnl Do *not* indent the following line: there may be CPP directives.
220 dnl Don't move the `;' right after for the same reason.
221 $2
222 ;
223 return 0;
224 }
225 ])
226
227 dnl #
228 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
229 dnl #
230 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
231 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
232 rm -Rf build && mkdir -p build
233 echo "obj-m := conftest.o" >build/Makefile
234 AS_IF(
235 [AC_TRY_COMMAND(cp conftest.c build && make [$2] CC="$CC" LINUXINCLUDE="-Iinclude -Iinclude2 -I$LINUX/include -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
236 [$4],
237 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
238 )
239 rm -Rf build
240 ])
241
242 dnl #
243 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
244 dnl #
245 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
246 [SPL_LINUX_COMPILE_IFELSE(
247 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
248 [modules],
249 [test -s build/conftest.o],
250 [$3], [$4])
251 ])
252
253 dnl #
254 dnl # SPL_LINUX_CONFIG
255 dnl #
256 AC_DEFUN([SPL_LINUX_CONFIG],
257 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
258 SPL_LINUX_TRY_COMPILE([
259 #ifndef AUTOCONF_INCLUDED
260 #include <linux/config.h>
261 #endif
262 ],[
263 #ifndef CONFIG_$1
264 #error CONFIG_$1 not #defined
265 #endif
266 ],[
267 AC_MSG_RESULT([yes])
268 $2
269 ],[
270 AC_MSG_RESULT([no])
271 $3
272 ])
273 ])
274
275 dnl #
276 dnl # SPL_CHECK_SYMBOL_EXPORT
277 dnl # check symbol exported or not
278 dnl #
279 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
280 [AC_MSG_CHECKING([whether symbol $1 is exported])
281 grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX_OBJ/Module.symvers 2>/dev/null
282 rc=$?
283 if test $rc -ne 0; then
284 export=0
285 for file in $2; do
286 grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX_OBJ/$file" 2>/dev/null
287 rc=$?
288 if test $rc -eq 0; then
289 export=1
290 break;
291 fi
292 done
293 if test $export -eq 0; then
294 AC_MSG_RESULT([no])
295 $4
296 else
297 AC_MSG_RESULT([yes])
298 $3
299 fi
300 else
301 AC_MSG_RESULT([yes])
302 $3
303 fi
304 ])
305
306 dnl #
307 dnl # SPL_CHECK_HEADER
308 dnl # check whether header exists and define HAVE_$2_HEADER
309 dnl #
310 AC_DEFUN([SPL_CHECK_HEADER],
311 [AC_MSG_CHECKING([whether header $1 exists])
312 SPL_LINUX_TRY_COMPILE([
313 #include <$1>
314 ],[
315 return 0;
316 ],[
317 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
318 AC_MSG_RESULT(yes)
319 $3
320 ],[
321 AC_MSG_RESULT(no)
322 $4
323 ])
324 ])
325
326 dnl #
327 dnl # 2.6.24 API change,
328 dnl # check if uintptr_t typedef is defined
329 dnl #
330 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
331 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
332 SPL_LINUX_TRY_COMPILE([
333 #include <linux/types.h>
334 ],[
335 uintptr_t *ptr;
336 ],[
337 AC_MSG_RESULT([yes])
338 AC_DEFINE(HAVE_UINTPTR_T, 1,
339 [kernel defines uintptr_t])
340 ],[
341 AC_MSG_RESULT([no])
342 ])
343 ])
344
345 dnl #
346 dnl # 2.6.x API change,
347 dnl # check if atomic64_t typedef is defined
348 dnl #
349 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_T],
350 [AC_MSG_CHECKING([whether kernel defines atomic64_t])
351 SPL_LINUX_TRY_COMPILE([
352 #include <asm/atomic.h>
353 ],[
354 atomic64_t *ptr;
355 ],[
356 AC_MSG_RESULT([yes])
357 AC_DEFINE(HAVE_ATOMIC64_T, 1,
358 [kernel defines atomic64_t])
359 ],[
360 AC_MSG_RESULT([no])
361 ])
362 ])
363
364 dnl #
365 dnl # 2.6.20 API change,
366 dnl # INIT_WORK use 2 args and not store data inside
367 dnl #
368 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
369 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
370 SPL_LINUX_TRY_COMPILE([
371 #include <linux/workqueue.h>
372 ],[
373 struct work_struct work;
374 INIT_WORK(&work, NULL, NULL);
375 ],[
376 AC_MSG_RESULT(yes)
377 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
378 [INIT_WORK wants 3 args])
379 ],[
380 AC_MSG_RESULT(no)
381 ])
382 ])
383
384 dnl #
385 dnl # 2.6.21 API change,
386 dnl # 'register_sysctl_table' use only one argument instead of two
387 dnl #
388 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
389 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
390 SPL_LINUX_TRY_COMPILE([
391 #include <linux/sysctl.h>
392 ],[
393 return register_sysctl_table(NULL,0);
394 ],[
395 AC_MSG_RESULT(yes)
396 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
397 [register_sysctl_table() wants 2 args])
398 ],[
399 AC_MSG_RESULT(no)
400 ])
401 ])
402
403 dnl #
404 dnl # 2.6.23 API change
405 dnl # Old set_shrinker API replaced with register_shrinker
406 dnl #
407 AC_DEFUN([SPL_AC_SET_SHRINKER], [
408 AC_MSG_CHECKING([whether set_shrinker() available])
409 SPL_LINUX_TRY_COMPILE([
410 #include <linux/mm.h>
411 ],[
412 return set_shrinker(DEFAULT_SEEKS, NULL);
413 ],[
414 AC_MSG_RESULT([yes])
415 AC_DEFINE(HAVE_SET_SHRINKER, 1,
416 [set_shrinker() available])
417 ],[
418 AC_MSG_RESULT([no])
419 ])
420 ])
421
422 dnl #
423 dnl # 2.6.25 API change,
424 dnl # struct path entry added to struct nameidata
425 dnl #
426 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
427 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
428 SPL_LINUX_TRY_COMPILE([
429 #include <linux/namei.h>
430 ],[
431 struct nameidata nd;
432
433 nd.path.mnt = NULL;
434 nd.path.dentry = NULL;
435 ],[
436 AC_MSG_RESULT(yes)
437 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
438 [struct path used in struct nameidata])
439 ],[
440 AC_MSG_RESULT(no)
441 ])
442 ])
443
444 dnl #
445 dnl # Custom SPL patch may export this system it is not required
446 dnl #
447 AC_DEFUN([SPL_AC_TASK_CURR], [
448 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
449 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
450 [])
451 ])
452
453 dnl #
454 dnl # 2.6.19 API change,
455 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
456 dnl #
457 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
458 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
459 SPL_LINUX_TRY_COMPILE([
460 #include <linux/sysctl.h>
461 ],[
462 #ifndef CTL_UNNUMBERED
463 #error CTL_UNNUMBERED undefined
464 #endif
465 ],[
466 AC_MSG_RESULT(yes)
467 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
468 [unnumbered sysctl support exists])
469 ],[
470 AC_MSG_RESULT(no)
471 ])
472 ])
473
474 dnl #
475 dnl # 2.6.16 API change.
476 dnl # Check if 'fls64()' is available
477 dnl #
478 AC_DEFUN([SPL_AC_FLS64],
479 [AC_MSG_CHECKING([whether fls64() is available])
480 SPL_LINUX_TRY_COMPILE([
481 #include <linux/bitops.h>
482 ],[
483 return fls64(0);
484 ],[
485 AC_MSG_RESULT(yes)
486 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
487 ],[
488 AC_MSG_RESULT(no)
489 ])
490 ])
491
492 dnl #
493 dnl # 2.6.18 API change, check whether device_create() is available.
494 dnl # Device_create() was introduced in 2.6.18 and depricated
495 dnl # class_device_create() which was fully removed in 2.6.26.
496 dnl #
497 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
498 SPL_CHECK_SYMBOL_EXPORT(
499 [device_create],
500 [drivers/base/core.c],
501 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
502 [device_create() is available])],
503 [])
504 ])
505
506 dnl #
507 dnl # 2.6.27 API change,
508 dnl # device_create() uses 5 args, new 'drvdata' argument.
509 dnl #
510 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
511 AC_MSG_CHECKING([whether device_create() wants 5 args])
512 tmp_flags="$EXTRA_KCFLAGS"
513 EXTRA_KCFLAGS="-Werror"
514 SPL_LINUX_TRY_COMPILE([
515 #include <linux/device.h>
516 ],[
517 device_create(NULL, NULL, 0, NULL, "%d", 1);
518 ],[
519 AC_MSG_RESULT(yes)
520 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
521 [device_create wants 5 args])
522 ],[
523 AC_MSG_RESULT(no)
524 ])
525 EXTRA_KCFLAGS="$tmp_flags"
526 ])
527
528 dnl #
529 dnl # 2.6.13 API change, check whether class_device_create() is available.
530 dnl # Class_device_create() was introduced in 2.6.13 and depricated
531 dnl # class_simple_device_add() which was fully removed in 2.6.13.
532 dnl #
533 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
534 SPL_CHECK_SYMBOL_EXPORT(
535 [class_device_create],
536 [drivers/base/class.c],
537 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
538 [class_device_create() is available])],
539 [])
540 ])
541
542 dnl #
543 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
544 dnl #
545 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
546 SPL_CHECK_SYMBOL_EXPORT(
547 [set_normalized_timespec],
548 [kernel/time.c],
549 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
550 [set_normalized_timespec() is available as export])],
551 [])
552 ])
553
554 dnl #
555 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
556 dnl # previously it was available in time.h as an inline.
557 dnl #
558 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
559 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
560 SPL_LINUX_TRY_COMPILE([
561 #include <linux/time.h>
562 void set_normalized_timespec(struct timespec *ts,
563 time_t sec, long nsec) { }
564 ],
565 [],
566 [
567 AC_MSG_RESULT(no)
568 ],[
569 AC_MSG_RESULT(yes)
570 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
571 [set_normalized_timespec() is available as inline])
572 ])
573 ])
574
575 dnl #
576 dnl # 2.6.18 API change,
577 dnl # timespec_sub() inline function available in linux/time.h
578 dnl #
579 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
580 AC_MSG_CHECKING([whether timespec_sub() is available])
581 SPL_LINUX_TRY_COMPILE([
582 #include <linux/time.h>
583 ],[
584 struct timespec a, b, c = { 0 };
585 c = timespec_sub(a, b);
586 ],[
587 AC_MSG_RESULT(yes)
588 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
589 ],[
590 AC_MSG_RESULT(no)
591 ])
592 ])
593
594 dnl #
595 dnl # 2.6.19 API change,
596 dnl # check if init_utsname() is available in linux/utsname.h
597 dnl #
598 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
599 AC_MSG_CHECKING([whether init_utsname() is available])
600 SPL_LINUX_TRY_COMPILE([
601 #include <linux/utsname.h>
602 ],[
603 struct new_utsname *a = init_utsname();
604 ],[
605 AC_MSG_RESULT(yes)
606 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
607 ],[
608 AC_MSG_RESULT(no)
609 ])
610 ])
611
612 dnl #
613 dnl # 2.6.26 API change,
614 dnl # definition of struct fdtable relocated to linux/fdtable.h
615 dnl #
616 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
617 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
618 ])
619
620 dnl #
621 dnl # 2.6.14 API change,
622 dnl # check whether 'files_fdtable()' exists
623 dnl #
624 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
625 AC_MSG_CHECKING([whether files_fdtable() is available])
626 SPL_LINUX_TRY_COMPILE([
627 #include <linux/sched.h>
628 #include <linux/file.h>
629 #ifdef HAVE_FDTABLE_HEADER
630 #include <linux/fdtable.h>
631 #endif
632 ],[
633 struct files_struct *files = current->files;
634 struct fdtable *fdt = files_fdtable(files);
635 ],[
636 AC_MSG_RESULT(yes)
637 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
638 ],[
639 AC_MSG_RESULT(no)
640 ])
641 ])
642
643 dnl #
644 dnl # 2.6.18 API change,
645 dnl # added linux/uaccess.h
646 dnl #
647 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
648 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
649 ])
650
651 dnl #
652 dnl # 2.6.12 API change,
653 dnl # check whether 'kmalloc_node()' is available.
654 dnl #
655 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
656 AC_MSG_CHECKING([whether kmalloc_node() is available])
657 SPL_LINUX_TRY_COMPILE([
658 #include <linux/slab.h>
659 ],[
660 void *a = kmalloc_node(1, GFP_KERNEL, 0);
661 ],[
662 AC_MSG_RESULT(yes)
663 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
664 ],[
665 AC_MSG_RESULT(no)
666 ])
667 ])
668
669 dnl #
670 dnl # 2.6.9 API change,
671 dnl # check whether 'monotonic_clock()' is available it may
672 dnl # be available for some archs but not others.
673 dnl #
674 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
675 SPL_CHECK_SYMBOL_EXPORT(
676 [monotonic_clock],
677 [],
678 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
679 [monotonic_clock() is available])],
680 [])
681 ])
682
683 dnl #
684 dnl # 2.6.16 API change,
685 dnl # check whether 'struct inode' has i_mutex
686 dnl #
687 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
688 AC_MSG_CHECKING([whether struct inode has i_mutex])
689 SPL_LINUX_TRY_COMPILE([
690 #include <linux/fs.h>
691 #include <linux/mutex.h>
692 ],[
693 struct inode i;
694 mutex_init(&i.i_mutex);
695 ],[
696 AC_MSG_RESULT(yes)
697 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
698 ],[
699 AC_MSG_RESULT(no)
700 ])
701 ])
702
703 dnl #
704 dnl # 2.6.14 API change,
705 dnl # check whether 'div64_64()' is available
706 dnl #
707 AC_DEFUN([SPL_AC_DIV64_64], [
708 AC_MSG_CHECKING([whether div64_64() is available])
709 SPL_LINUX_TRY_COMPILE([
710 #include <asm/div64.h>
711 #include <linux/types.h>
712 ],[
713 uint64_t i = div64_64(1ULL, 1ULL);
714 ],[
715 AC_MSG_RESULT(yes)
716 AC_DEFINE(HAVE_DIV64_64, 1, [div64_64() is available])
717 ],[
718 AC_MSG_RESULT(no)
719 ])
720 ])
721
722 dnl #
723 dnl # 2.6.27 API change,
724 dnl # on_each_cpu() uses 3 args, no 'retry' argument
725 dnl #
726 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
727 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
728 SPL_LINUX_TRY_COMPILE([
729 #include <linux/smp.h>
730 ],[
731 on_each_cpu(NULL, NULL, 0);
732 ],[
733 AC_MSG_RESULT(yes)
734 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
735 [on_each_cpu wants 3 args])
736 ],[
737 AC_MSG_RESULT(no)
738 ])
739 ])
740
741 dnl #
742 dnl # 2.6.18 API change,
743 dnl # kallsyms_lookup_name no longer exported
744 dnl #
745 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
746 SPL_CHECK_SYMBOL_EXPORT(
747 [kallsyms_lookup_name],
748 [],
749 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
750 [kallsyms_lookup_name() is available])],
751 [])
752 ])
753
754 dnl #
755 dnl # Symbol only available in custom kernels
756 dnl #
757 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
758 SPL_CHECK_SYMBOL_EXPORT(
759 [get_vmalloc_info],
760 [],
761 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
762 [get_vmalloc_info() is available])],
763 [])
764 ])
765
766 dnl #
767 dnl # Symbol only available in custom kernels
768 dnl #
769 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
770 SPL_CHECK_SYMBOL_EXPORT(
771 [first_online_pgdat],
772 [],
773 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
774 [first_online_pgdat() is available])],
775 [])
776 ])
777
778 dnl #
779 dnl # Symbol only available in custom kernels
780 dnl #
781 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
782 SPL_CHECK_SYMBOL_EXPORT(
783 [next_online_pgdat],
784 [],
785 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
786 [next_online_pgdat() is available])],
787 [])
788 ])
789
790 dnl #
791 dnl # Symbol only available in custom kernels
792 dnl #
793 AC_DEFUN([SPL_AC_NEXT_ZONE], [
794 SPL_CHECK_SYMBOL_EXPORT(
795 [next_zone],
796 [],
797 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
798 [next_zone() is available])],
799 [])
800 ])
801
802 dnl #
803 dnl # Symbol only available in custom kernels
804 dnl #
805 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
806 SPL_CHECK_SYMBOL_EXPORT(
807 [get_zone_counts],
808 [],
809 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
810 [get_zone_counts() is available])],
811 [])
812 ])