4 # whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
6 AC_DEFUN([LIBCFS_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])])
33 ]) # LIBCFS_CONFIG_CDEBUG
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
126 # 2.6.35 kernel has sk_sleep function
128 AC_DEFUN([LC_SK_SLEEP], [
129 LB_CHECK_COMPILE([if Linux kernel has 'sk_sleep'],
131 #include <net/sock.h>
135 AC_DEFINE(HAVE_SK_SLEEP, 1,
136 [kernel has sk_sleep])
143 # 2.6.38 kstrtoul is added
145 AC_DEFUN([LIBCFS_KSTRTOUL], [
146 LB_CHECK_COMPILE([if Linux kernel has 'kstrtoul'],
148 #include <linux/kernel.h>
150 unsigned long result;
151 return kstrtoul("12345", 0, &result);
153 AC_DEFINE(HAVE_KSTRTOUL, 1,
154 [kernel has kstrtoul])
159 # LIBCFS_DUMP_TRACE_ADDRESS
161 # 2.6.39 adds a base pointer address argument to dump_trace
163 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS], [
164 LB_CHECK_COMPILE([if 'dump_trace' want address],
165 dump_trace_address, [
168 #include <asm/stacktrace.h>
170 dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
172 AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
173 [dump_trace want address argument])
175 ]) # LIBCFS_DUMP_TRACE_ADDRESS
180 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
181 # pressure shrinker from Linux 3.0
183 AC_DEFUN([LC_SHRINK_CONTROL], [
184 LB_CHECK_COMPILE([if 'shrink_control' is present],
186 #include <linux/atomic.h>
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 member])
301 ]) # LIBCFS_SHRINKER_COUNT
304 # Kernel version 3.17 changed hlist_add_after to
307 AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
308 LB_CHECK_COMPILE([does function hlist_add_after exist'],
310 #include <linux/list.h>
312 hlist_add_after(NULL, NULL);
314 AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
315 [hlist_add_after is available])
317 ]) # LIBCFS_HLIST_ADD_AFTER
322 # LibCFS linux kernel checks
324 AC_DEFUN([LIBCFS_PROG_LINUX], [
325 AC_MSG_NOTICE([LibCFS kernel checks
326 ==============================================================================])
327 LIBCFS_CONFIG_PANIC_DUMPLOG
330 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
331 LC_SHRINKER_WANT_SHRINK_PTR
333 LIBCFS_SYSCTL_CTLNAME
339 LIBCFS_DUMP_TRACE_ADDRESS
343 LIBCFS_STACKTRACE_WARNING
345 LIBCFS_PROCESS_NAMESPACE
348 LIBCFS_SOCK_ALLOC_FILE
351 LIBCFS_ENABLE_CRC32_ACCEL
353 LIBCFS_ENABLE_CRC32C_ACCEL
355 LIBCFS_SHRINKER_COUNT
357 LIBCFS_HLIST_ADD_AFTER
358 ]) # LIBCFS_PROG_LINUX
361 # LIBCFS_PATH_DEFAULTS
363 # default paths for installed files
365 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
366 ]) # LIBCFS_PATH_DEFAULTS
371 # other configure checks
373 AC_DEFUN([LIBCFS_CONFIGURE], [
374 AC_MSG_NOTICE([LibCFS core checks
375 ==============================================================================])
377 # lnet/utils/portals.c
378 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
381 AC_CHECK_HEADERS([linux/version.h])
383 AC_CHECK_TYPE([spinlock_t],
384 [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
386 [#include <linux/spinlock.h>])
388 # lnet/utils/wirecheck.c
389 AC_CHECK_FUNCS([strnlen])
391 # lnet/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
392 AC_CHECK_FUNCS([strlcpy])
394 # libcfs/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
395 AC_CHECK_FUNCS([strlcat])
397 # libcfs/include/libcfs/linux/linux-prim.h, ...
398 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
400 # libcfs/include/libcfs/linux/linux-prim.h
401 AC_CHECK_HEADERS([linux/random.h], [], [],
402 [#ifdef HAVE_LINUX_TYPES_H
403 #include <linux/types.h>
407 # libcfs/include/libcfs/linux/libcfs.h
408 # libcfs/include/libcfs/byteorder.h
409 # libcfs/libcfs/util/nidstrings.c
410 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
411 AC_CHECK_FUNCS([gethostbyname])
413 # -------- Check for required packages --------------
415 AC_MSG_NOTICE([LibCFS required packages checks
416 ==============================================================================])
418 AC_MSG_CHECKING([whether to enable readline support])
419 AC_ARG_ENABLE(readline,
420 AC_HELP_STRING([--disable-readline],
421 [disable readline support]),
422 [], [enable_readline="yes"])
423 AC_MSG_RESULT([$enable_readline])
426 AS_IF([test "x$enable_readline" = xyes], [
427 AC_CHECK_LIB([readline], [readline], [
428 LIBREADLINE="-lreadline"
429 AC_DEFINE(HAVE_LIBREADLINE, 1,
430 [readline library is available])
433 AC_SUBST(LIBREADLINE)
435 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
436 AC_ARG_ENABLE([libpthread],
437 AC_HELP_STRING([--disable-libpthread],
438 [disable libpthread]),
439 [], [enable_libpthread="yes"])
440 AC_MSG_RESULT([$enable_libpthread])
443 AS_IF([test "x$enable_libpthread" = xyes], [
444 AC_CHECK_LIB([pthread], [pthread_create], [
445 PTHREAD_LIBS="-lpthread"
446 AC_DEFINE([HAVE_LIBPTHREAD], 1,
447 [use libpthread for libcfs library])
450 AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
452 AC_SUBST(PTHREAD_LIBS)
453 ]) # LIBCFS_CONFIGURE
456 # LIBCFS_CONDITIONALS
458 AC_DEFUN([LIBCFS_CONDITIONALS], [
459 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
460 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32, [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
461 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
462 ]) # LIBCFS_CONDITIONALS
465 # LIBCFS_CONFIG_FILES
467 # files that should be generated with AC_OUTPUT
469 AC_DEFUN([LIBCFS_CONFIG_FILES], [
473 libcfs/autoconf/Makefile
474 libcfs/include/Makefile
475 libcfs/include/libcfs/Makefile
476 libcfs/include/libcfs/linux/Makefile
477 libcfs/include/libcfs/util/Makefile
478 libcfs/libcfs/Makefile
479 libcfs/libcfs/autoMakefile
480 libcfs/libcfs/linux/Makefile
481 libcfs/libcfs/util/Makefile
483 ]) # LIBCFS_CONFIG_FILES