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