Whamcloud - gitweb
LU-2800 autoconf: remove LIBCFS_SOCK_MAP_FD_2ARG
[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 #
104 # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
105 #
106 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
107 #
108 AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK],
109 [AC_MSG_CHECKING([if 'struct stacktrace_ops' has 'walk_stack' field])
110 LB_LINUX_TRY_COMPILE([
111         #include <asm/stacktrace.h>
112 ],[
113         ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
114 ],[
115         AC_MSG_RESULT([yes])
116         AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1, ['struct stacktrace_ops' has 'walk_stack' field])
117 ],[
118         AC_MSG_RESULT([no])
119 ])
120 ])
121
122 AC_DEFUN([LIBCFS_HAVE_KEYTYPE_H],
123 [LB_CHECK_FILE([$LINUX/include/linux/key-type.h], [
124         AC_DEFINE(HAVE_LINUX_KEYTYPE_H, 1,
125                 [kernel has include/key-type.h])
126 ],[
127         AC_MSG_RESULT([no])
128 ])
129 ])
130
131 #
132 # RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
133 #
134 AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR],
135 [AC_MSG_CHECKING([shrinker want self pointer in handler])
136 LB_LINUX_TRY_COMPILE([
137         #include <linux/mm.h>
138 ],[
139         struct shrinker *tmp = NULL;
140         tmp->shrink(tmp, 0, 0);
141 ],[
142         AC_MSG_RESULT(yes)
143         AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
144                   [shrinker want self pointer in handler])
145 ],[
146         AC_MSG_RESULT(no)
147 ])
148 ])
149
150 #
151 # 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
152 #
153 AC_DEFUN([LIBCFS_SYSCTL_CTLNAME],
154 [AC_MSG_CHECKING([if ctl_table has a ctl_name field])
155 LB_LINUX_TRY_COMPILE([
156         #include <linux/sysctl.h>
157 ],[
158         struct ctl_table ct;
159         ct.ctl_name = sizeof(ct);
160 ],[
161         AC_MSG_RESULT(yes)
162         AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
163                   [ctl_table has ctl_name field])
164 ],[
165         AC_MSG_RESULT(no)
166 ])
167 ])
168
169 #
170 # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
171 #
172 # 2.6.34 adds __add_wait_queue_exclusive
173 #
174 AC_DEFUN([LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE],
175 [AC_MSG_CHECKING([if __add_wait_queue_exclusive exists])
176 LB_LINUX_TRY_COMPILE([
177         #include <linux/wait.h>
178 ],[
179         wait_queue_head_t queue;
180         wait_queue_t      wait;
181
182         __add_wait_queue_exclusive(&queue, &wait);
183 ],[
184         AC_MSG_RESULT(yes)
185         AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
186                   [__add_wait_queue_exclusive exists])
187 ],[
188         AC_MSG_RESULT(no)
189 ])
190 ])
191
192 #
193 # 2.6.35 kernel has sk_sleep function
194 #
195 AC_DEFUN([LC_SK_SLEEP],
196 [AC_MSG_CHECKING([if kernel has sk_sleep])
197 LB_LINUX_TRY_COMPILE([
198         #include <net/sock.h>
199 ],[
200         sk_sleep(NULL);
201 ],[
202         AC_MSG_RESULT(yes)
203         AC_DEFINE(HAVE_SK_SLEEP, 1, [kernel has sk_sleep])
204 ],[
205         AC_MSG_RESULT(no)
206 ],[
207 ])
208 ])
209
210 # 2.6.39 adds a base pointer address argument to dump_trace
211 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS],
212 [AC_MSG_CHECKING([dump_trace want address])
213 LB_LINUX_TRY_COMPILE([
214         struct task_struct;
215         struct pt_regs;
216         #include <asm/stacktrace.h>
217 ],[
218         dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
219 ],[
220         AC_MSG_RESULT(yes)
221         AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
222                 [dump_trace want address argument])
223 ],[
224         AC_MSG_RESULT(no)
225 ],[
226 ])
227 ])
228
229 #
230 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
231 # pressure shrinker from Linux 3.0
232 #
233 AC_DEFUN([LC_SHRINK_CONTROL],
234 [AC_MSG_CHECKING([shrink_control is present])
235 LB_LINUX_TRY_COMPILE([
236         #include <linux/mm.h>
237 ],[
238         struct shrink_control tmp = {0};
239         tmp.nr_to_scan = sizeof(tmp);
240 ],[
241         AC_MSG_RESULT(yes)
242         AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
243                   [shrink_control is present])
244 ],[
245         AC_MSG_RESULT(no)
246 ])
247 ])
248
249 # 3.0 removes stacktrace_ops warning* functions
250 AC_DEFUN([LIBCFS_STACKTRACE_WARNING],
251 [AC_MSG_CHECKING([whether stacktrace_ops.warning is exist])
252 LB_LINUX_TRY_COMPILE([
253         struct task_struct;
254         struct pt_regs;
255         #include <asm/stacktrace.h>
256 ],[
257         ((struct stacktrace_ops *)0)->warning(NULL, NULL);
258 ],[
259         AC_MSG_RESULT(yes)
260         AC_DEFINE(HAVE_STACKTRACE_WARNING, 1, [stacktrace_ops.warning is exist])
261 ],[
262         AC_MSG_RESULT(no)
263 ],[
264 ])
265 ])
266
267 #
268 # FC18 3.7.2-201 unexport sock_map_fd() change to
269 # use sock_alloc_file().
270 # upstream commit 56b31d1c9f1e6a3ad92e7bfe252721e05d92b285
271 #
272 AC_DEFUN([LIBCFS_SOCK_ALLOC_FILE],
273 [AC_MSG_CHECKING([sock_alloc_file is exported])
274 LB_CHECK_SYMBOL_EXPORT([sock_alloc_file], [net/socket.c],[
275         LB_LINUX_TRY_COMPILE([
276                 #include <linux/net.h>
277         ],[
278                 sock_alloc_file(NULL, 0, NULL);
279         ],[
280                 AC_MSG_RESULT(yes)
281                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE_3ARGS, 1,
282                         [sock_alloc_file takes 3 arguments])
283         ],[
284                 AC_MSG_RESULT(yes)
285                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE, 1,
286                         [sock_alloc_file is exported])
287         ])
288 ],[
289 ])
290 ])
291
292 #
293 # LIBCFS_PROG_LINUX
294 #
295 # LNet linux kernel checks
296 #
297 AC_DEFUN([LIBCFS_PROG_LINUX],
298 [
299 LIBCFS_CONFIG_PANIC_DUMPLOG
300
301 LIBCFS_U64_LONG_LONG_LINUX
302 # 2.6.24
303 LIBCFS_SYSCTL_UNNUMBERED
304 LIBCFS_HAVE_KEYTYPE_H
305 # 2.6.32
306 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
307 LC_SHRINKER_WANT_SHRINK_PTR
308 # 2.6.33
309 LIBCFS_SYSCTL_CTLNAME
310 # 2.6.34
311 LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
312 # 2.6.35
313 LC_SK_SLEEP
314 # 2.6.39
315 LIBCFS_DUMP_TRACE_ADDRESS
316 # 2.6.40 fc15
317 LC_SHRINK_CONTROL
318 # 3.0
319 LIBCFS_STACKTRACE_WARNING
320 # 3.7
321 LIBCFS_SOCK_ALLOC_FILE
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_MSG_CHECKING([whether to use libpthread for libcfs library])
458 AC_ARG_ENABLE([libpthread],
459         AC_HELP_STRING([--disable-libpthread],
460                 [disable libpthread]),
461         [],[enable_libpthread=yes])
462 if test "$enable_libpthread" = "yes" ; then
463         AC_CHECK_LIB([pthread], [pthread_create],
464                 [ENABLE_LIBPTHREAD="yes"],
465                 [ENABLE_LIBPTHREAD="no"])
466         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
467                 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
468                 PTHREAD_LIBS="-lpthread"
469                 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
470         else
471                 PTHREAD_LIBS=""
472                 AC_MSG_RESULT([no libpthread is found])
473         fi
474         AC_SUBST(PTHREAD_LIBS)
475 else
476         AC_MSG_RESULT([no (disabled explicitly)])
477         ENABLE_LIBPTHREAD="no"
478 fi
479 AC_SUBST(ENABLE_LIBPTHREAD)
480
481
482 ])
483
484 #
485 # LIBCFS_CONDITIONALS
486 #
487 # AM_CONDITOINAL defines for lnet
488 #
489 AC_DEFUN([LIBCFS_CONDITIONALS],
490 [
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 ])