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