Whamcloud - gitweb
LU-4476 kernel: support process namespace containers
[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 # 3.4 introduced process namespace
237 AC_DEFUN([LIBCFS_PROCESS_NAMESPACE],[
238 LB_CHECK_LINUX_HEADER([linux/uidgid.h], [
239         AC_DEFINE(HAVE_UIDGID_HEADER, 1, [uidgid.h is present])
240 ])
241 ])
242
243 #
244 # FC18 3.7.2-201 unexport sock_map_fd() change to
245 # use sock_alloc_file().
246 # upstream commit 56b31d1c9f1e6a3ad92e7bfe252721e05d92b285
247 #
248 AC_DEFUN([LIBCFS_SOCK_ALLOC_FILE],
249 [LB_CHECK_SYMBOL_EXPORT([sock_alloc_file], [net/socket.c],[
250         LB_LINUX_TRY_COMPILE([
251                 #include <linux/net.h>
252         ],[
253                 sock_alloc_file(NULL, 0, NULL);
254         ],[
255                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE_3ARGS, 1,
256                         [sock_alloc_file takes 3 arguments])
257         ],[
258                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE, 1,
259                         [sock_alloc_file is exported])
260         ])
261 ],[
262 ])
263 ])
264
265 AC_DEFUN([LIBCFS_HAVE_CRC32],
266 [LB_LINUX_CONFIG_IM([CRC32],
267         [have_crc32=true],[have_crc32=false])
268 if test x$have_crc32 = xtrue; then
269         AC_DEFINE(HAVE_CRC32, 1, [kernel compiled with CRC32 functions])
270 fi
271 ])
272
273 AC_DEFUN([LIBCFS_ENABLE_CRC32_ACCEL],
274 [LB_LINUX_CONFIG_IM([CRYPTO_CRC32_PCLMUL],
275         [enable_crc32_crypto=false],[enable_crc32_crypto=true])
276 if test x$have_crc32 = xtrue -a x$enable_crc32_crypto = xtrue; then
277         AC_DEFINE(NEED_CRC32_ACCEL, 1, [need pclmulqdq based crc32])
278         AC_MSG_WARN([
279
280 No crc32 pclmulqdq crypto api found, enable internal pclmulqdq based crc32
281 ])
282 fi
283 ])
284
285 AC_DEFUN([LIBCFS_ENABLE_CRC32C_ACCEL],
286 [LB_LINUX_CONFIG_IM([CRYPTO_CRC32C_INTEL],
287         [enable_crc32c_crypto=false],[enable_crc32c_crypto=true])
288 if test x$enable_crc32c_crypto = xtrue; then
289         AC_DEFINE(NEED_CRC32C_ACCEL, 1, [need pclmulqdq based crc32c])
290         AC_MSG_WARN([
291
292 No crc32c pclmulqdq crypto api found, enable internal pclmulqdq based crc32c
293 ])
294 fi
295 ])
296
297 #
298 # LIBCFS_PROG_LINUX
299 #
300 # LNet linux kernel checks
301 #
302 AC_DEFUN([LIBCFS_PROG_LINUX],
303 [
304 LIBCFS_CONFIG_PANIC_DUMPLOG
305
306 LIBCFS_U64_LONG_LONG_LINUX
307 # 2.6.32
308 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
309 LC_SHRINKER_WANT_SHRINK_PTR
310 # 2.6.33
311 LIBCFS_SYSCTL_CTLNAME
312 # 2.6.34
313 LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
314 # 2.6.35
315 LC_SK_SLEEP
316 # 2.6.39
317 LIBCFS_DUMP_TRACE_ADDRESS
318 # 2.6.40 fc15
319 LC_SHRINK_CONTROL
320 # 3.0
321 LIBCFS_STACKTRACE_WARNING
322 # 3.4
323 LIBCFS_PROCESS_NAMESPACE
324 # 3.7
325 LIBCFS_SOCK_ALLOC_FILE
326 # 3.8
327 LIBCFS_HAVE_CRC32
328 LIBCFS_ENABLE_CRC32_ACCEL
329 # 3.10
330 LIBCFS_ENABLE_CRC32C_ACCEL
331 ])
332
333 #
334 # LIBCFS_PROG_DARWIN
335 #
336 # Darwin checks
337 #
338 AC_DEFUN([LIBCFS_PROG_DARWIN],
339 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
340 ])
341
342 #
343 # LIBCFS_PATH_DEFAULTS
344 #
345 # default paths for installed files
346 #
347 AC_DEFUN([LIBCFS_PATH_DEFAULTS],
348 [
349 ])
350
351 #
352 # LIBCFS_CONFIGURE
353 #
354 # other configure checks
355 #
356 AC_DEFUN([LIBCFS_CONFIGURE],
357 [# lnet/utils/portals.c
358 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
359
360 # lnet/utils/debug.c
361 AC_CHECK_HEADERS([linux/version.h])
362
363 AC_CHECK_TYPE([spinlock_t],
364         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
365         [],
366         [#include <linux/spinlock.h>])
367
368 # lnet/utils/wirecheck.c
369 AC_CHECK_FUNCS([strnlen])
370
371 # lnet/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
372 AC_CHECK_FUNCS([strlcpy])
373
374 # libcfs/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
375 AC_CHECK_FUNCS([strlcat])
376
377 AC_CHECK_TYPE([umode_t],
378         [AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
379         [],
380         [#include <asm/types.h>])
381
382 AC_CHECK_TYPE([__s8],
383         [AC_DEFINE(HAVE___S8, 1, [__s8 is defined])],
384         [],
385         [#include <asm/types.h>])
386
387 AC_CHECK_TYPE([__u8],
388         [AC_DEFINE(HAVE___U8, 1, [__u8 is defined])],
389         [],
390         [#include <asm/types.h>])
391
392 AC_CHECK_TYPE([__s16],
393         [AC_DEFINE(HAVE___S16, 1, [__s16 is defined])],
394         [],
395         [#include <asm/types.h>])
396
397 AC_CHECK_TYPE([__u16],
398         [AC_DEFINE(HAVE___U16, 1, [__u16 is defined])],
399         [],
400         [#include <asm/types.h>])
401
402 AC_CHECK_TYPE([__s32],
403         [AC_DEFINE(HAVE___S32, 1, [__s32 is defined])],
404         [],
405         [#include <asm/types.h>])
406
407 AC_CHECK_TYPE([__u32],
408         [AC_DEFINE(HAVE___U32, 1, [__u32 is defined])],
409         [],
410         [#include <asm/types.h>])
411
412 AC_CHECK_TYPE([__u64],
413         [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
414         [],
415         [#include <asm/types.h>])
416
417 AC_CHECK_TYPE([__s64],
418         [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
419         [],
420         [#include <asm/types.h>])
421
422 # check userland __u64 type
423 AC_MSG_CHECKING([userspace __u64 is long long type])
424 tmp_flags="$CFLAGS"
425 CFLAGS="$CFLAGS -Werror"
426 AC_COMPILE_IFELSE([
427         #include <stdio.h>
428         #include <linux/types.h>
429         #include <linux/stddef.h>
430         int main(void) {
431                 unsigned long long *data1;
432                 __u64 *data2 = NULL;
433
434                 data1 = data2;
435                 data2 = data1;
436                 return 0;
437         }
438 ],[
439         AC_MSG_RESULT([yes])
440         AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
441                   [__u64 is long long type])
442 ],[
443         AC_MSG_RESULT([no])
444 ])
445 CFLAGS="$tmp_flags"
446
447 # --------  Check for required packages  --------------
448
449
450 AC_MSG_CHECKING([if efence debugging support is requested])
451 AC_ARG_ENABLE(efence,
452         AC_HELP_STRING([--enable-efence],
453                         [use efence library]),
454         [],[enable_efence='no'])
455 AC_MSG_RESULT([$enable_efence])
456 if test "$enable_efence" = "yes" ; then
457         LIBEFENCE="-lefence"
458         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
459 else
460         LIBEFENCE=""
461 fi
462 AC_SUBST(LIBEFENCE)
463
464
465 # -------- check for -lpthread support ----
466 AC_ARG_ENABLE([libpthread],
467         AC_HELP_STRING([--disable-libpthread],
468                 [disable libpthread]),
469         [],[enable_libpthread=yes])
470 if test "$enable_libpthread" = "yes" ; then
471         AC_CHECK_LIB([pthread], [pthread_create],
472                 [ENABLE_LIBPTHREAD="yes"],
473                 [ENABLE_LIBPTHREAD="no"])
474         AC_MSG_CHECKING([whether to use libpthread for libcfs library])
475         AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
476         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
477                 PTHREAD_LIBS="-lpthread"
478                 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
479         else
480                 PTHREAD_LIBS=""
481         fi
482         AC_SUBST(PTHREAD_LIBS)
483 else
484         AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
485         ENABLE_LIBPTHREAD="no"
486 fi
487 AC_SUBST(ENABLE_LIBPTHREAD)
488 ])
489
490 #
491 # LIBCFS_CONDITIONALS
492 #
493 # AM_CONDITOINAL defines for lnet
494 #
495 AC_DEFUN([LIBCFS_CONDITIONALS],
496 [
497 AM_CONDITIONAL(HAVE_CRC32, test x$have_crc32 = xtrue)
498 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32,  test x$have_crc32 = xtrue -a x$enable_crc32_crypto = xtrue)
499 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, test x$enable_crc32c_crypto = xtrue)
500 ])
501
502 #
503 # LIBCFS_CONFIG_FILES
504 #
505 # files that should be generated with AC_OUTPUT
506 #
507 AC_DEFUN([LIBCFS_CONFIG_FILES],
508 [AC_CONFIG_FILES([
509 libcfs/Kernelenv
510 libcfs/Makefile
511 libcfs/autoMakefile
512 libcfs/autoconf/Makefile
513 libcfs/include/Makefile
514 libcfs/include/libcfs/Makefile
515 libcfs/include/libcfs/linux/Makefile
516 libcfs/include/libcfs/posix/Makefile
517 libcfs/include/libcfs/util/Makefile
518 libcfs/libcfs/Makefile
519 libcfs/libcfs/autoMakefile
520 libcfs/libcfs/linux/Makefile
521 libcfs/libcfs/posix/Makefile
522 libcfs/libcfs/util/Makefile
523 libcfs/include/libcfs/darwin/Makefile
524 libcfs/libcfs/darwin/Makefile
525 ])
526 ])