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)])
62 # check kernel __u64 type
63 AC_DEFUN([LIBCFS_U64_LONG_LONG_LINUX],
65 AC_MSG_CHECKING([kernel __u64 is long long type])
66 tmp_flags="$EXTRA_KCFLAGS"
67 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
68 LB_LINUX_TRY_COMPILE([
69 #include <linux/types.h>
70 #include <linux/stddef.h>
72 unsigned long long *data;
74 data = (__u64*)sizeof(data);
77 AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
78 [kernel __u64 is long long type])
82 EXTRA_KCFLAGS="$tmp_flags"
85 # check cpumask_size (2.6.28)
86 AC_DEFUN([LIBCFS_CPUMASK_SIZE],
87 [AC_MSG_CHECKING([whether have cpumask_size()])
88 LB_LINUX_TRY_COMPILE([
89 #include <linux/cpumask.h>
91 int size = cpumask_size();
94 AC_DEFINE(HAVE_CPUMASK_SIZE, 1, [have cpumask_size()])
100 # 2.6.24 request not use real numbers for ctl_name
101 AC_DEFUN([LIBCFS_SYSCTL_UNNUMBERED],
102 [AC_MSG_CHECKING([for CTL_UNNUMBERED])
103 LB_LINUX_TRY_COMPILE([
104 #include <linux/sysctl.h>
106 #ifndef CTL_UNNUMBERED
107 #error CTL_UNNUMBERED not exist in kernel
111 AC_DEFINE(HAVE_SYSCTL_UNNUMBERED, 1,
112 [sysctl has CTL_UNNUMBERED])
118 # 2.6.27 have second argument to sock_map_fd
119 AC_DEFUN([LIBCFS_SOCK_MAP_FD_2ARG],
120 [AC_MSG_CHECKING([sock_map_fd have second argument])
121 LB_LINUX_TRY_COMPILE([
122 #include <linux/net.h>
124 sock_map_fd(NULL, 0);
127 AC_DEFINE(HAVE_SOCK_MAP_FD_2ARG, 1,
128 [sock_map_fd have second argument])
135 # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
137 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
139 AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK],
140 [AC_MSG_CHECKING([if 'struct stacktrace_ops' has 'walk_stack' field])
141 LB_LINUX_TRY_COMPILE([
142 #include <asm/stacktrace.h>
144 ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
147 AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1, ['struct stacktrace_ops' has 'walk_stack' field])
153 AC_DEFUN([LIBCFS_HAVE_KEYTYPE_H],
154 [LB_CHECK_FILE([$LINUX/include/linux/key-type.h], [
155 AC_DEFINE(HAVE_LINUX_KEYTYPE_H, 1,
156 [kernel has include/key-type.h])
163 # RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
165 AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR],
166 [AC_MSG_CHECKING([shrinker want self pointer in handler])
167 LB_LINUX_TRY_COMPILE([
168 #include <linux/mm.h>
170 struct shrinker *tmp = NULL;
171 tmp->shrink(tmp, 0, 0);
174 AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
175 [shrinker want self pointer in handler])
182 # 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
184 AC_DEFUN([LIBCFS_SYSCTL_CTLNAME],
185 [AC_MSG_CHECKING([if ctl_table has a ctl_name field])
186 LB_LINUX_TRY_COMPILE([
187 #include <linux/sysctl.h>
190 ct.ctl_name = sizeof(ct);
193 AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
194 [ctl_table has ctl_name field])
201 # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
203 # 2.6.34 adds __add_wait_queue_exclusive
205 AC_DEFUN([LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE],
206 [AC_MSG_CHECKING([if __add_wait_queue_exclusive exists])
207 LB_LINUX_TRY_COMPILE([
208 #include <linux/wait.h>
210 wait_queue_head_t queue;
213 __add_wait_queue_exclusive(&queue, &wait);
216 AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
217 [__add_wait_queue_exclusive exists])
224 # 2.6.35 kernel has sk_sleep function
226 AC_DEFUN([LC_SK_SLEEP],
227 [AC_MSG_CHECKING([if kernel has sk_sleep])
228 LB_LINUX_TRY_COMPILE([
229 #include <net/sock.h>
234 AC_DEFINE(HAVE_SK_SLEEP, 1, [kernel has sk_sleep])
241 # 2.6.39 adds a base pointer address argument to dump_trace
242 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS],
243 [AC_MSG_CHECKING([dump_trace want address])
244 LB_LINUX_TRY_COMPILE([
247 #include <asm/stacktrace.h>
249 dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
252 AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
253 [dump_trace want address argument])
261 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
262 # pressure shrinker from Linux 3.0
264 AC_DEFUN([LC_SHRINK_CONTROL],
265 [AC_MSG_CHECKING([shrink_control is present])
266 LB_LINUX_TRY_COMPILE([
267 #include <linux/mm.h>
269 struct shrink_control tmp = {0};
270 tmp.nr_to_scan = sizeof(tmp);
273 AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
274 [shrink_control is present])
280 # 3.0 removes stacktrace_ops warning* functions
281 AC_DEFUN([LIBCFS_STACKTRACE_WARNING],
282 [AC_MSG_CHECKING([whether stacktrace_ops.warning is exist])
283 LB_LINUX_TRY_COMPILE([
286 #include <asm/stacktrace.h>
288 ((struct stacktrace_ops *)0)->warning(NULL, NULL);
291 AC_DEFINE(HAVE_STACKTRACE_WARNING, 1, [stacktrace_ops.warning is exist])
299 # FC18 3.7.2-201 unexport sock_map_fd() change to
300 # use sock_alloc_file().
301 # upstream commit 56b31d1c9f1e6a3ad92e7bfe252721e05d92b285
303 AC_DEFUN([LIBCFS_SOCK_ALLOC_FILE],
304 [AC_MSG_CHECKING([sock_alloc_file is exported])
305 LB_CHECK_SYMBOL_EXPORT([sock_alloc_file], [net/socket.c],[
306 LB_LINUX_TRY_COMPILE([
307 #include <linux/net.h>
309 sock_alloc_file(NULL, 0, NULL);
312 AC_DEFINE(HAVE_SOCK_ALLOC_FILE_3ARGS, 1,
313 [sock_alloc_file takes 3 arguments])
316 AC_DEFINE(HAVE_SOCK_ALLOC_FILE, 1,
317 [sock_alloc_file is exported])
326 # LNet linux kernel checks
328 AC_DEFUN([LIBCFS_PROG_LINUX],
330 LIBCFS_CONFIG_PANIC_DUMPLOG
332 LIBCFS_U64_LONG_LONG_LINUX
334 LIBCFS_SYSCTL_UNNUMBERED
335 LIBCFS_HAVE_KEYTYPE_H
337 LIBCFS_SOCK_MAP_FD_2ARG
339 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
340 LC_SHRINKER_WANT_SHRINK_PTR
342 LIBCFS_SYSCTL_CTLNAME
344 LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
348 LIBCFS_DUMP_TRACE_ADDRESS
352 LIBCFS_STACKTRACE_WARNING
354 LIBCFS_SOCK_ALLOC_FILE
362 AC_DEFUN([LIBCFS_PROG_DARWIN],
363 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
367 # LIBCFS_PATH_DEFAULTS
369 # default paths for installed files
371 AC_DEFUN([LIBCFS_PATH_DEFAULTS],
378 # other configure checks
380 AC_DEFUN([LIBCFS_CONFIGURE],
381 [# lnet/utils/portals.c
382 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
385 AC_CHECK_HEADERS([linux/version.h])
387 AC_CHECK_TYPE([spinlock_t],
388 [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
390 [#include <linux/spinlock.h>])
392 # lnet/utils/wirecheck.c
393 AC_CHECK_FUNCS([strnlen])
395 # lnet/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
396 AC_CHECK_FUNCS([strlcpy])
398 # libcfs/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
399 AC_CHECK_FUNCS([strlcat])
401 AC_CHECK_TYPE([umode_t],
402 [AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
404 [#include <asm/types.h>])
406 AC_CHECK_TYPE([__s8],
407 [AC_DEFINE(HAVE___S8, 1, [__s8 is defined])],
409 [#include <asm/types.h>])
411 AC_CHECK_TYPE([__u8],
412 [AC_DEFINE(HAVE___U8, 1, [__u8 is defined])],
414 [#include <asm/types.h>])
416 AC_CHECK_TYPE([__s16],
417 [AC_DEFINE(HAVE___S16, 1, [__s16 is defined])],
419 [#include <asm/types.h>])
421 AC_CHECK_TYPE([__u16],
422 [AC_DEFINE(HAVE___U16, 1, [__u16 is defined])],
424 [#include <asm/types.h>])
426 AC_CHECK_TYPE([__s32],
427 [AC_DEFINE(HAVE___S32, 1, [__s32 is defined])],
429 [#include <asm/types.h>])
431 AC_CHECK_TYPE([__u32],
432 [AC_DEFINE(HAVE___U32, 1, [__u32 is defined])],
434 [#include <asm/types.h>])
436 AC_CHECK_TYPE([__u64],
437 [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
439 [#include <asm/types.h>])
441 AC_CHECK_TYPE([__s64],
442 [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
444 [#include <asm/types.h>])
446 # check userland __u64 type
447 AC_MSG_CHECKING([userspace __u64 is long long type])
449 CFLAGS="$CFLAGS -Werror"
452 #include <linux/types.h>
453 #include <linux/stddef.h>
455 unsigned long long *data1;
464 AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
465 [__u64 is long long type])
471 # -------- Check for required packages --------------
474 AC_MSG_CHECKING([if efence debugging support is requested])
475 AC_ARG_ENABLE(efence,
476 AC_HELP_STRING([--enable-efence],
477 [use efence library]),
478 [],[enable_efence='no'])
479 AC_MSG_RESULT([$enable_efence])
480 if test "$enable_efence" = "yes" ; then
482 AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
489 # -------- check for -lpthread support ----
490 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
491 AC_ARG_ENABLE([libpthread],
492 AC_HELP_STRING([--disable-libpthread],
493 [disable libpthread]),
494 [],[enable_libpthread=yes])
495 if test "$enable_libpthread" = "yes" ; then
496 AC_CHECK_LIB([pthread], [pthread_create],
497 [ENABLE_LIBPTHREAD="yes"],
498 [ENABLE_LIBPTHREAD="no"])
499 if test "$ENABLE_LIBPTHREAD" = "yes" ; then
500 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
501 PTHREAD_LIBS="-lpthread"
502 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
505 AC_MSG_RESULT([no libpthread is found])
507 AC_SUBST(PTHREAD_LIBS)
509 AC_MSG_RESULT([no (disabled explicitly)])
510 ENABLE_LIBPTHREAD="no"
512 AC_SUBST(ENABLE_LIBPTHREAD)
518 # LIBCFS_CONDITIONALS
520 # AM_CONDITOINAL defines for lnet
522 AC_DEFUN([LIBCFS_CONDITIONALS],
527 # LIBCFS_CONFIG_FILES
529 # files that should be generated with AC_OUTPUT
531 AC_DEFUN([LIBCFS_CONFIG_FILES],
536 libcfs/autoconf/Makefile
537 libcfs/include/Makefile
538 libcfs/include/libcfs/Makefile
539 libcfs/include/libcfs/linux/Makefile
540 libcfs/include/libcfs/posix/Makefile
541 libcfs/include/libcfs/util/Makefile
542 libcfs/libcfs/Makefile
543 libcfs/libcfs/autoMakefile
544 libcfs/libcfs/linux/Makefile
545 libcfs/libcfs/posix/Makefile
546 libcfs/libcfs/util/Makefile
547 libcfs/include/libcfs/darwin/Makefile
548 libcfs/libcfs/darwin/Makefile