]> git.proxmox.com Git - mirror_spl.git/blame - config/spl-build.m4
* : Add autogen.sh products.
[mirror_spl.git] / config / spl-build.m4
CommitLineData
57d86234 1AC_DEFUN([SPL_AC_KERNEL], [
2 ver=`uname -r`
3
4 AC_ARG_WITH([linux],
5 AS_HELP_STRING([--with-linux=PATH],
6 [Path to kernel source]),
7 [kernelsrc="$withval"; kernelbuild="$withval"])
8
9 AC_ARG_WITH([linux-obj],
10 AS_HELP_STRING([--with-linux-obj=PATH],
11 [Path to kernel build objects]),
12 [kernelbuild="$withval"])
13
14 AC_MSG_CHECKING([kernel source directory])
15 if test -z "$kernelsrc"; then
16 kernelbuild=
17 sourcelink=/lib/modules/${ver}/source
18 buildlink=/lib/modules/${ver}/build
19
20 if test -e $sourcelink; then
21 kernelsrc=`(cd $sourcelink; /bin/pwd)`
22 fi
23 if test -e $buildlink; then
24 kernelbuild=`(cd $buildlink; /bin/pwd)`
25 fi
26 if test -z "$kernelsrc"; then
27 kernelsrc=$kernelbuild
28 fi
29 if test -z "$kernelsrc" -o -z "$kernelbuild"; then
30 AC_MSG_RESULT([Not found])
31 AC_MSG_ERROR([
32 *** Please specify the location of the kernel source
6a1c3d41 33 *** with the '--with-linux=PATH' option])
57d86234 34 fi
35 fi
36
37 AC_MSG_RESULT([$kernelsrc])
38 AC_MSG_CHECKING([kernel build directory])
39 AC_MSG_RESULT([$kernelbuild])
40
41 AC_MSG_CHECKING([kernel source version])
42 if test -r $kernelbuild/include/linux/version.h &&
43 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
44
45 kernsrcver=`(echo "#include <linux/version.h>";
46 echo "kernsrcver=UTS_RELEASE") |
47 cpp -I $kernelbuild/include |
48 grep "^kernsrcver=" | cut -d \" -f 2`
49
50 elif test -r $kernelbuild/include/linux/utsrelease.h &&
51 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
52
53 kernsrcver=`(echo "#include <linux/utsrelease.h>";
54 echo "kernsrcver=UTS_RELEASE") |
55 cpp -I $kernelbuild/include |
56 grep "^kernsrcver=" | cut -d \" -f 2`
57 fi
58
59 if test -z "$kernsrcver"; then
60 AC_MSG_RESULT([Not found])
61 AC_MSG_ERROR([
62 *** Cannot determine the version of the linux kernel source.
63 *** Please prepare the kernel before running this script])
64 fi
65
66 AC_MSG_RESULT([$kernsrcver])
67
68 kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver
69 LINUX=${kernelsrc}
70 LINUX_OBJ=${kernelbuild}
71
72 AC_SUBST(LINUX)
73 AC_SUBST(LINUX_OBJ)
74 AC_SUBST(kmoduledir)
75])
76
6a1c3d41 77AC_DEFUN([SPL_AC_LICENSE], [
78 AC_MSG_CHECKING([license])
79 AC_MSG_RESULT([GPL])
80 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
81])
82
57d86234 83AC_DEFUN([SPL_AC_DEBUG], [
84 AC_MSG_CHECKING([whether debugging is enabled])
85 AC_ARG_ENABLE( [debug],
86 AS_HELP_STRING([--enable-debug],
87 [Enable generic debug support (default off)]),
88 [ case "$enableval" in
89 yes) spl_ac_debug=yes ;;
475cdc78 90 no) spl_ac_debug=no ;;
57d86234 91 *) AC_MSG_RESULT([Error!])
92 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
93 esac ]
94 )
95 if test "$spl_ac_debug" = yes; then
475cdc78 96 AC_MSG_RESULT([yes])
57d86234 97 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"
98 else
475cdc78 99 AC_MSG_RESULT([no])
57d86234 100 AC_DEFINE([NDEBUG], [1],
101 [Define to 1 to disable debug tracing])
475cdc78 102 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
57d86234 103 fi
57d86234 104])
105
106AC_DEFUN([SPL_AC_DEBUG_KMEM], [
107 AC_MSG_CHECKING([whether kmem debugging is enabled])
108 AC_ARG_ENABLE( [debug-kmem],
109 AS_HELP_STRING([--enable-debug-kmem],
110 [Enable kmem debug support (default off)]),
111 [ case "$enableval" in
475cdc78 112 yes) spl_ac_debug_kmem=yes ;;
113 no) spl_ac_debug_kmem=no ;;
57d86234 114 *) AC_MSG_RESULT([Error!])
115 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;;
116 esac ]
117 )
475cdc78 118 if test "$spl_ac_debug_kmem" = yes; then
119 AC_MSG_RESULT([yes])
57d86234 120 AC_DEFINE([DEBUG_KMEM], [1],
121 [Define to 1 to enable kmem debugging])
475cdc78 122 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
123 else
124 AC_MSG_RESULT([no])
57d86234 125 fi
57d86234 126])
127
128AC_DEFUN([SPL_AC_DEBUG_MUTEX], [
129 AC_MSG_CHECKING([whether mutex debugging is enabled])
130 AC_ARG_ENABLE( [debug-mutex],
131 AS_HELP_STRING([--enable-debug-mutex],
132 [Enable mutex debug support (default off)]),
133 [ case "$enableval" in
475cdc78 134 yes) spl_ac_debug_mutex=yes ;;
135 no) spl_ac_debug_mutex=no ;;
57d86234 136 *) AC_MSG_RESULT([Error!])
137 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;;
138 esac ]
139 )
475cdc78 140 if test "$spl_ac_debug_mutex" = yes; then
141 AC_MSG_RESULT([yes])
57d86234 142 AC_DEFINE([DEBUG_MUTEX], [1],
143 [Define to 1 to enable mutex debugging])
475cdc78 144 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX"
145 else
146 AC_MSG_RESULT([no])
57d86234 147 fi
57d86234 148])
149
150AC_DEFUN([SPL_AC_DEBUG_KSTAT], [
151 AC_MSG_CHECKING([whether kstat debugging is enabled])
152 AC_ARG_ENABLE( [debug-kstat],
153 AS_HELP_STRING([--enable-debug-kstat],
154 [Enable kstat debug support (default off)]),
155 [ case "$enableval" in
475cdc78 156 yes) spl_ac_debug_kstat=yes ;;
157 no) spl_ac_debug_kstat=no ;;
57d86234 158 *) AC_MSG_RESULT([Error!])
159 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;;
160 esac ]
161 )
475cdc78 162 if test "$spl_ac_debug_kstat" = yes; then
163 AC_MSG_RESULT([yes])
57d86234 164 AC_DEFINE([DEBUG_KSTAT], [1],
165 [Define to 1 to enable kstat debugging])
475cdc78 166 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT"
167 else
168 AC_MSG_RESULT([no])
57d86234 169 fi
57d86234 170])
171
172AC_DEFUN([SPL_AC_DEBUG_CALLB], [
173 AC_MSG_CHECKING([whether callb debugging is enabled])
174 AC_ARG_ENABLE( [debug-callb],
175 AS_HELP_STRING([--enable-debug-callb],
176 [Enable callb debug support (default off)]),
177 [ case "$enableval" in
475cdc78 178 yes) spl_ac_debug_callb=yes ;;
179 no) spl_ac_debug_callb=no ;;
57d86234 180 *) AC_MSG_RESULT([Error!])
181 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;;
182 esac ]
183 )
475cdc78 184 if test "$spl_ac_debug_callb" = yes; then
185 AC_MSG_RESULT([yes])
57d86234 186 AC_DEFINE([DEBUG_CALLB], [1],
187 [Define to 1 to enable callb debugging])
475cdc78 188 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB"
189 else
190 AC_MSG_RESULT([no])
57d86234 191 fi
57d86234 192])
193
194dnl #
195dnl # SPL_LINUX_CONFTEST
196dnl #
197AC_DEFUN([SPL_LINUX_CONFTEST], [
198cat >conftest.c <<_ACEOF
199$1
200_ACEOF
201])
202
203dnl #
204dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
205dnl #
206m4_define([SPL_LANG_PROGRAM], [
207$1
208int
209main (void)
210{
211dnl Do *not* indent the following line: there may be CPP directives.
212dnl Don't move the `;' right after for the same reason.
213$2
214 ;
215 return 0;
216}
217])
218
219dnl #
220dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
221dnl #
222AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
223m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])dnl
224rm -f build/conftest.o build/conftest.mod.c build/conftest.ko build/Makefile
225echo "obj-m := conftest.o" >build/Makefile
226dnl AS_IF([AC_TRY_COMMAND(cp conftest.c build && make [$2] CC="$CC" -f $PWD/build/Makefile LINUXINCLUDE="-Iinclude -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 SUBDIRS=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
227AS_IF([AC_TRY_COMMAND(cp conftest.c build && make [$2] CC="$CC" LINUXINCLUDE="-Iinclude -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])],
228 [$4],
229 [_AC_MSG_LOG_CONFTEST
230m4_ifvaln([$5],[$5])dnl])dnl
231rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko m4_ifval([$1], [build/conftest.c conftest.c])[]dnl
232])
233
234dnl #
235dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
236dnl #
237AC_DEFUN([SPL_LINUX_TRY_COMPILE],
238 [SPL_LINUX_COMPILE_IFELSE(
d50bd9e2 239 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
240 [modules],
241 [test -s build/conftest.o],
242 [$3], [$4])
57d86234 243])
244
245dnl #
246dnl # SPL_LINUX_CONFIG
247dnl #
248AC_DEFUN([SPL_LINUX_CONFIG],
249 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
250 SPL_LINUX_TRY_COMPILE([
251 #ifndef AUTOCONF_INCLUDED
252 #include <linux/config.h>
253 #endif
254 ],[
255 #ifndef CONFIG_$1
256 #error CONFIG_$1 not #defined
257 #endif
258 ],[
259 AC_MSG_RESULT([yes])
260 $2
261 ],[
262 AC_MSG_RESULT([no])
263 $3
264 ])
265])
266
267dnl #
268dnl # SPL_CHECK_SYMBOL_EXPORT
269dnl # check symbol exported or not
270dnl #
271AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
272 [AC_MSG_CHECKING([whether symbol $1 is exported])
273 grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX/Module.symvers 2>/dev/null
274 rc=$?
275 if test $rc -ne 0; then
276 export=0
277 for file in $2; do
278 grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX/$file" 2>/dev/null
279 rc=$?
280 if test $rc -eq 0; then
281 export=1
282 break;
283 fi
284 done
285 if test $export -eq 0; then
286 AC_MSG_RESULT([no])
287 $4
288 else
289 AC_MSG_RESULT([yes])
290 $3
291 fi
292 else
293 AC_MSG_RESULT([yes])
294 $3
295 fi
296])
297
86de8532 298dnl #
299dnl # SPL_CHECK_HEADER
300dnl # check whether header exists and define HAVE_$2_HEADER
301dnl #
302AC_DEFUN([SPL_CHECK_HEADER],
303 [AC_MSG_CHECKING([whether header $1 exists])
304 SPL_LINUX_TRY_COMPILE([
d50bd9e2 305 #include <$1>
86de8532 306 ],[
307 return 0;
308 ],[
309 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
310 AC_MSG_RESULT(yes)
311 $3
312 ],[
313 AC_MSG_RESULT(no)
314 $4
315 ])
316])
6a6cafbe 317
57d86234 318dnl #
3d061e9d 319dnl # 2.6.24 API change,
57d86234 320dnl # check if uintptr_t typedef is defined
321dnl #
322AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
323 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
324 SPL_LINUX_TRY_COMPILE([
d50bd9e2 325 #include <linux/types.h>
57d86234 326 ],[
d50bd9e2 327 uintptr_t *ptr;
57d86234 328 ],[
d50bd9e2 329 AC_MSG_RESULT([yes])
330 AC_DEFINE(HAVE_UINTPTR_T, 1,
57d86234 331 [kernel defines uintptr_t])
332 ],[
d50bd9e2 333 AC_MSG_RESULT([no])
57d86234 334 ])
335])
336
a0f6da3d 337dnl #
338dnl # 2.6.x API change,
339dnl # check if atomic64_t typedef is defined
340dnl #
341AC_DEFUN([SPL_AC_TYPE_ATOMIC64_T],
342 [AC_MSG_CHECKING([whether kernel defines atomic64_t])
343 SPL_LINUX_TRY_COMPILE([
344 #include <asm/atomic.h>
345 ],[
346 atomic64_t *ptr;
347 ],[
348 AC_MSG_RESULT([yes])
349 AC_DEFINE(HAVE_ATOMIC64_T, 1,
350 [kernel defines atomic64_t])
351 ],[
352 AC_MSG_RESULT([no])
353 ])
354])
355
57d86234 356dnl #
3d061e9d 357dnl # 2.6.20 API change,
57d86234 358dnl # INIT_WORK use 2 args and not store data inside
359dnl #
360AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
361 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
362 SPL_LINUX_TRY_COMPILE([
d50bd9e2 363 #include <linux/workqueue.h>
57d86234 364 ],[
d50bd9e2 365 struct work_struct work;
366 INIT_WORK(&work, NULL, NULL);
57d86234 367 ],[
d50bd9e2 368 AC_MSG_RESULT(yes)
369 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
370 [INIT_WORK wants 3 args])
57d86234 371 ],[
d50bd9e2 372 AC_MSG_RESULT(no)
57d86234 373 ])
374])
375
376dnl #
3d061e9d 377dnl # 2.6.21 API change,
57d86234 378dnl # 'register_sysctl_table' use only one argument instead of two
379dnl #
380AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
381 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
382 SPL_LINUX_TRY_COMPILE([
d50bd9e2 383 #include <linux/sysctl.h>
57d86234 384 ],[
d50bd9e2 385 return register_sysctl_table(NULL,0);
57d86234 386 ],[
d50bd9e2 387 AC_MSG_RESULT(yes)
388 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
389 [register_sysctl_table() wants 2 args])
57d86234 390 ],[
d50bd9e2 391 AC_MSG_RESULT(no)
57d86234 392 ])
393])
394
57d86234 395dnl #
3d061e9d 396dnl # 2.6.23 API change
57d86234 397dnl # Old set_shrinker API replaced with register_shrinker
398dnl #
399AC_DEFUN([SPL_AC_SET_SHRINKER], [
400 AC_MSG_CHECKING([whether set_shrinker() available])
401 SPL_LINUX_TRY_COMPILE([
402 #include <linux/mm.h>
403 ],[
404 return set_shrinker(DEFAULT_SEEKS, NULL);
405 ],[
406 AC_MSG_RESULT([yes])
407 AC_DEFINE(HAVE_SET_SHRINKER, 1,
408 [set_shrinker() available])
409 ],[
410 AC_MSG_RESULT([no])
411 ])
412])
413
414dnl #
3d061e9d 415dnl # 2.6.25 API change,
57d86234 416dnl # struct path entry added to struct nameidata
417dnl #
418AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
419 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
420 SPL_LINUX_TRY_COMPILE([
d50bd9e2 421 #include <linux/namei.h>
57d86234 422 ],[
d50bd9e2 423 struct nameidata nd;
57d86234 424
425 nd.path.mnt = NULL;
426 nd.path.dentry = NULL;
427 ],[
d50bd9e2 428 AC_MSG_RESULT(yes)
429 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
430 [struct path used in struct nameidata])
57d86234 431 ],[
d50bd9e2 432 AC_MSG_RESULT(no)
57d86234 433 ])
434])
435
436dnl #
437dnl # Custom SPL patch may export this system it is not required
438dnl #
439AC_DEFUN([SPL_AC_TASK_CURR], [
440 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
441 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
442 [])
443])
444
445dnl #
3d061e9d 446dnl # 2.6.19 API change,
57d86234 447dnl # Use CTL_UNNUMBERED when binary sysctl is not required
448dnl #
449AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
450 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
451 SPL_LINUX_TRY_COMPILE([
d50bd9e2 452 #include <linux/sysctl.h>
57d86234 453 ],[
454 #ifndef CTL_UNNUMBERED
455 #error CTL_UNNUMBERED undefined
456 #endif
457 ],[
d50bd9e2 458 AC_MSG_RESULT(yes)
459 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
460 [unnumbered sysctl support exists])
57d86234 461 ],[
d50bd9e2 462 AC_MSG_RESULT(no)
57d86234 463 ])
464])
877a32e9 465
466dnl #
467dnl # 2.6.16 API change.
468dnl # Check if 'fls64()' is available
469dnl #
470AC_DEFUN([SPL_AC_FLS64],
6a6cafbe 471 [AC_MSG_CHECKING([whether fls64() is available])
472 SPL_LINUX_TRY_COMPILE([
473 #include <linux/bitops.h>
474 ],[
475 return fls64(0);
476 ],[
477 AC_MSG_RESULT(yes)
478 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
479 ],[
480 AC_MSG_RESULT(no)
481 ])
877a32e9 482])
46c685d0 483
484dnl #
485dnl # 2.6.18 API change, check whether device_create() is available.
486dnl # Device_create() was introduced in 2.6.18 and depricated
487dnl # class_device_create() which was fully removed in 2.6.26.
488dnl #
489AC_DEFUN([SPL_AC_DEVICE_CREATE], [
490 SPL_CHECK_SYMBOL_EXPORT(
491 [device_create],
492 [drivers/base/core.c],
493 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
494 [device_create() is available])],
6a6cafbe 495 [])
46c685d0 496])
497
498dnl #
499dnl # 2.6.13 API change, check whether class_device_create() is available.
500dnl # Class_device_create() was introduced in 2.6.13 and depricated
501dnl # class_simple_device_add() which was fully removed in 2.6.13.
502dnl #
503AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
504 SPL_CHECK_SYMBOL_EXPORT(
505 [class_device_create],
506 [drivers/base/class.c],
507 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
508 [class_device_create() is available])],
6a6cafbe 509 [])
46c685d0 510])
6a6cafbe 511
6a6cafbe 512dnl #
513dnl # 2.6.26 API change, set_normalized_timespec() is exported.
514dnl #
515AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
516 SPL_CHECK_SYMBOL_EXPORT(
517 [set_normalized_timespec],
518 [kernel/time.c],
519 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
520 [set_normalized_timespec() is available as export])],
521 [])
522])
523
524dnl #
525dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
526dnl # previously it was available in time.h as an inline.
527dnl #
86de8532 528AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
529 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
6a6cafbe 530 SPL_LINUX_TRY_COMPILE([
531 #include <linux/time.h>
6a6cafbe 532 void set_normalized_timespec(struct timespec *ts,
25557fd8 533 time_t sec, long nsec) { }
534 ],
535 [],
536 [
6a6cafbe 537 AC_MSG_RESULT(no)
538 ],[
539 AC_MSG_RESULT(yes)
540 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
541 [set_normalized_timespec() is available as inline])
542 ])
543])
544
545dnl #
546dnl # 2.6.18 API change,
547dnl # timespec_sub() inline function available in linux/time.h
548dnl #
86de8532 549AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
550 AC_MSG_CHECKING([whether timespec_sub() is available])
6a6cafbe 551 SPL_LINUX_TRY_COMPILE([
552 #include <linux/time.h>
553 ],[
554 struct timespec a, b, c = { 0 };
555 c = timespec_sub(a, b);
556 ],[
557 AC_MSG_RESULT(yes)
558 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
559 ],[
560 AC_MSG_RESULT(no)
561 ])
562])
563
86de8532 564dnl #
3d061e9d 565dnl # 2.6.19 API change,
566dnl # check if init_utsname() is available in linux/utsname.h
567dnl #
568AC_DEFUN([SPL_AC_INIT_UTSNAME], [
569 AC_MSG_CHECKING([whether init_utsname() is available])
570 SPL_LINUX_TRY_COMPILE([
571 #include <linux/utsname.h>
572 ],[
573 struct new_utsname *a = init_utsname();
574 ],[
575 AC_MSG_RESULT(yes)
576 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
577 ],[
578 AC_MSG_RESULT(no)
579 ])
580])
581
582dnl #
583dnl # 2.6.26 API change,
584dnl # definition of struct fdtable relocated to linux/fdtable.h
86de8532 585dnl #
586AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
587 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
588])
322640b7 589
590dnl #
3d061e9d 591dnl # 2.6.14 API change,
592dnl # check whether 'files_fdtable()' exists
593dnl #
594AC_DEFUN([SPL_AC_FILES_FDTABLE], [
595 AC_MSG_CHECKING([whether files_fdtable() is available])
596 SPL_LINUX_TRY_COMPILE([
597 #include <linux/sched.h>
598 #include <linux/file.h>
599 #ifdef HAVE_FDTABLE_HEADER
600 #include <linux/fdtable.h>
601 #endif
602 ],[
603 struct files_struct *files = current->files;
604 struct fdtable *fdt = files_fdtable(files);
605 ],[
606 AC_MSG_RESULT(yes)
607 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
608 ],[
609 AC_MSG_RESULT(no)
610 ])
611])
612
613dnl #
614dnl # 2.6.18 API change,
615dnl # added linux/uaccess.h
322640b7 616dnl #
617AC_DEFUN([SPL_AC_UACCESS_HEADER], [
618 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
619])
3d061e9d 620
621dnl #
622dnl # 2.6.12 API change,
623dnl # check whether 'kmalloc_node()' is available.
624dnl #
625AC_DEFUN([SPL_AC_KMALLOC_NODE], [
626 AC_MSG_CHECKING([whether kmalloc_node() is available])
627 SPL_LINUX_TRY_COMPILE([
628 #include <linux/slab.h>
629 ],[
630 void *a = kmalloc_node(1, GFP_KERNEL, 0);
631 ],[
632 AC_MSG_RESULT(yes)
633 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
634 ],[
635 AC_MSG_RESULT(no)
636 ])
637])
638
639dnl #
640dnl # 2.6.9 API change,
641dnl # check whether 'monotonic_clock()' is available it may
642dnl # be available for some archs but not others.
643dnl #
644AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
645 SPL_CHECK_SYMBOL_EXPORT(
646 [monotonic_clock],
647 [],
648 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
649 [monotonic_clock() is available])],
650 [])
651])
652
653dnl #
654dnl # 2.6.16 API change,
655dnl # check whether 'struct inode' has i_mutex
656dnl #
657AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
658 AC_MSG_CHECKING([whether struct inode has i_mutex])
659 SPL_LINUX_TRY_COMPILE([
660 #include <linux/fs.h>
661 #include <linux/mutex.h>
662 ],[
663 struct inode i;
664 mutex_init(&i.i_mutex);
665 ],[
666 AC_MSG_RESULT(yes)
667 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
668 ],[
669 AC_MSG_RESULT(no)
670 ])
671])
b61a6e8b 672
673dnl #
674dnl # 2.6.14 API change,
675dnl # check whether 'div64_64()' is available
676dnl #
677AC_DEFUN([SPL_AC_DIV64_64], [
678 AC_MSG_CHECKING([whether div64_64() is available])
679 SPL_LINUX_TRY_COMPILE([
680 #include <asm/div64.h>
550f1705 681 #include <linux/types.h>
b61a6e8b 682 ],[
683 uint64_t i = div64_64(1ULL, 1ULL);
684 ],[
685 AC_MSG_RESULT(yes)
686 AC_DEFINE(HAVE_DIV64_64, 1, [div64_64() is available])
687 ],[
688 AC_MSG_RESULT(no)
689 ])
690])