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_STRUCT_PAGE_LIST
65 # 2.6.4 no longer has page->list
67 AC_DEFUN([LIBCFS_STRUCT_PAGE_LIST],
68 [AC_MSG_CHECKING([if struct page has a list field])
69 LB_LINUX_TRY_COMPILE([
76 AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
83 # LIBCFS_STRUCT_SIGHAND
85 # red hat 2.4 adds sighand to struct task_struct
87 AC_DEFUN([LIBCFS_STRUCT_SIGHAND],
88 [AC_MSG_CHECKING([if task_struct has a sighand field])
89 LB_LINUX_TRY_COMPILE([
90 #include <linux/sched.h>
95 AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
103 # LIBCFS_FUNC_CPU_ONLINE
105 # cpu_online is different in rh 2.4, vanilla 2.4, and 2.6
107 AC_DEFUN([LIBCFS_FUNC_CPU_ONLINE],
108 [AC_MSG_CHECKING([if kernel defines cpu_online()])
109 LB_LINUX_TRY_COMPILE([
110 #include <linux/sched.h>
115 AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
124 # check if gfp_t is typedef-ed
126 AC_DEFUN([LIBCFS_TYPE_GFP_T],
127 [AC_MSG_CHECKING([if kernel defines gfp_t])
128 LB_LINUX_TRY_COMPILE([
129 #include <linux/gfp.h>
131 return sizeof(gfp_t);
134 AC_DEFINE(HAVE_GFP_T, 1, [gfp_t found])
141 # LIBCFS_TYPE_CPUMASK_T
143 # same goes for cpumask_t
145 AC_DEFUN([LIBCFS_TYPE_CPUMASK_T],
146 [AC_MSG_CHECKING([if kernel defines cpumask_t])
147 LB_LINUX_TRY_COMPILE([
148 #include <linux/sched.h>
150 return sizeof (cpumask_t);
153 AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found])
160 # LIBCFS_FUNC_SHOW_TASK
162 # we export show_task(), but not all kernels have it (yet)
164 AC_DEFUN([LIBCFS_FUNC_SHOW_TASK],
165 [LB_CHECK_SYMBOL_EXPORT([show_task],
166 [kernel/ksyms.c kernel/sched.c],[
167 AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
172 # check userland & kernel __u64 type
173 AC_DEFUN([LIBCFS_U64_LONG_LONG],
174 [AC_MSG_CHECKING([u64 is long long type])
176 CFLAGS="$CFLAGS -Werror"
178 #include <linux/types.h>
179 #include <linux/stddef.h>
181 unsigned long long *data1;
189 AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
190 [__u64 is long long type])
195 AC_MSG_CHECKING([kernel __u64 is long long type])
196 tmp_flags="$EXTRA_KCFLAGS"
197 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
198 LB_LINUX_TRY_COMPILE([
199 #include <linux/types.h>
200 #include <linux/stddef.h>
202 unsigned long long *data1;
208 AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
209 [kernel __u64 is long long type])
213 EXTRA_KCFLAGS="$tmp_flags"
216 # check userland size_t type
217 AC_DEFUN([LIBCFS_SIZE_T_LONG],
218 [AC_MSG_CHECKING([size_t is unsigned long type])
220 CFLAGS="$CFLAGS -Werror"
222 #include <linux/types.h>
223 #include <linux/stddef.h>
225 unsigned long *data1;
226 size_t *data2 = NULL;
233 AC_DEFINE(HAVE_SIZE_T_LONG, 1,
234 [size_t is long type])
241 AC_DEFUN([LIBCFS_SSIZE_T_LONG],
242 [AC_MSG_CHECKING([ssize_t is signed long type])
244 CFLAGS="$CFLAGS -Werror"
246 #include <linux/types.h>
247 #include <linux/stddef.h>
250 ssize_t *data2 = NULL;
257 AC_DEFINE(HAVE_SSIZE_T_LONG, 1,
258 [ssize_t is long type])
266 # check if task_struct with rcu memeber
267 AC_DEFUN([LIBCFS_TASK_RCU],
268 [AC_MSG_CHECKING([if task_struct has a rcu field])
269 LB_LINUX_TRY_COMPILE([
270 #include <linux/sched.h>
272 struct task_struct tsk;
277 AC_DEFINE(HAVE_TASK_RCU, 1,
278 [task_struct has rcu field])
284 # LIBCFS_TASKLIST_LOCK
285 # 2.6.18 remove tasklist_lock export
286 AC_DEFUN([LIBCFS_TASKLIST_LOCK],
287 [LB_CHECK_SYMBOL_EXPORT([tasklist_lock],
289 AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
290 [tasklist_lock exported])
296 # kmem_cache_destroy(cachep) return void instead of
298 AC_DEFUN([LIBCFS_KMEM_CACHE_DESTROY_INT],
299 [AC_MSG_CHECKING([kmem_cache_destroy(cachep) return int])
300 LB_LINUX_TRY_COMPILE([
301 #include <linux/slab.h>
303 int i = kmem_cache_destroy(NULL);
306 AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT, 1,
307 [kmem_cache_destroy(cachep) return int])
314 #panic_notifier_list use atomic_notifier operations
316 AC_DEFUN([LIBCFS_ATOMIC_PANIC_NOTIFIER],
317 [AC_MSG_CHECKING([panic_notifier_list is atomic])
318 LB_LINUX_TRY_COMPILE([
319 #include <linux/notifier.h>
320 #include <linux/kernel.h>
322 struct atomic_notifier_head panic_notifier_list;
325 AC_DEFINE(HAVE_ATOMIC_PANIC_NOTIFIER, 1,
326 [panic_notifier_list is atomic_notifier_head])
332 # since 2.6.19 nlmsg_multicast() needs 5 argument.
333 AC_DEFUN([LIBCFS_NLMSG_MULTICAST],
334 [AC_MSG_CHECKING([nlmsg_multicast needs 5 argument])
335 LB_LINUX_TRY_COMPILE([
336 #include <net/netlink.h>
338 nlmsg_multicast(NULL, NULL, 0, 0, 0);
341 AC_DEFINE(HAVE_NLMSG_MULTICAST_5ARGS, 1,
342 [nlmsg_multicast needs 5 argument])
351 # If we have netlink.h, and nlmsg_new takes 2 args (2.6.19)
353 AC_DEFUN([LIBCFS_NETLINK],
354 [AC_MSG_CHECKING([if netlink.h can be compiled])
355 LB_LINUX_TRY_COMPILE([
356 #include <net/netlink.h>
359 AC_DEFINE(HAVE_NETLINK, 1, [net/netlink.h found])
361 AC_MSG_CHECKING([if nlmsg_new takes a 2nd argument])
362 LB_LINUX_TRY_COMPILE([
363 #include <net/netlink.h>
365 nlmsg_new(100, GFP_KERNEL);
368 AC_DEFINE(HAVE_NETLINK_NL2, 1, [nlmsg_new takes 2 args])
377 # 2.6.20 API change INIT_WORK use 2 args and not
379 AC_DEFUN([LIBCFS_3ARGS_INIT_WORK],
380 [AC_MSG_CHECKING([check INIT_WORK want 3 args])
381 LB_LINUX_TRY_COMPILE([
382 #include <linux/workqueue.h>
384 struct work_struct work;
386 INIT_WORK(&work, NULL, NULL);
389 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
390 [INIT_WORK use 3 args and store data inside])
396 # 2.6.21 api change. 'register_sysctl_table' use only one argument,
397 # instead of more old which need two.
398 AC_DEFUN([LIBCFS_2ARGS_REGISTER_SYSCTL],
399 [AC_MSG_CHECKING([check register_sysctl_table want 2 args])
400 LB_LINUX_TRY_COMPILE([
401 #include <linux/sysctl.h>
403 return register_sysctl_table(NULL,0);
406 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
407 [register_sysctl_table want 2 args])
413 # 2.6.21 marks kmem_cache_t deprecated and uses struct kmem_cache
415 AC_DEFUN([LIBCFS_KMEM_CACHE],
416 [AC_MSG_CHECKING([check kernel has struct kmem_cache])
417 tmp_flags="$EXTRA_KCFLAGS"
418 EXTRA_KCFLAGS="-Werror"
419 LB_LINUX_TRY_COMPILE([
420 #include <linux/slab.h>
421 typedef struct kmem_cache cache_t;
423 cache_t *cachep = NULL;
425 kmem_cache_alloc(cachep, 0);
428 AC_DEFINE(HAVE_KMEM_CACHE, 1,
429 [kernel has struct kmem_cache])
433 EXTRA_KCFLAGS="$tmp_flags"
436 # 2.6.23 lost dtor argument
437 AC_DEFUN([LIBCFS_KMEM_CACHE_CREATE_DTOR],
438 [AC_MSG_CHECKING([check kmem_cache_create has dtor argument])
439 LB_LINUX_TRY_COMPILE([
440 #include <linux/slab.h>
442 kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);
445 AC_DEFINE(HAVE_KMEM_CACHE_CREATE_DTOR, 1,
446 [kmem_cache_create has dtor argument])
453 AC_DEFUN([LIBCFS_NETLINK_CBMUTEX],
454 [AC_MSG_CHECKING([for mutex in netlink_kernel_create])
455 LB_LINUX_TRY_COMPILE([
456 #include <linux/netlink.h>
458 struct mutex *lock = NULL;
460 netlink_kernel_create(0, 0, NULL, lock, NULL);
463 AC_DEFINE(HAVE_NETLINK_CBMUTEX, 1,
464 [netlink_kernel_create want mutex for callback])
470 # 2.6.24 request not use real numbers for ctl_name
471 AC_DEFUN([LIBCFS_SYSCTL_UNNUMBERED],
472 [AC_MSG_CHECKING([for CTL_UNNUMBERED])
473 LB_LINUX_TRY_COMPILE([
474 #include <linux/sysctl.h>
476 #ifndef CTL_UNNUMBERED
477 #error CTL_UNNUMBERED not exist in kernel
481 AC_DEFINE(HAVE_SYSCTL_UNNUMBERED, 1,
482 [sysctl has CTL_UNNUMBERED])
488 # 2.6.24 lost scatterlist->page
489 AC_DEFUN([LIBCFS_SCATTERLIST_SETPAGE],
490 [AC_MSG_CHECKING([for exist sg_set_page])
491 LB_LINUX_TRY_COMPILE([
492 #include <linux/scatterlist.h>
494 sg_set_page(NULL,NULL,0,0);
497 AC_DEFINE(HAVE_SCATTERLIST_SETPAGE, 1,
498 [struct scatterlist has page member])
505 AC_DEFUN([LIBCFS_NETWORK_NAMESPACE],
506 [AC_MSG_CHECKING([for network stack has namespaces])
507 LB_LINUX_TRY_COMPILE([
508 #include <net/net_namespace.h>
510 struct net *net = &init_ns;
513 AC_DEFINE(HAVE_INIT_NET, 1,
514 [kernel is support network namespaces ])
522 AC_DEFUN([LIBCFS_NETLINK_NETNS],
523 [AC_MSG_CHECKING([for netlink support net ns])
524 LB_LINUX_TRY_COMPILE([
525 #include <linux/netlink.h>
527 struct net *net = NULL;
528 struct mutex *lock = NULL;
530 netlink_kernel_create(net, 0, 0, NULL,
535 AC_DEFINE(HAVE_NETLINK_NS, 1,
536 [netlink is support network namespace])
538 # for now - if kernel have netlink ns - he uses cbmutex
539 AC_DEFINE(HAVE_NETLINK_CBMUTEX, 1,
540 [netlink_kernel_create want mutex for callback])
548 AC_DEFUN([LIBCFS_NL_BROADCAST_GFP],
549 [AC_MSG_CHECKING([for netlink_broadcast is want to have gfp parameter])
550 LB_LINUX_TRY_COMPILE([
551 #include <linux/netlink.h>
553 gfp_t gfp = GFP_KERNEL;
555 netlink_broadcast(NULL, NULL, 0, 0, gfp);
558 AC_DEFINE(HAVE_NL_BROADCAST_GFP, 1,
559 [netlink brouacast is want to have gfp paramter])
566 # LIBCFS_FUNC_DUMP_TRACE
568 # 2.6.23 exports dump_trace() so we can dump_stack() on any task
569 # 2.6.24 has stacktrace_ops.address with "reliable" parameter
571 AC_DEFUN([LIBCFS_FUNC_DUMP_TRACE],
572 [LB_CHECK_SYMBOL_EXPORT([dump_trace],
573 [kernel/ksyms.c arch/${LINUX_ARCH%_64}/kernel/traps_64.c],[
574 tmp_flags="$EXTRA_KCFLAGS"
575 EXTRA_KCFLAGS="-Werror"
576 AC_MSG_CHECKING([whether we can really use dump_stack])
577 LB_LINUX_TRY_COMPILE([
580 #include <asm/stacktrace.h>
584 AC_DEFINE(HAVE_DUMP_TRACE, 1, [dump_trace is exported])
589 AC_MSG_CHECKING([whether print_trace_address has reliable argument])
590 LB_LINUX_TRY_COMPILE([
593 void print_addr(void *data, unsigned long addr, int reliable);
594 #include <asm/stacktrace.h>
596 struct stacktrace_ops ops;
598 ops.address = print_addr;
601 AC_DEFINE(HAVE_TRACE_ADDRESS_RELIABLE, 1,
602 [print_trace_address has reliable argument])
607 EXTRA_KCFLAGS="$tmp_flags"
612 # 2.6.26 use int instead of atomic for sem.count
613 AC_DEFUN([LIBCFS_SEM_COUNT],
614 [AC_MSG_CHECKING([atomic sem.count])
615 LB_LINUX_TRY_COMPILE([
616 #include <asm/semaphore.h>
620 atomic_read(&s.count);
623 AC_DEFINE(HAVE_SEM_COUNT_ATOMIC, 1,
624 [semaphore counter is atomic])
630 # 2.6.27 have second argument to sock_map_fd
631 AC_DEFUN([LIBCFS_SOCK_MAP_FD_2ARG],
632 [AC_MSG_CHECKING([sock_map_fd have second argument])
633 LB_LINUX_TRY_COMPILE([
634 #include <linux/net.h>
636 sock_map_fd(NULL, 0);
639 AC_DEFINE(HAVE_SOCK_MAP_FD_2ARG, 1,
640 [sock_map_fd have second argument])
649 # LNet linux kernel checks
651 AC_DEFUN([LIBCFS_PROG_LINUX],
653 LIBCFS_FUNC_CPU_ONLINE
655 LIBCFS_TYPE_CPUMASK_T
656 LIBCFS_CONFIG_PANIC_DUMPLOG
658 LIBCFS_STRUCT_PAGE_LIST
659 LIBCFS_STRUCT_SIGHAND
660 LIBCFS_FUNC_SHOW_TASK
669 LIBCFS_NLMSG_MULTICAST
670 LIBCFS_KMEM_CACHE_DESTROY_INT
671 LIBCFS_ATOMIC_PANIC_NOTIFIER
673 LIBCFS_3ARGS_INIT_WORK
675 LIBCFS_2ARGS_REGISTER_SYSCTL
678 LIBCFS_KMEM_CACHE_CREATE_DTOR
679 LIBCFS_NETLINK_CBMUTEX
681 LIBCFS_SYSCTL_UNNUMBERED
682 LIBCFS_SCATTERLIST_SETPAGE
683 LIBCFS_NL_BROADCAST_GFP
684 LIBCFS_NETWORK_NAMESPACE
686 LIBCFS_FUNC_DUMP_TRACE
689 LIBCFS_SOCK_MAP_FD_2ARG
697 AC_DEFUN([LIBCFS_PROG_DARWIN],
698 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
702 # LIBCFS_PATH_DEFAULTS
704 # default paths for installed files
706 AC_DEFUN([LIBCFS_PATH_DEFAULTS],
713 # other configure checks
715 AC_DEFUN([LIBCFS_CONFIGURE],
716 [# lnet/utils/portals.c
717 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
720 AC_CHECK_HEADERS([linux/version.h])
722 AC_CHECK_TYPE([spinlock_t],
723 [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
725 [#include <linux/spinlock.h>])
727 # lnet/utils/wirecheck.c
728 AC_CHECK_FUNCS([strnlen])
730 AC_CHECK_TYPE([umode_t],
731 [AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
733 [#include <asm/types.h>])
735 AC_CHECK_TYPE([__u64],
736 [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
738 [#include <asm/types.h>])
740 AC_CHECK_TYPE([__s64],
741 [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
743 [#include <asm/types.h>])
745 # -------- Check for required packages --------------
748 AC_MSG_CHECKING([if efence debugging support is requested])
749 AC_ARG_ENABLE(efence,
750 AC_HELP_STRING([--enable-efence],
751 [use efence library]),
752 [],[enable_efence='no'])
753 AC_MSG_RESULT([$enable_efence])
754 if test "$enable_efence" = "yes" ; then
756 AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
763 # -------- check for -lpthread support ----
764 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
765 AC_ARG_ENABLE([libpthread],
766 AC_HELP_STRING([--disable-libpthread],
767 [disable libpthread]),
768 [],[enable_libpthread=yes])
769 if test "$enable_libpthread" = "yes" ; then
770 AC_CHECK_LIB([pthread], [pthread_create],
771 [ENABLE_LIBPTHREAD="yes"],
772 [ENABLE_LIBPTHREAD="no"])
773 if test "$ENABLE_LIBPTHREAD" = "yes" ; then
774 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
775 PTHREAD_LIBS="-lpthread"
776 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
779 AC_MSG_RESULT([no libpthread is found])
781 AC_SUBST(PTHREAD_LIBS)
783 AC_MSG_RESULT([no (disabled explicitly)])
784 ENABLE_LIBPTHREAD="no"
786 AC_SUBST(ENABLE_LIBPTHREAD)
792 # LIBCFS_CONDITIONALS
794 # AM_CONDITOINAL defines for lnet
796 AC_DEFUN([LIBCFS_CONDITIONALS],
801 # LIBCFS_CONFIG_FILES
803 # files that should be generated with AC_OUTPUT
805 AC_DEFUN([LIBCFS_CONFIG_FILES],
810 libcfs/autoconf/Makefile
811 libcfs/include/Makefile
812 libcfs/include/libcfs/Makefile
813 libcfs/include/libcfs/linux/Makefile
814 libcfs/include/libcfs/posix/Makefile
815 libcfs/include/libcfs/util/Makefile
816 libcfs/libcfs/Makefile
817 libcfs/libcfs/autoMakefile
818 libcfs/libcfs/linux/Makefile
819 libcfs/libcfs/ulinux/Makefile
820 libcfs/libcfs/posix/Makefile
821 libcfs/libcfs/util/Makefile
823 case $lb_target_os in
826 libcfs/include/libcfs/darwin/Makefile
827 libcfs/libcfs/darwin/Makefile