]> git.proxmox.com Git - mirror_spl-debian.git/blame - config/spl-build.m4
Add spl.release to spl-devel to simply dependent package version check.
[mirror_spl-debian.git] / config / spl-build.m4
CommitLineData
57d86234 1AC_DEFUN([SPL_AC_KERNEL], [
57d86234 2 AC_ARG_WITH([linux],
3 AS_HELP_STRING([--with-linux=PATH],
4 [Path to kernel source]),
39a3d2a4 5 [kernelsrc="$withval"])
57d86234 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
bf338d8d
BB
14 sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \
15 2>/dev/null | grep -v obj | tail -1`
57d86234 16
d4326403
BB
17 if test -e ${sourcelink}; then
18 kernelsrc=`readlink -f ${sourcelink}`
d4326403 19 else
57d86234 20 AC_MSG_RESULT([Not found])
21 AC_MSG_ERROR([
22 *** Please specify the location of the kernel source
6a1c3d41 23 *** with the '--with-linux=PATH' option])
57d86234 24 fi
c5f70460
BB
25 else
26 if test "$kernelsrc" = "NONE"; then
27 kernsrcver=NONE
28 fi
57d86234 29 fi
30
31 AC_MSG_RESULT([$kernelsrc])
32 AC_MSG_CHECKING([kernel build directory])
39a3d2a4
BB
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
bf338d8d 41 fi
57d86234 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") |
d4326403 50 cpp -I $kernelbuild/include |
57d86234 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") |
d4326403 58 cpp -I $kernelbuild/include |
57d86234 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
57d86234 71 LINUX=${kernelsrc}
72 LINUX_OBJ=${kernelbuild}
c5f70460
BB
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}"
57d86234 86
87 AC_SUBST(LINUX)
88 AC_SUBST(LINUX_OBJ)
c5f70460
BB
89 AC_SUBST(LINUX_VERSION)
90 AC_SUBST(KERNELMAKE_PARAMS)
91 AC_SUBST(KERNELCPPFLAGS)
92 AC_SUBST(KERNELCFLAGS)
57d86234 93])
94
2e0e7e69
BB
95AC_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
6a1c3d41 106AC_DEFUN([SPL_AC_LICENSE], [
2e0e7e69
BB
107 AC_MSG_CHECKING([license])
108 AC_MSG_RESULT([GPL])
6a1c3d41 109 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
110])
111
57d86234 112AC_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 ;;
475cdc78 119 no) spl_ac_debug=no ;;
57d86234 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
475cdc78 125 AC_MSG_RESULT([yes])
57d86234 126 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"
127 else
475cdc78 128 AC_MSG_RESULT([no])
475cdc78 129 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
57d86234 130 fi
57d86234 131])
132
133AC_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
475cdc78 139 yes) spl_ac_debug_kmem=yes ;;
140 no) spl_ac_debug_kmem=no ;;
57d86234 141 *) AC_MSG_RESULT([Error!])
142 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;;
143 esac ]
144 )
475cdc78 145 if test "$spl_ac_debug_kmem" = yes; then
146 AC_MSG_RESULT([yes])
57d86234 147 AC_DEFINE([DEBUG_KMEM], [1],
148 [Define to 1 to enable kmem debugging])
475cdc78 149 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
150 else
151 AC_MSG_RESULT([no])
57d86234 152 fi
57d86234 153])
154
155AC_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
475cdc78 161 yes) spl_ac_debug_mutex=yes ;;
162 no) spl_ac_debug_mutex=no ;;
57d86234 163 *) AC_MSG_RESULT([Error!])
164 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;;
165 esac ]
166 )
475cdc78 167 if test "$spl_ac_debug_mutex" = yes; then
168 AC_MSG_RESULT([yes])
57d86234 169 AC_DEFINE([DEBUG_MUTEX], [1],
170 [Define to 1 to enable mutex debugging])
475cdc78 171 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX"
172 else
173 AC_MSG_RESULT([no])
57d86234 174 fi
57d86234 175])
176
177AC_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
475cdc78 183 yes) spl_ac_debug_kstat=yes ;;
184 no) spl_ac_debug_kstat=no ;;
57d86234 185 *) AC_MSG_RESULT([Error!])
186 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;;
187 esac ]
188 )
475cdc78 189 if test "$spl_ac_debug_kstat" = yes; then
190 AC_MSG_RESULT([yes])
57d86234 191 AC_DEFINE([DEBUG_KSTAT], [1],
192 [Define to 1 to enable kstat debugging])
475cdc78 193 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT"
194 else
195 AC_MSG_RESULT([no])
57d86234 196 fi
57d86234 197])
198
199AC_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
475cdc78 205 yes) spl_ac_debug_callb=yes ;;
206 no) spl_ac_debug_callb=no ;;
57d86234 207 *) AC_MSG_RESULT([Error!])
208 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;;
209 esac ]
210 )
475cdc78 211 if test "$spl_ac_debug_callb" = yes; then
212 AC_MSG_RESULT([yes])
57d86234 213 AC_DEFINE([DEBUG_CALLB], [1],
214 [Define to 1 to enable callb debugging])
475cdc78 215 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB"
216 else
217 AC_MSG_RESULT([no])
57d86234 218 fi
57d86234 219])
220
221dnl #
222dnl # SPL_LINUX_CONFTEST
223dnl #
224AC_DEFUN([SPL_LINUX_CONFTEST], [
225cat >conftest.c <<_ACEOF
226$1
227_ACEOF
228])
229
230dnl #
231dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
232dnl #
233m4_define([SPL_LANG_PROGRAM], [
234$1
235int
236main (void)
237{
238dnl Do *not* indent the following line: there may be CPP directives.
239dnl Don't move the `;' right after for the same reason.
240$2
241 ;
242 return 0;
243}
244])
245
246dnl #
247dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
248dnl #
249AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
c5f70460
BB
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(
bf338d8d 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])],
c5f70460
BB
255 [$4],
256 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
257 )
258 rm -Rf build
57d86234 259])
260
261dnl #
262dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
263dnl #
264AC_DEFUN([SPL_LINUX_TRY_COMPILE],
265 [SPL_LINUX_COMPILE_IFELSE(
d50bd9e2 266 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
267 [modules],
268 [test -s build/conftest.o],
269 [$3], [$4])
57d86234 270])
271
272dnl #
273dnl # SPL_LINUX_CONFIG
274dnl #
275AC_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
294dnl #
295dnl # SPL_CHECK_SYMBOL_EXPORT
296dnl # check symbol exported or not
297dnl #
298AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
299 [AC_MSG_CHECKING([whether symbol $1 is exported])
2e0e7e69
BB
300 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
301 $LINUX_OBJ/Module*.symvers 2>/dev/null
57d86234 302 rc=$?
303 if test $rc -ne 0; then
304 export=0
305 for file in $2; do
2e0e7e69
BB
306 grep -q -E "EXPORT_SYMBOL.*($1)" \
307 "$LINUX_OBJ/$file" 2>/dev/null
57d86234 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
86de8532 327dnl #
328dnl # SPL_CHECK_HEADER
329dnl # check whether header exists and define HAVE_$2_HEADER
330dnl #
331AC_DEFUN([SPL_CHECK_HEADER],
332 [AC_MSG_CHECKING([whether header $1 exists])
333 SPL_LINUX_TRY_COMPILE([
d50bd9e2 334 #include <$1>
86de8532 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])
6a6cafbe 346
57d86234 347dnl #
3d061e9d 348dnl # 2.6.24 API change,
57d86234 349dnl # check if uintptr_t typedef is defined
350dnl #
351AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
352 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
353 SPL_LINUX_TRY_COMPILE([
d50bd9e2 354 #include <linux/types.h>
57d86234 355 ],[
d50bd9e2 356 uintptr_t *ptr;
57d86234 357 ],[
d50bd9e2 358 AC_MSG_RESULT([yes])
359 AC_DEFINE(HAVE_UINTPTR_T, 1,
57d86234 360 [kernel defines uintptr_t])
361 ],[
d50bd9e2 362 AC_MSG_RESULT([no])
57d86234 363 ])
364])
365
a0f6da3d 366dnl #
367dnl # 2.6.x API change,
368dnl # check if atomic64_t typedef is defined
369dnl #
370AC_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
57d86234 385dnl #
3d061e9d 386dnl # 2.6.20 API change,
57d86234 387dnl # INIT_WORK use 2 args and not store data inside
388dnl #
389AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
390 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
391 SPL_LINUX_TRY_COMPILE([
d50bd9e2 392 #include <linux/workqueue.h>
57d86234 393 ],[
d50bd9e2 394 struct work_struct work;
395 INIT_WORK(&work, NULL, NULL);
57d86234 396 ],[
d50bd9e2 397 AC_MSG_RESULT(yes)
398 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
399 [INIT_WORK wants 3 args])
57d86234 400 ],[
d50bd9e2 401 AC_MSG_RESULT(no)
57d86234 402 ])
403])
404
405dnl #
3d061e9d 406dnl # 2.6.21 API change,
57d86234 407dnl # 'register_sysctl_table' use only one argument instead of two
408dnl #
409AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
410 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
411 SPL_LINUX_TRY_COMPILE([
d50bd9e2 412 #include <linux/sysctl.h>
57d86234 413 ],[
d50bd9e2 414 return register_sysctl_table(NULL,0);
57d86234 415 ],[
d50bd9e2 416 AC_MSG_RESULT(yes)
417 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
418 [register_sysctl_table() wants 2 args])
57d86234 419 ],[
d50bd9e2 420 AC_MSG_RESULT(no)
57d86234 421 ])
422])
423
57d86234 424dnl #
3d061e9d 425dnl # 2.6.23 API change
57d86234 426dnl # Old set_shrinker API replaced with register_shrinker
427dnl #
428AC_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
443dnl #
3d061e9d 444dnl # 2.6.25 API change,
57d86234 445dnl # struct path entry added to struct nameidata
446dnl #
447AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
448 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
449 SPL_LINUX_TRY_COMPILE([
d50bd9e2 450 #include <linux/namei.h>
57d86234 451 ],[
d50bd9e2 452 struct nameidata nd;
57d86234 453
454 nd.path.mnt = NULL;
455 nd.path.dentry = NULL;
456 ],[
d50bd9e2 457 AC_MSG_RESULT(yes)
458 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
459 [struct path used in struct nameidata])
57d86234 460 ],[
d50bd9e2 461 AC_MSG_RESULT(no)
57d86234 462 ])
463])
464
465dnl #
466dnl # Custom SPL patch may export this system it is not required
467dnl #
468AC_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
474dnl #
3d061e9d 475dnl # 2.6.19 API change,
57d86234 476dnl # Use CTL_UNNUMBERED when binary sysctl is not required
477dnl #
478AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
479 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
480 SPL_LINUX_TRY_COMPILE([
d50bd9e2 481 #include <linux/sysctl.h>
57d86234 482 ],[
483 #ifndef CTL_UNNUMBERED
484 #error CTL_UNNUMBERED undefined
485 #endif
486 ],[
d50bd9e2 487 AC_MSG_RESULT(yes)
488 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
489 [unnumbered sysctl support exists])
57d86234 490 ],[
d50bd9e2 491 AC_MSG_RESULT(no)
57d86234 492 ])
493])
877a32e9 494
495dnl #
496dnl # 2.6.16 API change.
497dnl # Check if 'fls64()' is available
498dnl #
499AC_DEFUN([SPL_AC_FLS64],
6a6cafbe 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 ])
877a32e9 511])
46c685d0 512
513dnl #
514dnl # 2.6.18 API change, check whether device_create() is available.
515dnl # Device_create() was introduced in 2.6.18 and depricated
516dnl # class_device_create() which was fully removed in 2.6.26.
517dnl #
518AC_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])],
6a6cafbe 524 [])
46c685d0 525])
526
8123ac4f
BB
527dnl #
528dnl # 2.6.27 API change,
529dnl # device_create() uses 5 args, new 'drvdata' argument.
530dnl #
531AC_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
46c685d0 549dnl #
550dnl # 2.6.13 API change, check whether class_device_create() is available.
551dnl # Class_device_create() was introduced in 2.6.13 and depricated
552dnl # class_simple_device_add() which was fully removed in 2.6.13.
553dnl #
554AC_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])],
6a6cafbe 560 [])
46c685d0 561])
6a6cafbe 562
6a6cafbe 563dnl #
564dnl # 2.6.26 API change, set_normalized_timespec() is exported.
565dnl #
566AC_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
575dnl #
576dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
577dnl # previously it was available in time.h as an inline.
578dnl #
86de8532 579AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
580 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
6a6cafbe 581 SPL_LINUX_TRY_COMPILE([
582 #include <linux/time.h>
6a6cafbe 583 void set_normalized_timespec(struct timespec *ts,
25557fd8 584 time_t sec, long nsec) { }
585 ],
586 [],
587 [
6a6cafbe 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
596dnl #
597dnl # 2.6.18 API change,
598dnl # timespec_sub() inline function available in linux/time.h
599dnl #
86de8532 600AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
601 AC_MSG_CHECKING([whether timespec_sub() is available])
6a6cafbe 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
86de8532 615dnl #
3d061e9d 616dnl # 2.6.19 API change,
617dnl # check if init_utsname() is available in linux/utsname.h
618dnl #
619AC_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
633dnl #
634dnl # 2.6.26 API change,
635dnl # definition of struct fdtable relocated to linux/fdtable.h
86de8532 636dnl #
637AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
638 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
639])
322640b7 640
641dnl #
3d061e9d 642dnl # 2.6.14 API change,
643dnl # check whether 'files_fdtable()' exists
644dnl #
645AC_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
664dnl #
665dnl # 2.6.18 API change,
666dnl # added linux/uaccess.h
322640b7 667dnl #
668AC_DEFUN([SPL_AC_UACCESS_HEADER], [
669 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
670])
3d061e9d 671
672dnl #
673dnl # 2.6.12 API change,
674dnl # check whether 'kmalloc_node()' is available.
675dnl #
676AC_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
690dnl #
691dnl # 2.6.9 API change,
692dnl # check whether 'monotonic_clock()' is available it may
693dnl # be available for some archs but not others.
694dnl #
695AC_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
704dnl #
705dnl # 2.6.16 API change,
706dnl # check whether 'struct inode' has i_mutex
707dnl #
708AC_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])
b61a6e8b 723
6c9433c1
BB
724dnl #
725dnl # 2.6.18 API change,
726dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
727dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
728dnl # if the mutex validator is disabled or otherwise unavailable.
729dnl #
730AC_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
b61a6e8b 747dnl #
96dded38
BB
748dnl # 2.6.22 API change,
749dnl # First introduced 'div64_64()' in lib/div64.c
750dnl
b61a6e8b 751AC_DEFUN([SPL_AC_DIV64_64], [
96dded38
BB
752 SPL_CHECK_SYMBOL_EXPORT(
753 [div64_64],
754 [],
755 [AC_DEFINE(HAVE_DIV64_64, 1,
756 [div64_64() is available])],
757 [])
758])
759
760dnl #
761dnl # 2.6.26 API change,
762dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
763dnl #
764AC_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 [])
b61a6e8b 771])
31a033ec
BB
772
773dnl #
774dnl # 2.6.27 API change,
775dnl # on_each_cpu() uses 3 args, no 'retry' argument
776dnl #
777AC_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])
36b313da
BB
791
792dnl #
d1ff2312
BB
793dnl # 2.6.18 API change,
794dnl # kallsyms_lookup_name no longer exported
795dnl #
796AC_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
805dnl #
e11d6c5f
BB
806dnl # Proposed API change,
807dnl # This symbol is not available in stock kernels. You may build a
808dnl # custom kernel with the *-spl-export-symbols.patch which will export
809dnl # these symbols for use. If your already rolling a custom kernel for
810dnl # your environment this is recommended.
d1ff2312
BB
811dnl #
812AC_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
5232d256
BB
821dnl #
822dnl # 2.6.17 API change
823dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
824dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
825dnl # were exported in 2.6.17 for use by modules which was consistent with
826dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
827dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
828dnl # were dropped entirely leaving modules no way to directly iterate over
829dnl # the zone list. Because we need access to the zone helpers we check
830dnl # if the kernel contains the old or new implementation. Then we check
831dnl # to see if the symbols we need for each version are available. If they
832dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
833dnl #
834AC_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
d1ff2312 846dnl #
e11d6c5f
BB
847dnl # Proposed API change,
848dnl # This symbol is not available in stock kernels. You may build a
849dnl # custom kernel with the *-spl-export-symbols.patch which will export
850dnl # these symbols for use. If your already rolling a custom kernel for
851dnl # your environment this is recommended.
36b313da
BB
852dnl #
853AC_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
862dnl #
e11d6c5f
BB
863dnl # Proposed API change,
864dnl # This symbol is not available in stock kernels. You may build a
865dnl # custom kernel with the *-spl-export-symbols.patch which will export
866dnl # these symbols for use. If your already rolling a custom kernel for
867dnl # your environment this is recommended.
36b313da
BB
868dnl #
869AC_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
878dnl #
e11d6c5f
BB
879dnl # Proposed API change,
880dnl # This symbol is not available in stock kernels. You may build a
881dnl # custom kernel with the *-spl-export-symbols.patch which will export
882dnl # these symbols for use. If your already rolling a custom kernel for
883dnl # your environment this is recommended.
36b313da
BB
884dnl #
885AC_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])
4ab13d3b 893
5232d256
BB
894dnl #
895dnl # 2.6.17 API change,
896dnl # See SPL_AC_PGDAT_HELPERS for details.
897dnl #
898AC_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
4ab13d3b 907dnl #
e11d6c5f
BB
908dnl # Proposed API change,
909dnl # This symbol is not available in stock kernels. You may build a
910dnl # custom kernel with the *-spl-export-symbols.patch which will export
911dnl # these symbols for use. If your already rolling a custom kernel for
912dnl # your environment this is recommended.
4ab13d3b
BB
913dnl #
914AC_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])
e11d6c5f 922
96dded38
BB
923dnl #
924dnl # 2.6.18 API change,
925dnl # First introduced global_page_state() support as an inline.
926dnl #
927AC_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
e11d6c5f
BB
943dnl #
944dnl # 2.6.21 API change,
945dnl # Public global zone stats now include free/inactive/active page
946dnl # counts. This replaced the priviate get_zone_counts() interface.
947dnl #
948AC_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])
a093c6a4
BB
965
966dnl #
967dnl # SLES API change, never adopted in mainline,
968dnl # Third 'struct vfsmount *' argument removed.
969dnl #
970AC_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
985dnl #
986dnl # SLES API change, never adopted in mainline,
987dnl # Third and sixth 'struct vfsmount *' argument removed.
988dnl #
989AC_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])