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