Whamcloud - gitweb
LU-4655 libcfs: properly (un)define CDEBUG_ENTRY_EXIT
[fs/lustre-release.git] / libcfs / autoconf / lustre-libcfs.m4
1 #
2 # LN_CONFIG_CDEBUG
3 #
4 # whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
5 #
6 AC_DEFUN([LN_CONFIG_CDEBUG],
7 [
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])
16 fi
17
18 AC_MSG_CHECKING([whether to enable ENTRY/EXIT])
19 AC_ARG_ENABLE([libcfs_trace],
20         AC_HELP_STRING([--disable-libcfs-trace],
21                         [disable libcfs ENTRY/EXIT]),
22         [],[enable_libcfs_trace='yes'])
23 AC_MSG_RESULT([$enable_libcfs_trace])
24 if test x$enable_libcfs_trace = xyes; then
25         AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])
26 fi
27
28 AC_MSG_CHECKING([whether to enable LASSERT, LASSERTF])
29 AC_ARG_ENABLE([libcfs_assert],
30         AC_HELP_STRING([--disable-libcfs-assert],
31                         [disable libcfs LASSERT, LASSERTF]),
32         [],[enable_libcfs_assert='yes'])
33 AC_MSG_RESULT([$enable_libcfs_assert])
34 if test x$enable_libcfs_assert = xyes; then
35    AC_DEFINE(LIBCFS_DEBUG, 1, [enable libcfs LASSERT, LASSERTF])
36 fi
37 ])
38
39 #
40 # LIBCFS_CONFIG_PANIC_DUMPLOG
41 #
42 # check if tunable panic_dumplog is wanted
43 #
44 AC_DEFUN([LIBCFS_CONFIG_PANIC_DUMPLOG],
45 [AC_MSG_CHECKING([for tunable panic_dumplog support])
46 AC_ARG_ENABLE([panic_dumplog],
47        AC_HELP_STRING([--enable-panic_dumplog],
48                       [enable panic_dumplog]),
49        [],[enable_panic_dumplog='no'])
50 if test x$enable_panic_dumplog = xyes ; then
51        AC_DEFINE(LNET_DUMP_ON_PANIC, 1, [use dumplog on panic])
52        AC_MSG_RESULT([yes (by request)])
53 else
54        AC_MSG_RESULT([no])
55 fi
56 ])
57
58 # check kernel __u64 type
59 AC_DEFUN([LIBCFS_U64_LONG_LONG_LINUX],
60 [
61 AC_MSG_CHECKING([kernel __u64 is long long type])
62 tmp_flags="$EXTRA_KCFLAGS"
63 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
64 LB_LINUX_TRY_COMPILE([
65         #include <linux/types.h>
66         #include <linux/stddef.h>
67 ],[
68         unsigned long long *data;
69
70         data = (__u64*)sizeof(data);
71 ],[
72         AC_MSG_RESULT([yes])
73         AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
74                   [kernel __u64 is long long type])
75 ],[
76         AC_MSG_RESULT([no])
77 ])
78 EXTRA_KCFLAGS="$tmp_flags"
79 ])
80
81 #
82 # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
83 #
84 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
85 #
86 AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK],
87 [AC_MSG_CHECKING([if 'struct stacktrace_ops' has 'walk_stack' field])
88 LB_LINUX_TRY_COMPILE([
89         #include <asm/stacktrace.h>
90 ],[
91         ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
92 ],[
93         AC_MSG_RESULT([yes])
94         AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1, ['struct stacktrace_ops' has 'walk_stack' field])
95 ],[
96         AC_MSG_RESULT([no])
97 ])
98 ])
99
100 #
101 # RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
102 #
103 AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR],
104 [AC_MSG_CHECKING([shrinker want self pointer in handler])
105 LB_LINUX_TRY_COMPILE([
106         #include <linux/mm.h>
107 ],[
108         struct shrinker *tmp = NULL;
109         tmp->shrink(tmp, 0, 0);
110 ],[
111         AC_MSG_RESULT(yes)
112         AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
113                   [shrinker want self pointer in handler])
114 ],[
115         AC_MSG_RESULT(no)
116 ])
117 ])
118
119 #
120 # 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
121 #
122 AC_DEFUN([LIBCFS_SYSCTL_CTLNAME],
123 [AC_MSG_CHECKING([if ctl_table has a ctl_name field])
124 LB_LINUX_TRY_COMPILE([
125         #include <linux/sysctl.h>
126 ],[
127         struct ctl_table ct;
128         ct.ctl_name = sizeof(ct);
129 ],[
130         AC_MSG_RESULT(yes)
131         AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
132                   [ctl_table has ctl_name field])
133 ],[
134         AC_MSG_RESULT(no)
135 ])
136 ])
137
138 #
139 # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
140 #
141 # 2.6.34 adds __add_wait_queue_exclusive
142 #
143 AC_DEFUN([LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE],
144 [AC_MSG_CHECKING([if __add_wait_queue_exclusive exists])
145 LB_LINUX_TRY_COMPILE([
146         #include <linux/wait.h>
147 ],[
148         wait_queue_head_t queue;
149         wait_queue_t      wait;
150
151         __add_wait_queue_exclusive(&queue, &wait);
152 ],[
153         AC_MSG_RESULT(yes)
154         AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
155                   [__add_wait_queue_exclusive exists])
156 ],[
157         AC_MSG_RESULT(no)
158 ])
159 ])
160
161 #
162 # 2.6.35 kernel has sk_sleep function
163 #
164 AC_DEFUN([LC_SK_SLEEP],
165 [AC_MSG_CHECKING([if kernel has sk_sleep])
166 LB_LINUX_TRY_COMPILE([
167         #include <net/sock.h>
168 ],[
169         sk_sleep(NULL);
170 ],[
171         AC_MSG_RESULT(yes)
172         AC_DEFINE(HAVE_SK_SLEEP, 1, [kernel has sk_sleep])
173 ],[
174         AC_MSG_RESULT(no)
175 ],[
176 ])
177 ])
178
179 # 2.6.39 adds a base pointer address argument to dump_trace
180 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS],
181 [AC_MSG_CHECKING([dump_trace want address])
182 LB_LINUX_TRY_COMPILE([
183         struct task_struct;
184         struct pt_regs;
185         #include <asm/stacktrace.h>
186 ],[
187         dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
188 ],[
189         AC_MSG_RESULT(yes)
190         AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
191                 [dump_trace want address argument])
192 ],[
193         AC_MSG_RESULT(no)
194 ],[
195 ])
196 ])
197
198 #
199 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
200 # pressure shrinker from Linux 3.0
201 #
202 AC_DEFUN([LC_SHRINK_CONTROL],
203 [AC_MSG_CHECKING([shrink_control is present])
204 LB_LINUX_TRY_COMPILE([
205         #include <linux/mm.h>
206 ],[
207         struct shrink_control tmp = {0};
208         tmp.nr_to_scan = sizeof(tmp);
209 ],[
210         AC_MSG_RESULT(yes)
211         AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
212                   [shrink_control is present])
213 ],[
214         AC_MSG_RESULT(no)
215 ])
216 ])
217
218 # 3.0 removes stacktrace_ops warning* functions
219 AC_DEFUN([LIBCFS_STACKTRACE_WARNING],
220 [AC_MSG_CHECKING([whether stacktrace_ops.warning is exist])
221 LB_LINUX_TRY_COMPILE([
222         struct task_struct;
223         struct pt_regs;
224         #include <asm/stacktrace.h>
225 ],[
226         ((struct stacktrace_ops *)0)->warning(NULL, NULL);
227 ],[
228         AC_MSG_RESULT(yes)
229         AC_DEFINE(HAVE_STACKTRACE_WARNING, 1, [stacktrace_ops.warning is exist])
230 ],[
231         AC_MSG_RESULT(no)
232 ],[
233 ])
234 ])
235
236 #
237 # FC18 3.7.2-201 unexport sock_map_fd() change to
238 # use sock_alloc_file().
239 # upstream commit 56b31d1c9f1e6a3ad92e7bfe252721e05d92b285
240 #
241 AC_DEFUN([LIBCFS_SOCK_ALLOC_FILE],
242 [LB_CHECK_SYMBOL_EXPORT([sock_alloc_file], [net/socket.c],[
243         LB_LINUX_TRY_COMPILE([
244                 #include <linux/net.h>
245         ],[
246                 sock_alloc_file(NULL, 0, NULL);
247         ],[
248                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE_3ARGS, 1,
249                         [sock_alloc_file takes 3 arguments])
250         ],[
251                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE, 1,
252                         [sock_alloc_file is exported])
253         ])
254 ],[
255 ])
256 ])
257
258 AC_DEFUN([LIBCFS_HAVE_CRC32],
259 [LB_LINUX_CONFIG_IM([CRC32],
260         [have_crc32=true],[have_crc32=false])
261 if test x$have_crc32 = xtrue; then
262         AC_DEFINE(HAVE_CRC32, 1, [kernel compiled with CRC32 functions])
263 fi
264 ])
265
266 AC_DEFUN([LIBCFS_ENABLE_CRC32_ACCEL],
267 [LB_LINUX_CONFIG_IM([CRYPTO_CRC32_PCLMUL],
268         [enable_crc32_crypto=false],[enable_crc32_crypto=true])
269 if test x$have_crc32 = xtrue -a x$enable_crc32_crypto = xtrue; then
270         AC_DEFINE(NEED_CRC32_ACCEL, 1, [need pclmulqdq based crc32])
271         AC_MSG_WARN([
272
273 No crc32 pclmulqdq crypto api found, enable internal pclmulqdq based crc32
274 ])
275 fi
276 ])
277
278 AC_DEFUN([LIBCFS_ENABLE_CRC32C_ACCEL],
279 [LB_LINUX_CONFIG_IM([CRYPTO_CRC32C_INTEL],
280         [enable_crc32c_crypto=false],[enable_crc32c_crypto=true])
281 if test x$enable_crc32c_crypto = xtrue; then
282         AC_DEFINE(NEED_CRC32C_ACCEL, 1, [need pclmulqdq based crc32c])
283         AC_MSG_WARN([
284
285 No crc32c pclmulqdq crypto api found, enable internal pclmulqdq based crc32c
286 ])
287 fi
288 ])
289
290 #
291 # LIBCFS_PROG_LINUX
292 #
293 # LNet linux kernel checks
294 #
295 AC_DEFUN([LIBCFS_PROG_LINUX],
296 [
297 LIBCFS_CONFIG_PANIC_DUMPLOG
298
299 LIBCFS_U64_LONG_LONG_LINUX
300 # 2.6.32
301 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
302 LC_SHRINKER_WANT_SHRINK_PTR
303 # 2.6.33
304 LIBCFS_SYSCTL_CTLNAME
305 # 2.6.34
306 LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
307 # 2.6.35
308 LC_SK_SLEEP
309 # 2.6.39
310 LIBCFS_DUMP_TRACE_ADDRESS
311 # 2.6.40 fc15
312 LC_SHRINK_CONTROL
313 # 3.0
314 LIBCFS_STACKTRACE_WARNING
315 # 3.7
316 LIBCFS_SOCK_ALLOC_FILE
317 # 3.8
318 LIBCFS_HAVE_CRC32
319 LIBCFS_ENABLE_CRC32_ACCEL
320 # 3.10
321 LIBCFS_ENABLE_CRC32C_ACCEL
322 ])
323
324 #
325 # LIBCFS_PROG_DARWIN
326 #
327 # Darwin checks
328 #
329 AC_DEFUN([LIBCFS_PROG_DARWIN],
330 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
331 ])
332
333 #
334 # LIBCFS_PATH_DEFAULTS
335 #
336 # default paths for installed files
337 #
338 AC_DEFUN([LIBCFS_PATH_DEFAULTS],
339 [
340 ])
341
342 #
343 # LIBCFS_CONFIGURE
344 #
345 # other configure checks
346 #
347 AC_DEFUN([LIBCFS_CONFIGURE],
348 [# lnet/utils/portals.c
349 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
350
351 # lnet/utils/debug.c
352 AC_CHECK_HEADERS([linux/version.h])
353
354 AC_CHECK_TYPE([spinlock_t],
355         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
356         [],
357         [#include <linux/spinlock.h>])
358
359 # lnet/utils/wirecheck.c
360 AC_CHECK_FUNCS([strnlen])
361
362 # lnet/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
363 AC_CHECK_FUNCS([strlcpy])
364
365 # libcfs/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
366 AC_CHECK_FUNCS([strlcat])
367
368 AC_CHECK_TYPE([umode_t],
369         [AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
370         [],
371         [#include <asm/types.h>])
372
373 AC_CHECK_TYPE([__s8],
374         [AC_DEFINE(HAVE___S8, 1, [__s8 is defined])],
375         [],
376         [#include <asm/types.h>])
377
378 AC_CHECK_TYPE([__u8],
379         [AC_DEFINE(HAVE___U8, 1, [__u8 is defined])],
380         [],
381         [#include <asm/types.h>])
382
383 AC_CHECK_TYPE([__s16],
384         [AC_DEFINE(HAVE___S16, 1, [__s16 is defined])],
385         [],
386         [#include <asm/types.h>])
387
388 AC_CHECK_TYPE([__u16],
389         [AC_DEFINE(HAVE___U16, 1, [__u16 is defined])],
390         [],
391         [#include <asm/types.h>])
392
393 AC_CHECK_TYPE([__s32],
394         [AC_DEFINE(HAVE___S32, 1, [__s32 is defined])],
395         [],
396         [#include <asm/types.h>])
397
398 AC_CHECK_TYPE([__u32],
399         [AC_DEFINE(HAVE___U32, 1, [__u32 is defined])],
400         [],
401         [#include <asm/types.h>])
402
403 AC_CHECK_TYPE([__u64],
404         [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
405         [],
406         [#include <asm/types.h>])
407
408 AC_CHECK_TYPE([__s64],
409         [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
410         [],
411         [#include <asm/types.h>])
412
413 # check userland __u64 type
414 AC_MSG_CHECKING([userspace __u64 is long long type])
415 tmp_flags="$CFLAGS"
416 CFLAGS="$CFLAGS -Werror"
417 AC_COMPILE_IFELSE([
418         #include <stdio.h>
419         #include <linux/types.h>
420         #include <linux/stddef.h>
421         int main(void) {
422                 unsigned long long *data1;
423                 __u64 *data2 = NULL;
424
425                 data1 = data2;
426                 data2 = data1;
427                 return 0;
428         }
429 ],[
430         AC_MSG_RESULT([yes])
431         AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
432                   [__u64 is long long type])
433 ],[
434         AC_MSG_RESULT([no])
435 ])
436 CFLAGS="$tmp_flags"
437
438 # --------  Check for required packages  --------------
439
440
441 AC_MSG_CHECKING([if efence debugging support is requested])
442 AC_ARG_ENABLE(efence,
443         AC_HELP_STRING([--enable-efence],
444                         [use efence library]),
445         [],[enable_efence='no'])
446 AC_MSG_RESULT([$enable_efence])
447 if test "$enable_efence" = "yes" ; then
448         LIBEFENCE="-lefence"
449         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
450 else
451         LIBEFENCE=""
452 fi
453 AC_SUBST(LIBEFENCE)
454
455
456 # -------- check for -lpthread support ----
457 AC_ARG_ENABLE([libpthread],
458         AC_HELP_STRING([--disable-libpthread],
459                 [disable libpthread]),
460         [],[enable_libpthread=yes])
461 if test "$enable_libpthread" = "yes" ; then
462         AC_CHECK_LIB([pthread], [pthread_create],
463                 [ENABLE_LIBPTHREAD="yes"],
464                 [ENABLE_LIBPTHREAD="no"])
465         AC_MSG_CHECKING([whether to use libpthread for libcfs library])
466         AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
467         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
468                 PTHREAD_LIBS="-lpthread"
469                 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
470         else
471                 PTHREAD_LIBS=""
472         fi
473         AC_SUBST(PTHREAD_LIBS)
474 else
475         AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
476         ENABLE_LIBPTHREAD="no"
477 fi
478 AC_SUBST(ENABLE_LIBPTHREAD)
479 ])
480
481 #
482 # LIBCFS_CONDITIONALS
483 #
484 # AM_CONDITOINAL defines for lnet
485 #
486 AC_DEFUN([LIBCFS_CONDITIONALS],
487 [
488 AM_CONDITIONAL(HAVE_CRC32, test x$have_crc32 = xtrue)
489 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32,  test x$have_crc32 = xtrue -a x$enable_crc32_crypto = xtrue)
490 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, test x$enable_crc32c_crypto = xtrue)
491 ])
492
493 #
494 # LIBCFS_CONFIG_FILES
495 #
496 # files that should be generated with AC_OUTPUT
497 #
498 AC_DEFUN([LIBCFS_CONFIG_FILES],
499 [AC_CONFIG_FILES([
500 libcfs/Kernelenv
501 libcfs/Makefile
502 libcfs/autoMakefile
503 libcfs/autoconf/Makefile
504 libcfs/include/Makefile
505 libcfs/include/libcfs/Makefile
506 libcfs/include/libcfs/linux/Makefile
507 libcfs/include/libcfs/posix/Makefile
508 libcfs/include/libcfs/util/Makefile
509 libcfs/libcfs/Makefile
510 libcfs/libcfs/autoMakefile
511 libcfs/libcfs/linux/Makefile
512 libcfs/libcfs/posix/Makefile
513 libcfs/libcfs/util/Makefile
514 libcfs/include/libcfs/darwin/Makefile
515 libcfs/libcfs/darwin/Makefile
516 ])
517 ])