4 # whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
6 AC_DEFUN([LN_CONFIG_CDEBUG], [
7 AC_MSG_CHECKING([whether to enable CDEBUG, CWARN])
8 AC_ARG_ENABLE([libcfs_cdebug],
9 AC_HELP_STRING([--disable-libcfs-cdebug],
10 [disable libcfs CDEBUG, CWARN]),
11 [], [enable_libcfs_cdebug="yes"])
12 AC_MSG_RESULT([$enable_libcfs_cdebug])
13 AS_IF([test "x$enable_libcfs_cdebug" = xyes],
14 [AC_DEFINE(CDEBUG_ENABLED, 1, [enable libcfs CDEBUG, CWARN])])
16 AC_MSG_CHECKING([whether to enable ENTRY/EXIT])
17 AC_ARG_ENABLE([libcfs_trace],
18 AC_HELP_STRING([--disable-libcfs-trace],
19 [disable libcfs ENTRY/EXIT]),
20 [], [enable_libcfs_trace="yes"])
21 AC_MSG_RESULT([$enable_libcfs_trace])
22 AS_IF([test "x$enable_libcfs_trace" = xyes],
23 [AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])])
25 AC_MSG_CHECKING([whether to enable LASSERT, LASSERTF])
26 AC_ARG_ENABLE([libcfs_assert],
27 AC_HELP_STRING([--disable-libcfs-assert],
28 [disable libcfs LASSERT, LASSERTF]),
29 [], [enable_libcfs_assert="yes"])
30 AC_MSG_RESULT([$enable_libcfs_assert])
31 AS_IF([test x$enable_libcfs_assert = xyes],
32 [AC_DEFINE(LIBCFS_DEBUG, 1, [enable libcfs LASSERT, LASSERTF])])
36 # LIBCFS_CONFIG_PANIC_DUMPLOG
38 # check if tunable panic_dumplog is wanted
40 AC_DEFUN([LIBCFS_CONFIG_PANIC_DUMPLOG], [
41 AC_MSG_CHECKING([whether to use tunable 'panic_dumplog' support])
42 AC_ARG_ENABLE([panic_dumplog],
43 AC_HELP_STRING([--enable-panic_dumplog],
44 [enable panic_dumplog]),
45 [], [enable_panic_dumplog="no"])
46 AC_MSG_RESULT([$enable_panic_dumplog])
47 AS_IF([test "x$enable_panic_dumplog" = xyes],
48 [AC_DEFINE(LNET_DUMP_ON_PANIC, 1, [use dumplog on panic])])
49 ]) # LIBCFS_CONFIG_PANIC_DUMPLOG
52 # LIBCFS_U64_LONG_LONG_LINUX
54 # check kernel __u64 type
56 AC_DEFUN([LIBCFS_U64_LONG_LONG_LINUX], [
57 tmp_flags="$EXTRA_KCFLAGS"
58 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
59 LB_CHECK_COMPILE([if Linux kernel '__u64' is 'long long' type],
60 kernel_u64_long_long, [
61 #include <linux/types.h>
62 #include <linux/stddef.h>
64 unsigned long long *data;
65 data = (__u64*)sizeof(data);
67 AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
68 [Linux kernel __u64 is long long type])
70 EXTRA_KCFLAGS="$tmp_flags"
71 ]) # LIBCFS_U64_LONG_LONG_LINUX
74 # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
76 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
78 AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK], [
79 LB_CHECK_COMPILE([if 'struct stacktrace_ops' has 'walk_stack' field],
80 stacktrace_ops_walk_stack, [
81 #include <asm/stacktrace.h>
83 ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
85 AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1,
86 ['struct stacktrace_ops' has 'walk_stack' field])
88 ]) # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
91 # LIBCFS_STACKTRACE_WARNING
93 # 3.0 removes stacktrace_ops warning* functions
95 AC_DEFUN([LIBCFS_STACKTRACE_WARNING], [
96 LB_CHECK_COMPILE([if 'stacktrace_ops.warning' is exist],
97 stacktrace_ops_warning, [
100 #include <asm/stacktrace.h>
102 ((struct stacktrace_ops *)0)->warning(NULL, NULL);
104 AC_DEFINE(HAVE_STACKTRACE_WARNING, 1,
105 [stacktrace_ops.warning is exist])
107 ]) # LIBCFS_STACKTRACE_WARNING
110 # LC_SHRINKER_WANT_SHRINK_PTR
112 # RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
114 AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR], [
115 LB_CHECK_COMPILE([if 'shrinker' want self pointer in handler],
116 shrink_self_pointer, [
117 #include <linux/mm.h>
119 struct shrinker *tmp = NULL;
120 tmp->shrink(tmp, 0, 0);
122 AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
123 [shrinker want self pointer in handler])
125 ]) # LC_SHRINKER_WANT_SHRINK_PTR
128 # LIBCFS_SYSCTL_CTLNAME
130 # 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
132 AC_DEFUN([LIBCFS_SYSCTL_CTLNAME], [
133 LB_CHECK_COMPILE([if 'ctl_table' has a 'ctl_name' field],
134 ctl_table_ctl_name, [
135 #include <linux/sysctl.h>
138 ct.ctl_name = sizeof(ct);
140 AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
141 [ctl_table has ctl_name field])
143 ]) # LIBCFS_SYSCTL_CTLNAME
146 # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
148 # 2.6.34 adds __add_wait_queue_exclusive
150 AC_DEFUN([LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE], [
151 LB_CHECK_COMPILE([if '__add_wait_queue_exclusive' exists],
152 __add_wait_queue_exclusive, [
153 #include <linux/wait.h>
155 wait_queue_head_t queue;
157 __add_wait_queue_exclusive(&queue, &wait);
159 AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
160 [__add_wait_queue_exclusive exists])
162 ]) # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
167 # 2.6.35 kernel has sk_sleep function
169 AC_DEFUN([LC_SK_SLEEP], [
170 LB_CHECK_COMPILE([if Linux kernel has 'sk_sleep'],
172 #include <net/sock.h>
176 AC_DEFINE(HAVE_SK_SLEEP, 1,
177 [kernel has sk_sleep])
182 # LIBCFS_DUMP_TRACE_ADDRESS
184 # 2.6.39 adds a base pointer address argument to dump_trace
186 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS], [
187 LB_CHECK_COMPILE([if 'dump_trace' want address],
188 dump_trace_address, [
191 #include <asm/stacktrace.h>
193 dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
195 AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
196 [dump_trace want address argument])
198 ]) # LIBCFS_DUMP_TRACE_ADDRESS
203 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
204 # pressure shrinker from Linux 3.0
206 AC_DEFUN([LC_SHRINK_CONTROL], [
207 LB_CHECK_COMPILE([if 'shrink_control' is present],
209 #include <linux/mm.h>
211 struct shrink_control tmp = {0};
212 tmp.nr_to_scan = sizeof(tmp);
214 AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
215 [shrink_control is present])
217 ]) # LC_SHRINK_CONTROL
220 # LIBCFS_PROCESS_NAMESPACE
222 # 3.4 introduced process namespace
223 AC_DEFUN([LIBCFS_PROCESS_NAMESPACE], [
224 LB_CHECK_LINUX_HEADER([linux/uidgid.h], [
225 AC_DEFINE(HAVE_UIDGID_HEADER, 1,
226 [uidgid.h is present])])
227 ]) # LIBCFS_PROCESS_NAMESPACE
230 # LIBCFS_SOCK_ALLOC_FILE
232 # FC18 3.7.2-201 unexport sock_map_fd() change to
233 # use sock_alloc_file().
234 # upstream commit 56b31d1c9f1e6a3ad92e7bfe252721e05d92b285
236 AC_DEFUN([LIBCFS_SOCK_ALLOC_FILE], [
237 LB_CHECK_EXPORT([sock_alloc_file], [net/socket.c], [
238 LB_CHECK_COMPILE([if 'sock_alloc_file' takes 3 arguments],
239 sock_alloc_file_3args, [
240 #include <linux/net.h>
242 sock_alloc_file(NULL, 0, NULL);
244 AC_DEFINE(HAVE_SOCK_ALLOC_FILE_3ARGS, 1,
245 [sock_alloc_file takes 3 arguments])
247 AC_DEFINE(HAVE_SOCK_ALLOC_FILE, 1,
248 [sock_alloc_file is exported])
251 ]) # LIBCFS_SOCK_ALLOC_FILE
256 AC_DEFUN([LIBCFS_HAVE_CRC32], [
257 LB_CHECK_CONFIG_IM([CRC32],
258 [have_crc32="yes"], [have_crc32="no"])
259 AS_IF([test "x$have_crc32" = xyes],
260 [AC_DEFINE(HAVE_CRC32, 1,
261 [kernel compiled with CRC32 functions])])
262 ]) # LIBCFS_HAVE_CRC32
265 # LIBCFS_ENABLE_CRC32_ACCEL
267 AC_DEFUN([LIBCFS_ENABLE_CRC32_ACCEL], [
268 LB_CHECK_CONFIG_IM([CRYPTO_CRC32_PCLMUL],
269 [enable_crc32_crypto="no"], [enable_crc32_crypto="yes"])
270 AS_IF([test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes], [
271 AC_DEFINE(NEED_CRC32_ACCEL, 1, [need pclmulqdq based crc32])
274 No crc32 pclmulqdq crypto api found, enable internal pclmulqdq based crc32
276 ]) # LIBCFS_ENABLE_CRC32_ACCEL
279 # LIBCFS_ENABLE_CRC32C_ACCEL
281 AC_DEFUN([LIBCFS_ENABLE_CRC32C_ACCEL], [
282 LB_CHECK_CONFIG_IM([CRYPTO_CRC32C_INTEL],
283 [enable_crc32c_crypto="no"], [enable_crc32c_crypto="yes"])
284 AS_IF([test "x$enable_crc32c_crypto" = xyes], [
285 AC_DEFINE(NEED_CRC32C_ACCEL, 1, [need pclmulqdq based crc32c])
288 No crc32c pclmulqdq crypto api found, enable internal pclmulqdq based crc32c
290 ]) # LIBCFS_ENABLE_CRC32C_ACCEL
295 # LibCFS linux kernel checks
297 AC_DEFUN([LIBCFS_PROG_LINUX], [
298 AC_MSG_NOTICE([LibCFS kernel checks
299 ==============================================================================])
300 LIBCFS_CONFIG_PANIC_DUMPLOG
302 LIBCFS_U64_LONG_LONG_LINUX
304 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
305 LC_SHRINKER_WANT_SHRINK_PTR
307 LIBCFS_SYSCTL_CTLNAME
309 LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
313 LIBCFS_DUMP_TRACE_ADDRESS
317 LIBCFS_STACKTRACE_WARNING
319 LIBCFS_PROCESS_NAMESPACE
321 LIBCFS_SOCK_ALLOC_FILE
324 LIBCFS_ENABLE_CRC32_ACCEL
326 LIBCFS_ENABLE_CRC32C_ACCEL
327 ]) # LIBCFS_PROG_LINUX
334 AC_DEFUN([LIBCFS_PROG_DARWIN], [
335 LB_DARWIN_CHECK_FUNCS([get_preemption_level])
336 ]) # LIBCFS_PROG_DARWIN
339 # LIBCFS_PATH_DEFAULTS
341 # default paths for installed files
343 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
344 ]) # LIBCFS_PATH_DEFAULTS
349 # other configure checks
351 AC_DEFUN([LIBCFS_CONFIGURE], [
352 AC_MSG_NOTICE([LibCFS core checks
353 ==============================================================================])
355 # lnet/utils/portals.c
356 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
359 AC_CHECK_HEADERS([linux/version.h])
361 AC_CHECK_TYPE([spinlock_t],
362 [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
364 [#include <linux/spinlock.h>])
366 # lnet/utils/wirecheck.c
367 AC_CHECK_FUNCS([strnlen])
369 # lnet/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
370 AC_CHECK_FUNCS([strlcpy])
372 # libcfs/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
373 AC_CHECK_FUNCS([strlcat])
375 AC_CHECK_TYPE([umode_t],
376 [AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
378 [#include <asm/types.h>])
380 AC_CHECK_TYPE([__s8],
381 [AC_DEFINE(HAVE___S8, 1, [__s8 is defined])],
383 [#include <asm/types.h>])
385 AC_CHECK_TYPE([__u8],
386 [AC_DEFINE(HAVE___U8, 1, [__u8 is defined])],
388 [#include <asm/types.h>])
390 AC_CHECK_TYPE([__s16],
391 [AC_DEFINE(HAVE___S16, 1, [__s16 is defined])],
393 [#include <asm/types.h>])
395 AC_CHECK_TYPE([__u16],
396 [AC_DEFINE(HAVE___U16, 1, [__u16 is defined])],
398 [#include <asm/types.h>])
400 AC_CHECK_TYPE([__s32],
401 [AC_DEFINE(HAVE___S32, 1, [__s32 is defined])],
403 [#include <asm/types.h>])
405 AC_CHECK_TYPE([__u32],
406 [AC_DEFINE(HAVE___U32, 1, [__u32 is defined])],
408 [#include <asm/types.h>])
410 AC_CHECK_TYPE([__u64],
411 [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
413 [#include <asm/types.h>])
415 AC_CHECK_TYPE([__s64],
416 [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
418 [#include <asm/types.h>])
420 # check userland __u64 type
422 CFLAGS="$CFLAGS -Werror"
423 AC_CACHE_CHECK([if userspace '__u64' is 'long long' type],
424 lb_cv_compile_userspace_u64_long_long, [
425 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
427 #include <linux/types.h>
428 #include <linux/stddef.h>
430 unsigned long long *data1;
437 [lb_cv_compile_userspace_u64_long_long="yes"],
438 [lb_cv_compile_userspace_u64_long_long="no"])
441 AS_IF([test "x$lb_cv_compile_userspace_u64_long_long" = xyes],
442 [AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
443 [__u64 is long long type])])
445 # -------- Check for required packages --------------
447 AC_MSG_NOTICE([LibCFS required packages checks
448 ==============================================================================])
450 AC_MSG_CHECKING([whether to enable 'efence' debugging support])
451 AC_ARG_ENABLE(efence,
452 AC_HELP_STRING([--enable-efence],
453 [use efence library]),
454 [], [enable_efence="no"])
455 AC_MSG_RESULT([$enable_efence])
456 AS_IF([test "$enable_efence" = yes], [
458 AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
464 # -------- check for -lpthread support ----
466 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
467 AC_ARG_ENABLE([libpthread],
468 AC_HELP_STRING([--disable-libpthread],
469 [disable libpthread]),
470 [], [enable_libpthread="yes"])
471 AC_MSG_RESULT([$enable_libpthread])
472 AS_IF([test "x$enable_libpthread" = xyes], [
473 AC_CHECK_LIB([pthread], [pthread_create],
474 [ENABLE_LIBPTHREAD="yes"],
475 [ENABLE_LIBPTHREAD="no"])
476 AS_IF([test "$ENABLE_LIBPTHREAD" = yes], [
477 PTHREAD_LIBS="-lpthread"
478 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
482 AC_SUBST(PTHREAD_LIBS)
484 AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
485 ENABLE_LIBPTHREAD="no"
487 AC_SUBST(ENABLE_LIBPTHREAD)
488 ]) # LIBCFS_CONFIGURE
491 # LIBCFS_CONDITIONALS
493 AC_DEFUN([LIBCFS_CONDITIONALS], [
494 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
495 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32, [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
496 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
497 ]) # LIBCFS_CONDITIONALS
500 # LIBCFS_CONFIG_FILES
502 # files that should be generated with AC_OUTPUT
504 AC_DEFUN([LIBCFS_CONFIG_FILES], [
509 libcfs/autoconf/Makefile
510 libcfs/include/Makefile
511 libcfs/include/libcfs/Makefile
512 libcfs/include/libcfs/linux/Makefile
513 libcfs/include/libcfs/posix/Makefile
514 libcfs/include/libcfs/util/Makefile
515 libcfs/libcfs/Makefile
516 libcfs/libcfs/autoMakefile
517 libcfs/libcfs/linux/Makefile
518 libcfs/libcfs/posix/Makefile
519 libcfs/libcfs/util/Makefile
520 libcfs/include/libcfs/darwin/Makefile
521 libcfs/libcfs/darwin/Makefile
523 ]) # LIBCFS_CONFIG_FILES