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>
180 unsigned long long *data1;
188 AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
189 [__u64 is long long type])
194 AC_MSG_CHECKING([kernel __u64 is long long type])
195 tmp_flags="$EXTRA_KCFLAGS"
196 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
197 LB_LINUX_TRY_COMPILE([
198 #include <linux/types.h>
199 #include <linux/stddef.h>
201 unsigned long long *data1;
207 AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
208 [kernel __u64 is long long type])
212 EXTRA_KCFLAGS="$tmp_flags"
215 # check userland size_t type
216 AC_DEFUN([LIBCFS_SIZE_T_LONG],
217 [AC_MSG_CHECKING([size_t is unsigned long type])
219 CFLAGS="$CFLAGS -Werror"
221 #include <linux/types.h>
223 unsigned long *data1;
231 AC_DEFINE(HAVE_SIZE_T_LONG, 1,
232 [size_t is long type])
239 AC_DEFUN([LIBCFS_SSIZE_T_LONG],
240 [AC_MSG_CHECKING([ssize_t is signed long type])
242 CFLAGS="$CFLAGS -Werror"
244 #include <linux/types.h>
254 AC_DEFINE(HAVE_SSIZE_T_LONG, 1,
255 [ssize_t is long type])
263 # check if task_struct with rcu memeber
264 AC_DEFUN([LIBCFS_TASK_RCU],
265 [AC_MSG_CHECKING([if task_struct has a rcu field])
266 LB_LINUX_TRY_COMPILE([
267 #include <linux/sched.h>
269 struct task_struct tsk;
274 AC_DEFINE(HAVE_TASK_RCU, 1,
275 [task_struct has rcu field])
281 # LIBCFS_TASKLIST_LOCK
282 # 2.6.18 remove tasklist_lock export
283 AC_DEFUN([LIBCFS_TASKLIST_LOCK],
284 [LB_CHECK_SYMBOL_EXPORT([tasklist_lock],
286 AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
287 [tasklist_lock exported])
293 # kmem_cache_destroy(cachep) return void instead of
295 AC_DEFUN([LIBCFS_KMEM_CACHE_DESTROY_INT],
296 [AC_MSG_CHECKING([kmem_cache_destroy(cachep) return int])
297 LB_LINUX_TRY_COMPILE([
298 #include <linux/slab.h>
300 int i = kmem_cache_destroy(NULL);
303 AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT, 1,
304 [kmem_cache_destroy(cachep) return int])
311 #panic_notifier_list use atomic_notifier operations
313 AC_DEFUN([LIBCFS_ATOMIC_PANIC_NOTIFIER],
314 [AC_MSG_CHECKING([panic_notifier_list is atomic])
315 LB_LINUX_TRY_COMPILE([
316 #include <linux/notifier.h>
317 #include <linux/kernel.h>
319 struct atomic_notifier_head panic_notifier_list;
322 AC_DEFINE(HAVE_ATOMIC_PANIC_NOTIFIER, 1,
323 [panic_notifier_list is atomic_notifier_head])
329 # 2.6.20 API change INIT_WORK use 2 args and not
331 AC_DEFUN([LIBCFS_3ARGS_INIT_WORK],
332 [AC_MSG_CHECKING([check INIT_WORK want 3 args])
333 LB_LINUX_TRY_COMPILE([
334 #include <linux/workqueue.h>
336 struct work_struct work;
338 INIT_WORK(&work, NULL, NULL);
341 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
342 [INIT_WORK use 3 args and store data inside])
348 # 2.6.21 api change. 'register_sysctl_table' use only one argument,
349 # instead of more old which need two.
350 AC_DEFUN([LIBCFS_2ARGS_REGISTER_SYSCTL],
351 [AC_MSG_CHECKING([check register_sysctl_table want 2 args])
352 LB_LINUX_TRY_COMPILE([
353 #include <linux/sysctl.h>
355 return register_sysctl_table(NULL,0);
358 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
359 [register_sysctl_table want 2 args])
365 # 2.6.21 marks kmem_cache_t deprecated and uses struct kmem_cache
367 AC_DEFUN([LIBCFS_KMEM_CACHE],
368 [AC_MSG_CHECKING([check kernel has struct kmem_cache])
369 tmp_flags="$EXTRA_KCFLAGS"
370 EXTRA_KCFLAGS="-Werror"
371 LB_LINUX_TRY_COMPILE([
372 #include <linux/slab.h>
373 typedef struct kmem_cache cache_t;
375 cache_t *cachep = NULL;
377 kmem_cache_alloc(cachep, 0);
380 AC_DEFINE(HAVE_KMEM_CACHE, 1,
381 [kernel has struct kmem_cache])
385 EXTRA_KCFLAGS="$tmp_flags"
387 # 2.6.23 lost dtor argument
388 AC_DEFUN([LIBCFS_KMEM_CACHE_CREATE_DTOR],
389 [AC_MSG_CHECKING([check kmem_cache_create has dtor argument])
390 LB_LINUX_TRY_COMPILE([
391 #include <linux/slab.h>
393 kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);
396 AC_DEFINE(HAVE_KMEM_CACHE_CREATE_DTOR, 1,
397 [kmem_cache_create has dtor argument])
403 # 2.6.24 request not use real numbers for ctl_name
404 AC_DEFUN([LN_SYSCTL_UNNUMBERED],
405 [AC_MSG_CHECKING([for CTL_UNNUMBERED])
406 LB_LINUX_TRY_COMPILE([
407 #include <linux/sysctl.h>
409 #ifndef CTL_UNNUMBERED
410 #error CTL_UNNUMBERED not exist in kernel
414 AC_DEFINE(HAVE_SYSCTL_UNNUMBERED, 1,
415 [sysctl has CTL_UNNUMBERED])
421 # 2.6.24 lost scatterlist->page
422 AC_DEFUN([LN_SCATTERLIST_SETPAGE],
423 [AC_MSG_CHECKING([for exist sg_set_page])
424 LB_LINUX_TRY_COMPILE([
425 #include <linux/scatterlist.h>
427 sg_set_page(NULL,NULL,0,0);
430 AC_DEFINE(HAVE_SCATTERLIST_SETPAGE, 1,
431 [struct scatterlist has page member])
437 # 2.6.26 use int instead of atomic for sem.count
438 AC_DEFUN([LN_SEM_COUNT],
439 [AC_MSG_CHECKING([atomic sem.count])
440 LB_LINUX_TRY_COMPILE([
441 #include <asm/semaphore.h>
445 atomic_read(&s.count);
448 AC_DEFINE(HAVE_SEM_COUNT_ATOMIC, 1,
449 [semaphore counter is atomic])
458 # LNet linux kernel checks
460 AC_DEFUN([LIBCFS_PROG_LINUX],
462 LIBCFS_FUNC_CPU_ONLINE
464 LIBCFS_TYPE_CPUMASK_T
465 LIBCFS_CONFIG_PANIC_DUMPLOG
467 LIBCFS_STRUCT_PAGE_LIST
468 LIBCFS_STRUCT_SIGHAND
469 LIBCFS_FUNC_SHOW_TASK
477 LIBCFS_KMEM_CACHE_DESTROY_INT
478 LIBCFS_ATOMIC_PANIC_NOTIFIER
480 LIBCFS_3ARGS_INIT_WORK
482 LIBCFS_2ARGS_REGISTER_SYSCTL
485 LIBCFS_KMEM_CACHE_CREATE_DTOR
488 LN_SCATTERLIST_SETPAGE
498 AC_DEFUN([LIBCFS_PROG_DARWIN],
499 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
503 # LIBCFS_PATH_DEFAULTS
505 # default paths for installed files
507 AC_DEFUN([LIBCFS_PATH_DEFAULTS],
514 # other configure checks
516 AC_DEFUN([LIBCFS_CONFIGURE],
517 [# lnet/utils/portals.c
518 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
521 AC_CHECK_HEADERS([linux/version.h])
523 AC_CHECK_TYPE([spinlock_t],
524 [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
526 [#include <linux/spinlock.h>])
528 # lnet/utils/wirecheck.c
529 AC_CHECK_FUNCS([strnlen])
531 AC_CHECK_TYPE([umode_t],
532 [AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
534 [#include <asm/types.h>])
536 AC_CHECK_TYPE([__u64],
537 [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
539 [#include <asm/types.h>])
541 AC_CHECK_TYPE([__s64],
542 [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
544 [#include <asm/types.h>])
546 # -------- Check for required packages --------------
549 AC_MSG_CHECKING([if efence debugging support is requested])
550 AC_ARG_ENABLE(efence,
551 AC_HELP_STRING([--enable-efence],
552 [use efence library]),
553 [],[enable_efence='no'])
554 AC_MSG_RESULT([$enable_efence])
555 if test "$enable_efence" = "yes" ; then
557 AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
564 # -------- check for -lpthread support ----
565 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
566 AC_ARG_ENABLE([libpthread],
567 AC_HELP_STRING([--disable-libpthread],
568 [disable libpthread]),
569 [],[enable_libpthread=yes])
570 if test "$enable_libpthread" = "yes" ; then
571 AC_CHECK_LIB([pthread], [pthread_create],
572 [ENABLE_LIBPTHREAD="yes"],
573 [ENABLE_LIBPTHREAD="no"])
574 if test "$ENABLE_LIBPTHREAD" = "yes" ; then
575 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
576 PTHREAD_LIBS="-lpthread"
577 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
580 AC_MSG_RESULT([no libpthread is found])
582 AC_SUBST(PTHREAD_LIBS)
584 AC_MSG_RESULT([no (disabled explicitly)])
585 ENABLE_LIBPTHREAD="no"
587 AC_SUBST(ENABLE_LIBPTHREAD)
593 # LIBCFS_CONDITIONALS
595 # AM_CONDITOINAL defines for lnet
597 AC_DEFUN([LIBCFS_CONDITIONALS],
602 # LIBCFS_CONFIG_FILES
604 # files that should be generated with AC_OUTPUT
606 AC_DEFUN([LIBCFS_CONFIG_FILES],
611 libcfs/autoconf/Makefile
612 libcfs/include/Makefile
613 libcfs/include/libcfs/Makefile
614 libcfs/include/libcfs/linux/Makefile
615 libcfs/include/libcfs/posix/Makefile
616 libcfs/include/libcfs/util/Makefile
617 libcfs/libcfs/Makefile
618 libcfs/libcfs/autoMakefile
619 libcfs/libcfs/linux/Makefile
620 libcfs/libcfs/ulinux/Makefile
621 libcfs/libcfs/posix/Makefile
622 libcfs/libcfs/util/Makefile
624 case $lb_target_os in
627 libcfs/include/libcfs/darwin/Makefile
628 libcfs/libcfs/darwin/Makefile