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