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_STACKTRACE_OPS_HAVE_WALK_STACK
54 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
56 AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK], [
57 LB_CHECK_COMPILE([if 'struct stacktrace_ops' has 'walk_stack' field],
58 stacktrace_ops_walk_stack, [
59 #include <asm/stacktrace.h>
61 ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
63 AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1,
64 ['struct stacktrace_ops' has 'walk_stack' field])
66 ]) # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
69 # LIBCFS_STACKTRACE_WARNING
71 # 3.0 removes stacktrace_ops warning* functions
73 AC_DEFUN([LIBCFS_STACKTRACE_WARNING], [
74 LB_CHECK_COMPILE([if 'stacktrace_ops.warning' is exist],
75 stacktrace_ops_warning, [
78 #include <asm/stacktrace.h>
80 ((struct stacktrace_ops *)0)->warning(NULL, NULL);
82 AC_DEFINE(HAVE_STACKTRACE_WARNING, 1,
83 [stacktrace_ops.warning is exist])
85 ]) # LIBCFS_STACKTRACE_WARNING
88 # LC_SHRINKER_WANT_SHRINK_PTR
90 # RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
92 AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR], [
93 LB_CHECK_COMPILE([if 'shrinker' want self pointer in handler],
94 shrink_self_pointer, [
97 struct shrinker *tmp = NULL;
98 tmp->shrink(tmp, 0, 0);
100 AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
101 [shrinker want self pointer in handler])
103 ]) # LC_SHRINKER_WANT_SHRINK_PTR
106 # LIBCFS_SYSCTL_CTLNAME
108 # 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
110 AC_DEFUN([LIBCFS_SYSCTL_CTLNAME], [
111 LB_CHECK_COMPILE([if 'ctl_table' has a 'ctl_name' field],
112 ctl_table_ctl_name, [
113 #include <linux/sysctl.h>
116 ct.ctl_name = sizeof(ct);
118 AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
119 [ctl_table has ctl_name field])
121 ]) # LIBCFS_SYSCTL_CTLNAME
124 # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
126 # 2.6.34 adds __add_wait_queue_exclusive
128 AC_DEFUN([LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE], [
129 LB_CHECK_COMPILE([if '__add_wait_queue_exclusive' exists],
130 __add_wait_queue_exclusive, [
131 #include <linux/wait.h>
133 wait_queue_head_t queue;
135 __add_wait_queue_exclusive(&queue, &wait);
137 AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
138 [__add_wait_queue_exclusive exists])
140 ]) # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
145 # 2.6.35 kernel has sk_sleep function
147 AC_DEFUN([LC_SK_SLEEP], [
148 LB_CHECK_COMPILE([if Linux kernel has 'sk_sleep'],
150 #include <net/sock.h>
154 AC_DEFINE(HAVE_SK_SLEEP, 1,
155 [kernel has sk_sleep])
160 # LIBCFS_DUMP_TRACE_ADDRESS
162 # 2.6.39 adds a base pointer address argument to dump_trace
164 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS], [
165 LB_CHECK_COMPILE([if 'dump_trace' want address],
166 dump_trace_address, [
169 #include <asm/stacktrace.h>
171 dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
173 AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
174 [dump_trace want address argument])
176 ]) # LIBCFS_DUMP_TRACE_ADDRESS
181 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
182 # pressure shrinker from Linux 3.0
184 AC_DEFUN([LC_SHRINK_CONTROL], [
185 LB_CHECK_COMPILE([if 'shrink_control' is present],
187 #include <linux/mm.h>
189 struct shrink_control tmp = {0};
190 tmp.nr_to_scan = sizeof(tmp);
192 AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
193 [shrink_control is present])
195 ]) # LC_SHRINK_CONTROL
198 # LIBCFS_PROCESS_NAMESPACE
200 # 3.5 introduced process namespace
201 AC_DEFUN([LIBCFS_PROCESS_NAMESPACE], [
202 LB_CHECK_LINUX_HEADER([linux/uidgid.h], [
203 AC_DEFINE(HAVE_UIDGID_HEADER, 1,
204 [uidgid.h is present])])
205 ]) # LIBCFS_PROCESS_NAMESPACE
210 # 3.5 added helpers to read the new uid/gid types from VFS structures
211 # SLE11 SP3 has uidgid.h but not the helpers
213 AC_DEFUN([LIBCFS_I_UID_READ], [
214 LB_CHECK_COMPILE([if 'i_uid_read' is present],
216 #include <linux/fs.h>
220 AC_DEFINE(HAVE_I_UID_READ, 1, [i_uid_read is present])
222 ]) # LIBCFS_I_UID_READ
225 # LIBCFS_SOCK_ALLOC_FILE
227 # FC18 3.7.2-201 unexport sock_map_fd() change to
228 # use sock_alloc_file().
229 # upstream commit 56b31d1c9f1e6a3ad92e7bfe252721e05d92b285
231 AC_DEFUN([LIBCFS_SOCK_ALLOC_FILE], [
232 LB_CHECK_EXPORT([sock_alloc_file], [net/socket.c], [
233 LB_CHECK_COMPILE([if 'sock_alloc_file' takes 3 arguments],
234 sock_alloc_file_3args, [
235 #include <linux/net.h>
237 sock_alloc_file(NULL, 0, NULL);
239 AC_DEFINE(HAVE_SOCK_ALLOC_FILE_3ARGS, 1,
240 [sock_alloc_file takes 3 arguments])
242 AC_DEFINE(HAVE_SOCK_ALLOC_FILE, 1,
243 [sock_alloc_file is exported])
246 ]) # LIBCFS_SOCK_ALLOC_FILE
251 AC_DEFUN([LIBCFS_HAVE_CRC32], [
252 LB_CHECK_CONFIG_IM([CRC32],
253 [have_crc32="yes"], [have_crc32="no"])
254 AS_IF([test "x$have_crc32" = xyes],
255 [AC_DEFINE(HAVE_CRC32, 1,
256 [kernel compiled with CRC32 functions])])
257 ]) # LIBCFS_HAVE_CRC32
260 # LIBCFS_ENABLE_CRC32_ACCEL
262 AC_DEFUN([LIBCFS_ENABLE_CRC32_ACCEL], [
263 LB_CHECK_CONFIG_IM([CRYPTO_CRC32_PCLMUL],
264 [enable_crc32_crypto="no"], [enable_crc32_crypto="yes"])
265 AS_IF([test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes], [
266 AC_DEFINE(NEED_CRC32_ACCEL, 1, [need pclmulqdq based crc32])
269 No crc32 pclmulqdq crypto api found, enable internal pclmulqdq based crc32
271 ]) # LIBCFS_ENABLE_CRC32_ACCEL
274 # LIBCFS_ENABLE_CRC32C_ACCEL
276 AC_DEFUN([LIBCFS_ENABLE_CRC32C_ACCEL], [
277 LB_CHECK_CONFIG_IM([CRYPTO_CRC32C_INTEL],
278 [enable_crc32c_crypto="no"], [enable_crc32c_crypto="yes"])
279 AS_IF([test "x$enable_crc32c_crypto" = xyes], [
280 AC_DEFINE(NEED_CRC32C_ACCEL, 1, [need pclmulqdq based crc32c])
283 No crc32c pclmulqdq crypto api found, enable internal pclmulqdq based crc32c
285 ]) # LIBCFS_ENABLE_CRC32C_ACCEL
288 # FC19 3.12 kernel struct shrinker change
290 AC_DEFUN([LIBCFS_SHRINKER_COUNT],[
291 LB_CHECK_COMPILE([shrinker has 'count_objects'],
292 shrinker_count_objects, [
293 #include <linux/mmzone.h>
294 #include <linux/shrinker.h>
296 ((struct shrinker*)0)->count_objects(NULL, NULL);
298 AC_DEFINE(HAVE_SHRINKER_COUNT, 1,
299 [shrinker has count_objects memeber])
306 # LibCFS linux kernel checks
308 AC_DEFUN([LIBCFS_PROG_LINUX], [
309 AC_MSG_NOTICE([LibCFS kernel checks
310 ==============================================================================])
311 LIBCFS_CONFIG_PANIC_DUMPLOG
314 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
315 LC_SHRINKER_WANT_SHRINK_PTR
317 LIBCFS_SYSCTL_CTLNAME
319 LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
323 LIBCFS_DUMP_TRACE_ADDRESS
327 LIBCFS_STACKTRACE_WARNING
329 LIBCFS_PROCESS_NAMESPACE
332 LIBCFS_SOCK_ALLOC_FILE
335 LIBCFS_ENABLE_CRC32_ACCEL
337 LIBCFS_ENABLE_CRC32C_ACCEL
339 LIBCFS_SHRINKER_COUNT
340 ]) # LIBCFS_PROG_LINUX
343 # LIBCFS_PATH_DEFAULTS
345 # default paths for installed files
347 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
348 ]) # LIBCFS_PATH_DEFAULTS
353 # other configure checks
355 AC_DEFUN([LIBCFS_CONFIGURE], [
356 AC_MSG_NOTICE([LibCFS core checks
357 ==============================================================================])
359 # lnet/utils/portals.c
360 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
363 AC_CHECK_HEADERS([linux/version.h])
365 AC_CHECK_TYPE([spinlock_t],
366 [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
368 [#include <linux/spinlock.h>])
370 # lnet/utils/wirecheck.c
371 AC_CHECK_FUNCS([strnlen])
373 # lnet/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
374 AC_CHECK_FUNCS([strlcpy])
376 # libcfs/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
377 AC_CHECK_FUNCS([strlcat])
379 # -------- Check for required packages --------------
381 AC_MSG_NOTICE([LibCFS required packages checks
382 ==============================================================================])
384 AC_MSG_CHECKING([whether to enable 'efence' debugging support])
385 AC_ARG_ENABLE(efence,
386 AC_HELP_STRING([--enable-efence],
387 [use efence library]),
388 [], [enable_efence="no"])
389 AC_MSG_RESULT([$enable_efence])
390 AS_IF([test "$enable_efence" = yes], [
392 AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
398 # -------- check for -lpthread support ----
400 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
401 AC_ARG_ENABLE([libpthread],
402 AC_HELP_STRING([--disable-libpthread],
403 [disable libpthread]),
404 [], [enable_libpthread="yes"])
405 AC_MSG_RESULT([$enable_libpthread])
406 AS_IF([test "x$enable_libpthread" = xyes], [
407 AC_CHECK_LIB([pthread], [pthread_create],
408 [ENABLE_LIBPTHREAD="yes"],
409 [ENABLE_LIBPTHREAD="no"])
410 AS_IF([test "$ENABLE_LIBPTHREAD" = yes], [
411 PTHREAD_LIBS="-lpthread"
412 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
416 AC_SUBST(PTHREAD_LIBS)
418 AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
419 ENABLE_LIBPTHREAD="no"
421 AC_SUBST(ENABLE_LIBPTHREAD)
422 ]) # LIBCFS_CONFIGURE
425 # LIBCFS_CONDITIONALS
427 AC_DEFUN([LIBCFS_CONDITIONALS], [
428 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
429 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32, [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
430 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
431 ]) # LIBCFS_CONDITIONALS
434 # LIBCFS_CONFIG_FILES
436 # files that should be generated with AC_OUTPUT
438 AC_DEFUN([LIBCFS_CONFIG_FILES], [
442 libcfs/autoconf/Makefile
443 libcfs/include/Makefile
444 libcfs/include/libcfs/Makefile
445 libcfs/include/libcfs/linux/Makefile
446 libcfs/include/libcfs/util/Makefile
447 libcfs/libcfs/Makefile
448 libcfs/libcfs/autoMakefile
449 libcfs/libcfs/linux/Makefile
450 libcfs/libcfs/util/Makefile
452 ]) # LIBCFS_CONFIG_FILES