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