]> git.proxmox.com Git - mirror_spl.git/blame - config/spl-build.m4
Simplify rpm build rules, added config/rpm.am.
[mirror_spl.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], [
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
57d86234 80AC_DEFUN([SPL_AC_KERNEL], [
57d86234 81 AC_ARG_WITH([linux],
82 AS_HELP_STRING([--with-linux=PATH],
83 [Path to kernel source]),
39a3d2a4 84 [kernelsrc="$withval"])
57d86234 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
bf338d8d
BB
93 sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \
94 2>/dev/null | grep -v obj | tail -1`
57d86234 95
d4326403
BB
96 if test -e ${sourcelink}; then
97 kernelsrc=`readlink -f ${sourcelink}`
d4326403 98 else
57d86234 99 AC_MSG_RESULT([Not found])
100 AC_MSG_ERROR([
101 *** Please specify the location of the kernel source
6a1c3d41 102 *** with the '--with-linux=PATH' option])
57d86234 103 fi
c5f70460
BB
104 else
105 if test "$kernelsrc" = "NONE"; then
106 kernsrcver=NONE
107 fi
57d86234 108 fi
109
110 AC_MSG_RESULT([$kernelsrc])
111 AC_MSG_CHECKING([kernel build directory])
39a3d2a4
BB
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
bf338d8d 120 fi
57d86234 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") |
d4326403 129 cpp -I $kernelbuild/include |
57d86234 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") |
d4326403 137 cpp -I $kernelbuild/include |
57d86234 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
57d86234 150 LINUX=${kernelsrc}
151 LINUX_OBJ=${kernelbuild}
c5f70460
BB
152 LINUX_VERSION=${kernsrcver}
153
57d86234 154 AC_SUBST(LINUX)
155 AC_SUBST(LINUX_OBJ)
c5f70460 156 AC_SUBST(LINUX_VERSION)
57d86234 157
86933a6e 158 SPL_AC_MODULE_SYMVERS
2e0e7e69
BB
159])
160
86933a6e
BB
161dnl #
162dnl # Default SPL user configuration
163dnl #
164AC_DEFUN([SPL_AC_CONFIG_USER], [])
165
6a1c3d41 166AC_DEFUN([SPL_AC_LICENSE], [
86933a6e
BB
167 AC_MSG_CHECKING([spl license])
168 LICENSE=GPL
169 AC_MSG_RESULT([$LICENSE])
6a1c3d41 170 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
86933a6e
BB
171 AC_SUBST(LICENSE)
172])
173
174AC_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])
6a1c3d41 202])
203
57d86234 204AC_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 ;;
475cdc78 211 no) spl_ac_debug=no ;;
57d86234 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
475cdc78 217 AC_MSG_RESULT([yes])
57d86234 218 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"
219 else
475cdc78 220 AC_MSG_RESULT([no])
475cdc78 221 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
57d86234 222 fi
57d86234 223])
224
225AC_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
475cdc78 231 yes) spl_ac_debug_kmem=yes ;;
232 no) spl_ac_debug_kmem=no ;;
57d86234 233 *) AC_MSG_RESULT([Error!])
234 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;;
235 esac ]
236 )
475cdc78 237 if test "$spl_ac_debug_kmem" = yes; then
238 AC_MSG_RESULT([yes])
57d86234 239 AC_DEFINE([DEBUG_KMEM], [1],
240 [Define to 1 to enable kmem debugging])
475cdc78 241 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
242 else
243 AC_MSG_RESULT([no])
57d86234 244 fi
57d86234 245])
246
247AC_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
475cdc78 253 yes) spl_ac_debug_mutex=yes ;;
254 no) spl_ac_debug_mutex=no ;;
57d86234 255 *) AC_MSG_RESULT([Error!])
256 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;;
257 esac ]
258 )
475cdc78 259 if test "$spl_ac_debug_mutex" = yes; then
260 AC_MSG_RESULT([yes])
57d86234 261 AC_DEFINE([DEBUG_MUTEX], [1],
262 [Define to 1 to enable mutex debugging])
475cdc78 263 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX"
264 else
265 AC_MSG_RESULT([no])
57d86234 266 fi
57d86234 267])
268
269AC_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
475cdc78 275 yes) spl_ac_debug_kstat=yes ;;
276 no) spl_ac_debug_kstat=no ;;
57d86234 277 *) AC_MSG_RESULT([Error!])
278 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;;
279 esac ]
280 )
475cdc78 281 if test "$spl_ac_debug_kstat" = yes; then
282 AC_MSG_RESULT([yes])
57d86234 283 AC_DEFINE([DEBUG_KSTAT], [1],
284 [Define to 1 to enable kstat debugging])
475cdc78 285 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT"
286 else
287 AC_MSG_RESULT([no])
57d86234 288 fi
57d86234 289])
290
291AC_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
475cdc78 297 yes) spl_ac_debug_callb=yes ;;
298 no) spl_ac_debug_callb=no ;;
57d86234 299 *) AC_MSG_RESULT([Error!])
300 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;;
301 esac ]
302 )
475cdc78 303 if test "$spl_ac_debug_callb" = yes; then
304 AC_MSG_RESULT([yes])
57d86234 305 AC_DEFINE([DEBUG_CALLB], [1],
306 [Define to 1 to enable callb debugging])
475cdc78 307 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB"
308 else
309 AC_MSG_RESULT([no])
57d86234 310 fi
57d86234 311])
312
313dnl #
314dnl # SPL_LINUX_CONFTEST
315dnl #
316AC_DEFUN([SPL_LINUX_CONFTEST], [
317cat >conftest.c <<_ACEOF
318$1
319_ACEOF
320])
321
322dnl #
323dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
324dnl #
325m4_define([SPL_LANG_PROGRAM], [
326$1
327int
328main (void)
329{
330dnl Do *not* indent the following line: there may be CPP directives.
331dnl Don't move the `;' right after for the same reason.
332$2
333 ;
334 return 0;
335}
336])
337
338dnl #
339dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
340dnl #
341AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
c5f70460
BB
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(
bf338d8d 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])],
c5f70460
BB
347 [$4],
348 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
349 )
350 rm -Rf build
57d86234 351])
352
353dnl #
354dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
355dnl #
356AC_DEFUN([SPL_LINUX_TRY_COMPILE],
357 [SPL_LINUX_COMPILE_IFELSE(
d50bd9e2 358 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
359 [modules],
360 [test -s build/conftest.o],
361 [$3], [$4])
57d86234 362])
363
364dnl #
365dnl # SPL_LINUX_CONFIG
366dnl #
367AC_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
386dnl #
387dnl # SPL_CHECK_SYMBOL_EXPORT
388dnl # check symbol exported or not
389dnl #
390AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
391 [AC_MSG_CHECKING([whether symbol $1 is exported])
2e0e7e69
BB
392 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
393 $LINUX_OBJ/Module*.symvers 2>/dev/null
57d86234 394 rc=$?
395 if test $rc -ne 0; then
396 export=0
397 for file in $2; do
2e0e7e69
BB
398 grep -q -E "EXPORT_SYMBOL.*($1)" \
399 "$LINUX_OBJ/$file" 2>/dev/null
57d86234 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
86de8532 419dnl #
420dnl # SPL_CHECK_HEADER
421dnl # check whether header exists and define HAVE_$2_HEADER
422dnl #
423AC_DEFUN([SPL_CHECK_HEADER],
424 [AC_MSG_CHECKING([whether header $1 exists])
425 SPL_LINUX_TRY_COMPILE([
d50bd9e2 426 #include <$1>
86de8532 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])
6a6cafbe 438
57d86234 439dnl #
3d061e9d 440dnl # 2.6.24 API change,
57d86234 441dnl # check if uintptr_t typedef is defined
442dnl #
443AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
444 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
445 SPL_LINUX_TRY_COMPILE([
d50bd9e2 446 #include <linux/types.h>
57d86234 447 ],[
d50bd9e2 448 uintptr_t *ptr;
57d86234 449 ],[
d50bd9e2 450 AC_MSG_RESULT([yes])
451 AC_DEFINE(HAVE_UINTPTR_T, 1,
57d86234 452 [kernel defines uintptr_t])
453 ],[
d50bd9e2 454 AC_MSG_RESULT([no])
57d86234 455 ])
456])
457
a0f6da3d 458dnl #
459dnl # 2.6.x API change,
460dnl # check if atomic64_t typedef is defined
461dnl #
462AC_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
57d86234 477dnl #
3d061e9d 478dnl # 2.6.20 API change,
57d86234 479dnl # INIT_WORK use 2 args and not store data inside
480dnl #
481AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
482 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
483 SPL_LINUX_TRY_COMPILE([
d50bd9e2 484 #include <linux/workqueue.h>
57d86234 485 ],[
d50bd9e2 486 struct work_struct work;
487 INIT_WORK(&work, NULL, NULL);
57d86234 488 ],[
d50bd9e2 489 AC_MSG_RESULT(yes)
490 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
491 [INIT_WORK wants 3 args])
57d86234 492 ],[
d50bd9e2 493 AC_MSG_RESULT(no)
57d86234 494 ])
495])
496
497dnl #
3d061e9d 498dnl # 2.6.21 API change,
57d86234 499dnl # 'register_sysctl_table' use only one argument instead of two
500dnl #
501AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
502 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
503 SPL_LINUX_TRY_COMPILE([
d50bd9e2 504 #include <linux/sysctl.h>
57d86234 505 ],[
d50bd9e2 506 return register_sysctl_table(NULL,0);
57d86234 507 ],[
d50bd9e2 508 AC_MSG_RESULT(yes)
509 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
510 [register_sysctl_table() wants 2 args])
57d86234 511 ],[
d50bd9e2 512 AC_MSG_RESULT(no)
57d86234 513 ])
514])
515
57d86234 516dnl #
3d061e9d 517dnl # 2.6.23 API change
57d86234 518dnl # Old set_shrinker API replaced with register_shrinker
519dnl #
520AC_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
535dnl #
3d061e9d 536dnl # 2.6.25 API change,
57d86234 537dnl # struct path entry added to struct nameidata
538dnl #
539AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
540 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
541 SPL_LINUX_TRY_COMPILE([
d50bd9e2 542 #include <linux/namei.h>
57d86234 543 ],[
d50bd9e2 544 struct nameidata nd;
57d86234 545
546 nd.path.mnt = NULL;
547 nd.path.dentry = NULL;
548 ],[
d50bd9e2 549 AC_MSG_RESULT(yes)
550 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
551 [struct path used in struct nameidata])
57d86234 552 ],[
d50bd9e2 553 AC_MSG_RESULT(no)
57d86234 554 ])
555])
556
557dnl #
558dnl # Custom SPL patch may export this system it is not required
559dnl #
560AC_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
566dnl #
3d061e9d 567dnl # 2.6.19 API change,
57d86234 568dnl # Use CTL_UNNUMBERED when binary sysctl is not required
569dnl #
570AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
571 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
572 SPL_LINUX_TRY_COMPILE([
d50bd9e2 573 #include <linux/sysctl.h>
57d86234 574 ],[
575 #ifndef CTL_UNNUMBERED
576 #error CTL_UNNUMBERED undefined
577 #endif
578 ],[
d50bd9e2 579 AC_MSG_RESULT(yes)
580 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
581 [unnumbered sysctl support exists])
57d86234 582 ],[
d50bd9e2 583 AC_MSG_RESULT(no)
57d86234 584 ])
585])
877a32e9 586
587dnl #
588dnl # 2.6.16 API change.
589dnl # Check if 'fls64()' is available
590dnl #
591AC_DEFUN([SPL_AC_FLS64],
6a6cafbe 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 ])
877a32e9 603])
46c685d0 604
605dnl #
606dnl # 2.6.18 API change, check whether device_create() is available.
607dnl # Device_create() was introduced in 2.6.18 and depricated
608dnl # class_device_create() which was fully removed in 2.6.26.
609dnl #
610AC_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])],
6a6cafbe 616 [])
46c685d0 617])
618
8123ac4f
BB
619dnl #
620dnl # 2.6.27 API change,
621dnl # device_create() uses 5 args, new 'drvdata' argument.
622dnl #
623AC_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
46c685d0 641dnl #
642dnl # 2.6.13 API change, check whether class_device_create() is available.
643dnl # Class_device_create() was introduced in 2.6.13 and depricated
644dnl # class_simple_device_add() which was fully removed in 2.6.13.
645dnl #
646AC_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])],
6a6cafbe 652 [])
46c685d0 653])
6a6cafbe 654
6a6cafbe 655dnl #
656dnl # 2.6.26 API change, set_normalized_timespec() is exported.
657dnl #
658AC_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
667dnl #
668dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
669dnl # previously it was available in time.h as an inline.
670dnl #
86de8532 671AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
672 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
6a6cafbe 673 SPL_LINUX_TRY_COMPILE([
674 #include <linux/time.h>
6a6cafbe 675 void set_normalized_timespec(struct timespec *ts,
25557fd8 676 time_t sec, long nsec) { }
677 ],
678 [],
679 [
6a6cafbe 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
688dnl #
689dnl # 2.6.18 API change,
690dnl # timespec_sub() inline function available in linux/time.h
691dnl #
86de8532 692AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
693 AC_MSG_CHECKING([whether timespec_sub() is available])
6a6cafbe 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
86de8532 707dnl #
3d061e9d 708dnl # 2.6.19 API change,
709dnl # check if init_utsname() is available in linux/utsname.h
710dnl #
711AC_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
725dnl #
726dnl # 2.6.26 API change,
727dnl # definition of struct fdtable relocated to linux/fdtable.h
86de8532 728dnl #
729AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
730 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
731])
322640b7 732
733dnl #
3d061e9d 734dnl # 2.6.14 API change,
735dnl # check whether 'files_fdtable()' exists
736dnl #
737AC_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
756dnl #
757dnl # 2.6.18 API change,
758dnl # added linux/uaccess.h
322640b7 759dnl #
760AC_DEFUN([SPL_AC_UACCESS_HEADER], [
761 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
762])
3d061e9d 763
764dnl #
765dnl # 2.6.12 API change,
766dnl # check whether 'kmalloc_node()' is available.
767dnl #
768AC_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
782dnl #
783dnl # 2.6.9 API change,
784dnl # check whether 'monotonic_clock()' is available it may
785dnl # be available for some archs but not others.
786dnl #
787AC_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
796dnl #
797dnl # 2.6.16 API change,
798dnl # check whether 'struct inode' has i_mutex
799dnl #
800AC_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])
b61a6e8b 815
6c9433c1
BB
816dnl #
817dnl # 2.6.18 API change,
818dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
819dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
820dnl # if the mutex validator is disabled or otherwise unavailable.
821dnl #
822AC_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
b61a6e8b 839dnl #
96dded38
BB
840dnl # 2.6.22 API change,
841dnl # First introduced 'div64_64()' in lib/div64.c
842dnl
b61a6e8b 843AC_DEFUN([SPL_AC_DIV64_64], [
96dded38
BB
844 SPL_CHECK_SYMBOL_EXPORT(
845 [div64_64],
846 [],
847 [AC_DEFINE(HAVE_DIV64_64, 1,
848 [div64_64() is available])],
849 [])
850])
851
852dnl #
853dnl # 2.6.26 API change,
854dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
855dnl #
856AC_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 [])
b61a6e8b 863])
31a033ec
BB
864
865dnl #
866dnl # 2.6.27 API change,
867dnl # on_each_cpu() uses 3 args, no 'retry' argument
868dnl #
869AC_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])
36b313da
BB
883
884dnl #
d1ff2312
BB
885dnl # 2.6.18 API change,
886dnl # kallsyms_lookup_name no longer exported
887dnl #
888AC_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
897dnl #
e11d6c5f
BB
898dnl # Proposed API change,
899dnl # This symbol is not available in stock kernels. You may build a
900dnl # custom kernel with the *-spl-export-symbols.patch which will export
901dnl # these symbols for use. If your already rolling a custom kernel for
902dnl # your environment this is recommended.
d1ff2312
BB
903dnl #
904AC_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
5232d256
BB
913dnl #
914dnl # 2.6.17 API change
915dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
916dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
917dnl # were exported in 2.6.17 for use by modules which was consistent with
918dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
919dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
920dnl # were dropped entirely leaving modules no way to directly iterate over
921dnl # the zone list. Because we need access to the zone helpers we check
922dnl # if the kernel contains the old or new implementation. Then we check
923dnl # to see if the symbols we need for each version are available. If they
924dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
925dnl #
926AC_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
d1ff2312 938dnl #
e11d6c5f
BB
939dnl # Proposed API change,
940dnl # This symbol is not available in stock kernels. You may build a
941dnl # custom kernel with the *-spl-export-symbols.patch which will export
942dnl # these symbols for use. If your already rolling a custom kernel for
943dnl # your environment this is recommended.
36b313da
BB
944dnl #
945AC_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
954dnl #
e11d6c5f
BB
955dnl # Proposed API change,
956dnl # This symbol is not available in stock kernels. You may build a
957dnl # custom kernel with the *-spl-export-symbols.patch which will export
958dnl # these symbols for use. If your already rolling a custom kernel for
959dnl # your environment this is recommended.
36b313da
BB
960dnl #
961AC_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
970dnl #
e11d6c5f
BB
971dnl # Proposed API change,
972dnl # This symbol is not available in stock kernels. You may build a
973dnl # custom kernel with the *-spl-export-symbols.patch which will export
974dnl # these symbols for use. If your already rolling a custom kernel for
975dnl # your environment this is recommended.
36b313da
BB
976dnl #
977AC_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])
4ab13d3b 985
5232d256
BB
986dnl #
987dnl # 2.6.17 API change,
988dnl # See SPL_AC_PGDAT_HELPERS for details.
989dnl #
990AC_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
4ab13d3b 999dnl #
e11d6c5f
BB
1000dnl # Proposed API change,
1001dnl # This symbol is not available in stock kernels. You may build a
1002dnl # custom kernel with the *-spl-export-symbols.patch which will export
1003dnl # these symbols for use. If your already rolling a custom kernel for
1004dnl # your environment this is recommended.
4ab13d3b
BB
1005dnl #
1006AC_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])
e11d6c5f 1014
96dded38
BB
1015dnl #
1016dnl # 2.6.18 API change,
1017dnl # First introduced global_page_state() support as an inline.
1018dnl #
1019AC_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
e11d6c5f
BB
1035dnl #
1036dnl # 2.6.21 API change,
1037dnl # Public global zone stats now include free/inactive/active page
1038dnl # counts. This replaced the priviate get_zone_counts() interface.
1039dnl #
1040AC_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])
a093c6a4
BB
1057
1058dnl #
1059dnl # SLES API change, never adopted in mainline,
1060dnl # Third 'struct vfsmount *' argument removed.
1061dnl #
1062AC_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
1077dnl #
1078dnl # SLES API change, never adopted in mainline,
1079dnl # Third and sixth 'struct vfsmount *' argument removed.
1080dnl #
1081AC_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])