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