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 # 2.6.24 request not use real numbers for ctl_name
86 AC_DEFUN([LIBCFS_SYSCTL_UNNUMBERED],
87 [AC_MSG_CHECKING([for CTL_UNNUMBERED])
88 LB_LINUX_TRY_COMPILE([
89 #include <linux/sysctl.h>
91 #ifndef CTL_UNNUMBERED
92 #error CTL_UNNUMBERED not exist in kernel
96 AC_DEFINE(HAVE_SYSCTL_UNNUMBERED, 1,
97 [sysctl has CTL_UNNUMBERED])
103 # 2.6.27 have second argument to sock_map_fd
104 AC_DEFUN([LIBCFS_SOCK_MAP_FD_2ARG],
105 [AC_MSG_CHECKING([sock_map_fd have second argument])
106 LB_LINUX_TRY_COMPILE([
107 #include <linux/net.h>
109 sock_map_fd(NULL, 0);
112 AC_DEFINE(HAVE_SOCK_MAP_FD_2ARG, 1,
113 [sock_map_fd have second argument])
120 # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
122 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
124 AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK],
125 [AC_MSG_CHECKING([if 'struct stacktrace_ops' has 'walk_stack' field])
126 LB_LINUX_TRY_COMPILE([
127 #include <asm/stacktrace.h>
129 ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
132 AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1, ['struct stacktrace_ops' has 'walk_stack' field])
138 AC_DEFUN([LIBCFS_HAVE_KEYTYPE_H],
139 [LB_CHECK_FILE([$LINUX/include/linux/key-type.h], [
140 AC_DEFINE(HAVE_LINUX_KEYTYPE_H, 1,
141 [kernel has include/key-type.h])
148 # RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
150 AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR],
151 [AC_MSG_CHECKING([shrinker want self pointer in handler])
152 LB_LINUX_TRY_COMPILE([
153 #include <linux/mm.h>
155 struct shrinker *tmp = NULL;
156 tmp->shrink(tmp, 0, 0);
159 AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
160 [shrinker want self pointer in handler])
167 # 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
169 AC_DEFUN([LIBCFS_SYSCTL_CTLNAME],
170 [AC_MSG_CHECKING([if ctl_table has a ctl_name field])
171 LB_LINUX_TRY_COMPILE([
172 #include <linux/sysctl.h>
175 ct.ctl_name = sizeof(ct);
178 AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
179 [ctl_table has ctl_name field])
186 # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
188 # 2.6.34 adds __add_wait_queue_exclusive
190 AC_DEFUN([LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE],
191 [AC_MSG_CHECKING([if __add_wait_queue_exclusive exists])
192 LB_LINUX_TRY_COMPILE([
193 #include <linux/wait.h>
195 wait_queue_head_t queue;
198 __add_wait_queue_exclusive(&queue, &wait);
201 AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
202 [__add_wait_queue_exclusive exists])
209 # 2.6.35 kernel has sk_sleep function
211 AC_DEFUN([LC_SK_SLEEP],
212 [AC_MSG_CHECKING([if kernel has sk_sleep])
213 LB_LINUX_TRY_COMPILE([
214 #include <net/sock.h>
219 AC_DEFINE(HAVE_SK_SLEEP, 1, [kernel has sk_sleep])
226 # 2.6.39 adds a base pointer address argument to dump_trace
227 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS],
228 [AC_MSG_CHECKING([dump_trace want address])
229 LB_LINUX_TRY_COMPILE([
232 #include <asm/stacktrace.h>
234 dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
237 AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
238 [dump_trace want address argument])
246 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
247 # pressure shrinker from Linux 3.0
249 AC_DEFUN([LC_SHRINK_CONTROL],
250 [AC_MSG_CHECKING([shrink_control is present])
251 LB_LINUX_TRY_COMPILE([
252 #include <linux/mm.h>
254 struct shrink_control tmp = {0};
255 tmp.nr_to_scan = sizeof(tmp);
258 AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
259 [shrink_control is present])
265 # 3.0 removes stacktrace_ops warning* functions
266 AC_DEFUN([LIBCFS_STACKTRACE_WARNING],
267 [AC_MSG_CHECKING([whether stacktrace_ops.warning is exist])
268 LB_LINUX_TRY_COMPILE([
271 #include <asm/stacktrace.h>
273 ((struct stacktrace_ops *)0)->warning(NULL, NULL);
276 AC_DEFINE(HAVE_STACKTRACE_WARNING, 1, [stacktrace_ops.warning is exist])
284 # FC18 3.7.2-201 unexport sock_map_fd() change to
285 # use sock_alloc_file().
286 # upstream commit 56b31d1c9f1e6a3ad92e7bfe252721e05d92b285
288 AC_DEFUN([LIBCFS_SOCK_ALLOC_FILE],
289 [AC_MSG_CHECKING([sock_alloc_file is exported])
290 LB_CHECK_SYMBOL_EXPORT([sock_alloc_file], [net/socket.c],[
291 LB_LINUX_TRY_COMPILE([
292 #include <linux/net.h>
294 sock_alloc_file(NULL, 0, NULL);
297 AC_DEFINE(HAVE_SOCK_ALLOC_FILE_3ARGS, 1,
298 [sock_alloc_file takes 3 arguments])
301 AC_DEFINE(HAVE_SOCK_ALLOC_FILE, 1,
302 [sock_alloc_file is exported])
311 # LNet linux kernel checks
313 AC_DEFUN([LIBCFS_PROG_LINUX],
315 LIBCFS_CONFIG_PANIC_DUMPLOG
317 LIBCFS_U64_LONG_LONG_LINUX
319 LIBCFS_SYSCTL_UNNUMBERED
320 LIBCFS_HAVE_KEYTYPE_H
322 LIBCFS_SOCK_MAP_FD_2ARG
324 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
325 LC_SHRINKER_WANT_SHRINK_PTR
327 LIBCFS_SYSCTL_CTLNAME
329 LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
333 LIBCFS_DUMP_TRACE_ADDRESS
337 LIBCFS_STACKTRACE_WARNING
339 LIBCFS_SOCK_ALLOC_FILE
347 AC_DEFUN([LIBCFS_PROG_DARWIN],
348 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
352 # LIBCFS_PATH_DEFAULTS
354 # default paths for installed files
356 AC_DEFUN([LIBCFS_PATH_DEFAULTS],
363 # other configure checks
365 AC_DEFUN([LIBCFS_CONFIGURE],
366 [# lnet/utils/portals.c
367 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
370 AC_CHECK_HEADERS([linux/version.h])
372 AC_CHECK_TYPE([spinlock_t],
373 [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
375 [#include <linux/spinlock.h>])
377 # lnet/utils/wirecheck.c
378 AC_CHECK_FUNCS([strnlen])
380 # lnet/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
381 AC_CHECK_FUNCS([strlcpy])
383 # libcfs/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
384 AC_CHECK_FUNCS([strlcat])
386 AC_CHECK_TYPE([umode_t],
387 [AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
389 [#include <asm/types.h>])
391 AC_CHECK_TYPE([__s8],
392 [AC_DEFINE(HAVE___S8, 1, [__s8 is defined])],
394 [#include <asm/types.h>])
396 AC_CHECK_TYPE([__u8],
397 [AC_DEFINE(HAVE___U8, 1, [__u8 is defined])],
399 [#include <asm/types.h>])
401 AC_CHECK_TYPE([__s16],
402 [AC_DEFINE(HAVE___S16, 1, [__s16 is defined])],
404 [#include <asm/types.h>])
406 AC_CHECK_TYPE([__u16],
407 [AC_DEFINE(HAVE___U16, 1, [__u16 is defined])],
409 [#include <asm/types.h>])
411 AC_CHECK_TYPE([__s32],
412 [AC_DEFINE(HAVE___S32, 1, [__s32 is defined])],
414 [#include <asm/types.h>])
416 AC_CHECK_TYPE([__u32],
417 [AC_DEFINE(HAVE___U32, 1, [__u32 is defined])],
419 [#include <asm/types.h>])
421 AC_CHECK_TYPE([__u64],
422 [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
424 [#include <asm/types.h>])
426 AC_CHECK_TYPE([__s64],
427 [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
429 [#include <asm/types.h>])
431 # check userland __u64 type
432 AC_MSG_CHECKING([userspace __u64 is long long type])
434 CFLAGS="$CFLAGS -Werror"
437 #include <linux/types.h>
438 #include <linux/stddef.h>
440 unsigned long long *data1;
449 AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
450 [__u64 is long long type])
456 # -------- Check for required packages --------------
459 AC_MSG_CHECKING([if efence debugging support is requested])
460 AC_ARG_ENABLE(efence,
461 AC_HELP_STRING([--enable-efence],
462 [use efence library]),
463 [],[enable_efence='no'])
464 AC_MSG_RESULT([$enable_efence])
465 if test "$enable_efence" = "yes" ; then
467 AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
474 # -------- check for -lpthread support ----
475 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
476 AC_ARG_ENABLE([libpthread],
477 AC_HELP_STRING([--disable-libpthread],
478 [disable libpthread]),
479 [],[enable_libpthread=yes])
480 if test "$enable_libpthread" = "yes" ; then
481 AC_CHECK_LIB([pthread], [pthread_create],
482 [ENABLE_LIBPTHREAD="yes"],
483 [ENABLE_LIBPTHREAD="no"])
484 if test "$ENABLE_LIBPTHREAD" = "yes" ; then
485 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
486 PTHREAD_LIBS="-lpthread"
487 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
490 AC_MSG_RESULT([no libpthread is found])
492 AC_SUBST(PTHREAD_LIBS)
494 AC_MSG_RESULT([no (disabled explicitly)])
495 ENABLE_LIBPTHREAD="no"
497 AC_SUBST(ENABLE_LIBPTHREAD)
503 # LIBCFS_CONDITIONALS
505 # AM_CONDITOINAL defines for lnet
507 AC_DEFUN([LIBCFS_CONDITIONALS],
512 # LIBCFS_CONFIG_FILES
514 # files that should be generated with AC_OUTPUT
516 AC_DEFUN([LIBCFS_CONFIG_FILES],
521 libcfs/autoconf/Makefile
522 libcfs/include/Makefile
523 libcfs/include/libcfs/Makefile
524 libcfs/include/libcfs/linux/Makefile
525 libcfs/include/libcfs/posix/Makefile
526 libcfs/include/libcfs/util/Makefile
527 libcfs/libcfs/Makefile
528 libcfs/libcfs/autoMakefile
529 libcfs/libcfs/linux/Makefile
530 libcfs/libcfs/posix/Makefile
531 libcfs/libcfs/util/Makefile
532 libcfs/include/libcfs/darwin/Makefile
533 libcfs/libcfs/darwin/Makefile