4 # whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
6 AC_DEFUN([LN_CONFIG_CDEBUG],
8 AC_MSG_CHECKING([whether to enable CDEBUG, CWARN])
9 AC_ARG_ENABLE([libcfs_cdebug],
10 AC_HELP_STRING([--disable-libcfs-cdebug],
11 [disable libcfs CDEBUG, CWARN]),
12 [],[enable_libcfs_cdebug='yes'])
13 AC_MSG_RESULT([$enable_libcfs_cdebug])
14 if test x$enable_libcfs_cdebug = xyes; then
15 AC_DEFINE(CDEBUG_ENABLED, 1, [enable libcfs CDEBUG, CWARN])
17 AC_DEFINE(CDEBUG_ENABLED, 0, [disable libcfs CDEBUG, CWARN])
20 AC_MSG_CHECKING([whether to enable ENTRY/EXIT])
21 AC_ARG_ENABLE([libcfs_trace],
22 AC_HELP_STRING([--disable-libcfs-trace],
23 [disable libcfs ENTRY/EXIT]),
24 [],[enable_libcfs_trace='yes'])
25 AC_MSG_RESULT([$enable_libcfs_trace])
26 if test x$enable_libcfs_trace = xyes; then
27 AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])
29 AC_DEFINE(CDEBUG_ENTRY_EXIT, 0, [disable libcfs ENTRY/EXIT])
32 AC_MSG_CHECKING([whether to enable LASSERT, LASSERTF])
33 AC_ARG_ENABLE([libcfs_assert],
34 AC_HELP_STRING([--disable-libcfs-assert],
35 [disable libcfs LASSERT, LASSERTF]),
36 [],[enable_libcfs_assert='yes'])
37 AC_MSG_RESULT([$enable_libcfs_assert])
38 if test x$enable_libcfs_assert = xyes; then
39 AC_DEFINE(LIBCFS_DEBUG, 1, [enable libcfs LASSERT, LASSERTF])
44 # LIBCFS_CONFIG_PANIC_DUMPLOG
46 # check if tunable panic_dumplog is wanted
48 AC_DEFUN([LIBCFS_CONFIG_PANIC_DUMPLOG],
49 [AC_MSG_CHECKING([for tunable panic_dumplog support])
50 AC_ARG_ENABLE([panic_dumplog],
51 AC_HELP_STRING([--enable-panic_dumplog],
52 [enable panic_dumplog]),
53 [],[enable_panic_dumplog='no'])
54 if test x$enable_panic_dumplog = xyes ; then
55 AC_DEFINE(LNET_DUMP_ON_PANIC, 1, [use dumplog on panic])
56 AC_MSG_RESULT([yes (by request)])
63 # LIBCFS_FUNC_CPU_ONLINE
65 # cpu_online is different in rh 2.4, vanilla 2.4, and 2.6
67 AC_DEFUN([LIBCFS_FUNC_CPU_ONLINE],
68 [AC_MSG_CHECKING([if kernel defines cpu_online()])
69 LB_LINUX_TRY_COMPILE([
70 #include <linux/sched.h>
75 AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
84 # check if gfp_t is typedef-ed
86 AC_DEFUN([LIBCFS_TYPE_GFP_T],
87 [AC_MSG_CHECKING([if kernel defines gfp_t])
88 LB_LINUX_TRY_COMPILE([
89 #include <linux/gfp.h>
94 AC_DEFINE(HAVE_GFP_T, 1, [gfp_t found])
101 # LIBCFS_FUNC_SHOW_TASK
103 # we export show_task(), but not all kernels have it (yet)
105 AC_DEFUN([LIBCFS_FUNC_SHOW_TASK],
106 [LB_CHECK_SYMBOL_EXPORT([show_task],
107 [kernel/ksyms.c kernel/sched.c],[
108 AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
113 # check userland & kernel __u64 type
114 AC_DEFUN([LIBCFS_U64_LONG_LONG],
115 [AC_MSG_CHECKING([u64 is long long type])
117 CFLAGS="$CFLAGS -Werror"
120 #include <linux/types.h>
121 #include <linux/stddef.h>
123 unsigned long long *data1;
131 AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
132 [__u64 is long long type])
137 AC_MSG_CHECKING([kernel __u64 is long long type])
138 tmp_flags="$EXTRA_KCFLAGS"
139 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
140 LB_LINUX_TRY_COMPILE([
141 #include <linux/types.h>
142 #include <linux/stddef.h>
144 unsigned long long *data1;
150 AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
151 [kernel __u64 is long long type])
155 EXTRA_KCFLAGS="$tmp_flags"
158 # check if task_struct with rcu memeber
159 AC_DEFUN([LIBCFS_TASK_RCU],
160 [AC_MSG_CHECKING([if task_struct has a rcu field])
161 LB_LINUX_TRY_COMPILE([
162 #include <linux/sched.h>
164 struct task_struct tsk;
169 AC_DEFINE(HAVE_TASK_RCU, 1,
170 [task_struct has rcu field])
176 # LIBCFS_TASKLIST_LOCK
177 # 2.6.18 remove tasklist_lock export
178 AC_DEFUN([LIBCFS_TASKLIST_LOCK],
179 [LB_CHECK_SYMBOL_EXPORT([tasklist_lock],
181 AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
182 [tasklist_lock exported])
188 # kmem_cache_destroy(cachep) return void instead of
190 AC_DEFUN([LIBCFS_KMEM_CACHE_DESTROY_INT],
191 [AC_MSG_CHECKING([kmem_cache_destroy(cachep) return int])
192 LB_LINUX_TRY_COMPILE([
193 #include <linux/slab.h>
195 int i = kmem_cache_destroy(NULL);
198 AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT, 1,
199 [kmem_cache_destroy(cachep) return int])
206 #panic_notifier_list use atomic_notifier operations
208 AC_DEFUN([LIBCFS_ATOMIC_PANIC_NOTIFIER],
209 [AC_MSG_CHECKING([panic_notifier_list is atomic])
210 LB_LINUX_TRY_COMPILE([
211 #include <linux/notifier.h>
212 #include <linux/kernel.h>
214 struct atomic_notifier_head panic_notifier_list;
217 AC_DEFINE(HAVE_ATOMIC_PANIC_NOTIFIER, 1,
218 [panic_notifier_list is atomic_notifier_head])
224 # since 2.6.19 nlmsg_multicast() needs 5 argument.
225 AC_DEFUN([LIBCFS_NLMSG_MULTICAST],
226 [AC_MSG_CHECKING([nlmsg_multicast needs 5 argument])
227 LB_LINUX_TRY_COMPILE([
228 #include <net/netlink.h>
230 nlmsg_multicast(NULL, NULL, 0, 0, 0);
233 AC_DEFINE(HAVE_NLMSG_MULTICAST_5ARGS, 1,
234 [nlmsg_multicast needs 5 argument])
243 # If we have netlink.h, and nlmsg_new takes 2 args (2.6.19)
245 AC_DEFUN([LIBCFS_NETLINK],
246 [AC_MSG_CHECKING([if netlink.h can be compiled])
247 LB_LINUX_TRY_COMPILE([
248 #include <net/netlink.h>
251 AC_DEFINE(HAVE_NETLINK, 1, [net/netlink.h found])
253 AC_MSG_CHECKING([if nlmsg_new takes a 2nd argument])
254 LB_LINUX_TRY_COMPILE([
255 #include <net/netlink.h>
257 nlmsg_new(100, GFP_KERNEL);
260 AC_DEFINE(HAVE_NETLINK_NL2, 1, [nlmsg_new takes 2 args])
269 # 2.6.20 API change INIT_WORK use 2 args and not
271 AC_DEFUN([LIBCFS_3ARGS_INIT_WORK],
272 [AC_MSG_CHECKING([check INIT_WORK want 3 args])
273 LB_LINUX_TRY_COMPILE([
274 #include <linux/workqueue.h>
276 struct work_struct work;
278 INIT_WORK(&work, NULL, NULL);
281 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
282 [INIT_WORK use 3 args and store data inside])
288 # 2.6.21 api change. 'register_sysctl_table' use only one argument,
289 # instead of more old which need two.
290 AC_DEFUN([LIBCFS_2ARGS_REGISTER_SYSCTL],
291 [AC_MSG_CHECKING([check register_sysctl_table want 2 args])
292 LB_LINUX_TRY_COMPILE([
293 #include <linux/sysctl.h>
295 return register_sysctl_table(NULL,0);
298 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
299 [register_sysctl_table want 2 args])
305 # 2.6.21 marks kmem_cache_t deprecated and uses struct kmem_cache
307 AC_DEFUN([LIBCFS_KMEM_CACHE],
308 [AC_MSG_CHECKING([check kernel has struct kmem_cache])
309 tmp_flags="$EXTRA_KCFLAGS"
310 EXTRA_KCFLAGS="-Werror"
311 LB_LINUX_TRY_COMPILE([
312 #include <linux/slab.h>
313 typedef struct kmem_cache cache_t;
315 cache_t *cachep = NULL;
317 kmem_cache_alloc(cachep, 0);
320 AC_DEFINE(HAVE_KMEM_CACHE, 1,
321 [kernel has struct kmem_cache])
325 EXTRA_KCFLAGS="$tmp_flags"
328 # 2.6.23 lost dtor argument
329 AC_DEFUN([LIBCFS_KMEM_CACHE_CREATE_DTOR],
330 [AC_MSG_CHECKING([check kmem_cache_create has dtor argument])
331 LB_LINUX_TRY_COMPILE([
332 #include <linux/slab.h>
334 kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);
337 AC_DEFINE(HAVE_KMEM_CACHE_CREATE_DTOR, 1,
338 [kmem_cache_create has dtor argument])
345 AC_DEFUN([LIBCFS_NETLINK_CBMUTEX],
346 [AC_MSG_CHECKING([for mutex in netlink_kernel_create])
347 LB_LINUX_TRY_COMPILE([
348 #include <linux/netlink.h>
350 struct mutex *lock = NULL;
352 netlink_kernel_create(0, 0, NULL, lock, NULL);
355 AC_DEFINE(HAVE_NETLINK_CBMUTEX, 1,
356 [netlink_kernel_create want mutex for callback])
362 # 2.6.24 request not use real numbers for ctl_name
363 AC_DEFUN([LIBCFS_SYSCTL_UNNUMBERED],
364 [AC_MSG_CHECKING([for CTL_UNNUMBERED])
365 LB_LINUX_TRY_COMPILE([
366 #include <linux/sysctl.h>
368 #ifndef CTL_UNNUMBERED
369 #error CTL_UNNUMBERED not exist in kernel
373 AC_DEFINE(HAVE_SYSCTL_UNNUMBERED, 1,
374 [sysctl has CTL_UNNUMBERED])
380 # 2.6.24 lost scatterlist->page
381 AC_DEFUN([LIBCFS_SCATTERLIST_SETPAGE],
382 [AC_MSG_CHECKING([for exist sg_set_page])
383 LB_LINUX_TRY_COMPILE([
384 #include <asm/types.h>
385 #include <linux/scatterlist.h>
387 sg_set_page(NULL,NULL,0,0);
390 AC_DEFINE(HAVE_SCATTERLIST_SETPAGE, 1,
391 [struct scatterlist has page member])
398 AC_DEFUN([LIBCFS_NETWORK_NAMESPACE],
399 [AC_MSG_CHECKING([for network stack has namespaces])
400 LB_LINUX_TRY_COMPILE([
401 #include <net/net_namespace.h>
403 struct net *net = &init_net;
406 AC_DEFINE(HAVE_INIT_NET, 1,
407 [kernel is support network namespaces ])
415 AC_DEFUN([LIBCFS_NETLINK_NETNS],
416 [AC_MSG_CHECKING([for netlink support net ns])
417 LB_LINUX_TRY_COMPILE([
418 #include <linux/netlink.h>
420 struct net *net = NULL;
421 struct mutex *lock = NULL;
423 netlink_kernel_create(net, 0, 0, NULL,
428 AC_DEFINE(HAVE_NETLINK_NS, 1,
429 [netlink is support network namespace])
431 # for now - if kernel have netlink ns - he uses cbmutex
432 AC_DEFINE(HAVE_NETLINK_CBMUTEX, 1,
433 [netlink_kernel_create want mutex for callback])
441 AC_DEFUN([LIBCFS_NL_BROADCAST_GFP],
442 [AC_MSG_CHECKING([for netlink_broadcast is want to have gfp parameter])
443 LB_LINUX_TRY_COMPILE([
444 #include <linux/netlink.h>
446 gfp_t gfp = GFP_KERNEL;
448 netlink_broadcast(NULL, NULL, 0, 0, gfp);
451 AC_DEFINE(HAVE_NL_BROADCAST_GFP, 1,
452 [netlink brouacast is want to have gfp paramter])
459 # LIBCFS_FUNC_DUMP_TRACE
461 # 2.6.23 exports dump_trace() so we can dump_stack() on any task
462 # 2.6.24 has stacktrace_ops.address with "reliable" parameter
464 AC_DEFUN([LIBCFS_FUNC_DUMP_TRACE],
465 [LB_CHECK_SYMBOL_EXPORT([dump_trace],
466 [kernel/ksyms.c arch/${LINUX_ARCH%_64}/kernel/traps_64.c],[
467 tmp_flags="$EXTRA_KCFLAGS"
468 EXTRA_KCFLAGS="-Werror"
469 AC_MSG_CHECKING([whether we can really use dump_trace])
470 LB_LINUX_TRY_COMPILE([
473 #include <asm/stacktrace.h>
477 AC_DEFINE(HAVE_DUMP_TRACE, 1, [dump_trace is exported])
482 AC_MSG_CHECKING([whether print_trace_address has reliable argument])
483 LB_LINUX_TRY_COMPILE([
486 void print_addr(void *data, unsigned long addr, int reliable);
487 #include <asm/stacktrace.h>
489 struct stacktrace_ops ops;
491 ops.address = print_addr;
494 AC_DEFINE(HAVE_TRACE_ADDRESS_RELIABLE, 1,
495 [print_trace_address has reliable argument])
500 EXTRA_KCFLAGS="$tmp_flags"
505 # 2.6.26 use int instead of atomic for sem.count
506 AC_DEFUN([LIBCFS_SEM_COUNT],
507 [AC_MSG_CHECKING([atomic sem.count])
508 LB_LINUX_TRY_COMPILE([
509 #include <asm/semaphore.h>
513 atomic_read(&s.count);
516 AC_DEFINE(HAVE_SEM_COUNT_ATOMIC, 1,
517 [semaphore counter is atomic])
523 # 2.6.27 have second argument to sock_map_fd
524 AC_DEFUN([LIBCFS_SOCK_MAP_FD_2ARG],
525 [AC_MSG_CHECKING([sock_map_fd have second argument])
526 LB_LINUX_TRY_COMPILE([
527 #include <linux/net.h>
529 sock_map_fd(NULL, 0);
532 AC_DEFINE(HAVE_SOCK_MAP_FD_2ARG, 1,
533 [sock_map_fd have second argument])
539 # LIBCFS_CRED_WRAPPERS
541 # wrappers for task's credentials are in sles11
543 AC_DEFUN([LIBCFS_CRED_WRAPPERS],
544 [AC_MSG_CHECKING([if kernel has wrappers for task's credentials])
545 LB_LINUX_TRY_COMPILE([
546 #include <linux/sched.h>
553 AC_DEFINE(HAVE_CRED_WRAPPERS, 1, [task's cred wrappers found])
560 # LN_STRUCT_CRED_IN_TASK
562 # struct cred was introduced in 2.6.29 to streamline credentials in task struct
564 AC_DEFUN([LIBCFS_STRUCT_CRED_IN_TASK],
565 [AC_MSG_CHECKING([if kernel has struct cred])
566 LB_LINUX_TRY_COMPILE([
567 #include <linux/sched.h>
569 struct task_struct *tsk = NULL;
570 tsk->real_cred = NULL;
573 AC_DEFINE(HAVE_STRUCT_CRED, 1, [struct cred found])
580 # LIBCFS_FUNC_UNSHARE_FS_STRUCT
582 # unshare_fs_struct was introduced in 2.6.30 to prevent others to directly
583 # mess with copy_fs_struct
585 AC_DEFUN([LIBCFS_FUNC_UNSHARE_FS_STRUCT],
586 [AC_MSG_CHECKING([if kernel defines unshare_fs_struct()])
587 tmp_flags="$EXTRA_KCFLAGS"
588 EXTRA_KCFLAGS="-Werror"
589 LB_LINUX_TRY_COMPILE([
590 #include <linux/sched.h>
591 #include <linux/fs_struct.h>
596 AC_DEFINE(HAVE_UNSHARE_FS_STRUCT, 1, [unshare_fs_struct found])
600 EXTRA_KCFLAGS="$tmp_flags"
604 # LIBCFS_HAVE_IS_COMPAT_TASK
606 # Added in 2.6.17, it wasn't until 2.6.29 that all
607 # Linux architectures have is_compat_task()
609 AC_DEFUN([LIBCFS_HAVE_IS_COMPAT_TASK],
610 [AC_MSG_CHECKING([if is_compat_task() is declared])
611 LB_LINUX_TRY_COMPILE([
612 #include <linux/compat.h>
614 int i = is_compat_task();
617 AC_DEFINE(HAVE_IS_COMPAT_TASK, 1, [is_compat_task() is available])
626 # LNet linux kernel checks
628 AC_DEFUN([LIBCFS_PROG_LINUX],
630 LIBCFS_FUNC_CPU_ONLINE
632 LIBCFS_CONFIG_PANIC_DUMPLOG
634 LIBCFS_FUNC_SHOW_TASK
639 LIBCFS_HAVE_IS_COMPAT_TASK
642 LIBCFS_NLMSG_MULTICAST
643 LIBCFS_KMEM_CACHE_DESTROY_INT
644 LIBCFS_ATOMIC_PANIC_NOTIFIER
646 LIBCFS_3ARGS_INIT_WORK
648 LIBCFS_2ARGS_REGISTER_SYSCTL
651 LIBCFS_KMEM_CACHE_CREATE_DTOR
652 LIBCFS_NETLINK_CBMUTEX
654 LIBCFS_SYSCTL_UNNUMBERED
655 LIBCFS_SCATTERLIST_SETPAGE
656 LIBCFS_NL_BROADCAST_GFP
657 LIBCFS_NETWORK_NAMESPACE
659 LIBCFS_FUNC_DUMP_TRACE
665 LIBCFS_STRUCT_CRED_IN_TASK
667 LIBCFS_FUNC_UNSHARE_FS_STRUCT
668 LIBCFS_SOCK_MAP_FD_2ARG
676 AC_DEFUN([LIBCFS_PROG_DARWIN],
677 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
681 # LIBCFS_PATH_DEFAULTS
683 # default paths for installed files
685 AC_DEFUN([LIBCFS_PATH_DEFAULTS],
692 # other configure checks
694 AC_DEFUN([LIBCFS_CONFIGURE],
695 [# lnet/utils/portals.c
696 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
699 AC_CHECK_HEADERS([linux/version.h])
701 AC_CHECK_TYPE([spinlock_t],
702 [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
704 [#include <linux/spinlock.h>])
706 # lnet/utils/wirecheck.c
707 AC_CHECK_FUNCS([strnlen])
709 AC_CHECK_TYPE([umode_t],
710 [AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
712 [#include <asm/types.h>])
714 AC_CHECK_TYPE([__s8],
715 [AC_DEFINE(HAVE___S8, 1, [__s8 is defined])],
717 [#include <asm/types.h>])
719 AC_CHECK_TYPE([__u8],
720 [AC_DEFINE(HAVE___U8, 1, [__u8 is defined])],
722 [#include <asm/types.h>])
724 AC_CHECK_TYPE([__s16],
725 [AC_DEFINE(HAVE___S16, 1, [__s16 is defined])],
727 [#include <asm/types.h>])
729 AC_CHECK_TYPE([__u16],
730 [AC_DEFINE(HAVE___U16, 1, [__u16 is defined])],
732 [#include <asm/types.h>])
734 AC_CHECK_TYPE([__s32],
735 [AC_DEFINE(HAVE___S32, 1, [__s32 is defined])],
737 [#include <asm/types.h>])
739 AC_CHECK_TYPE([__u32],
740 [AC_DEFINE(HAVE___U32, 1, [__u32 is defined])],
742 [#include <asm/types.h>])
744 AC_CHECK_TYPE([__u64],
745 [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
747 [#include <asm/types.h>])
749 AC_CHECK_TYPE([__s64],
750 [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
752 [#include <asm/types.h>])
754 # -------- Check for required packages --------------
757 AC_MSG_CHECKING([if efence debugging support is requested])
758 AC_ARG_ENABLE(efence,
759 AC_HELP_STRING([--enable-efence],
760 [use efence library]),
761 [],[enable_efence='no'])
762 AC_MSG_RESULT([$enable_efence])
763 if test "$enable_efence" = "yes" ; then
765 AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
772 # -------- check for -lpthread support ----
773 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
774 AC_ARG_ENABLE([libpthread],
775 AC_HELP_STRING([--disable-libpthread],
776 [disable libpthread]),
777 [],[enable_libpthread=yes])
778 if test "$enable_libpthread" = "yes" ; then
779 AC_CHECK_LIB([pthread], [pthread_create],
780 [ENABLE_LIBPTHREAD="yes"],
781 [ENABLE_LIBPTHREAD="no"])
782 if test "$ENABLE_LIBPTHREAD" = "yes" ; then
783 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
784 PTHREAD_LIBS="-lpthread"
785 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
788 AC_MSG_RESULT([no libpthread is found])
790 AC_SUBST(PTHREAD_LIBS)
792 AC_MSG_RESULT([no (disabled explicitly)])
793 ENABLE_LIBPTHREAD="no"
795 AC_SUBST(ENABLE_LIBPTHREAD)
801 # LIBCFS_CONDITIONALS
803 # AM_CONDITOINAL defines for lnet
805 AC_DEFUN([LIBCFS_CONDITIONALS],
810 # LIBCFS_CONFIG_FILES
812 # files that should be generated with AC_OUTPUT
814 AC_DEFUN([LIBCFS_CONFIG_FILES],
819 libcfs/autoconf/Makefile
820 libcfs/include/Makefile
821 libcfs/include/libcfs/Makefile
822 libcfs/include/libcfs/linux/Makefile
823 libcfs/include/libcfs/posix/Makefile
824 libcfs/include/libcfs/util/Makefile
825 libcfs/libcfs/Makefile
826 libcfs/libcfs/autoMakefile
827 libcfs/libcfs/linux/Makefile
828 libcfs/libcfs/posix/Makefile
829 libcfs/libcfs/util/Makefile
830 libcfs/include/libcfs/darwin/Makefile
831 libcfs/libcfs/darwin/Makefile