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