Whamcloud - gitweb
d5eb5cf942043832f62472ea920c3d7dea25d362
[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_STACKTRACE_OPS_HAVE_WALK_STACK
53 #
54 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
55 #
56 AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK], [
57 LB_CHECK_COMPILE([if 'struct stacktrace_ops' has 'walk_stack' field],
58 stacktrace_ops_walk_stack, [
59         #include <asm/stacktrace.h>
60 ],[
61         ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
62 ],[
63         AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1,
64                 ['struct stacktrace_ops' has 'walk_stack' field])
65 ])
66 ]) # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
67
68 #
69 # LIBCFS_STACKTRACE_WARNING
70 #
71 # 3.0 removes stacktrace_ops warning* functions
72 #
73 AC_DEFUN([LIBCFS_STACKTRACE_WARNING], [
74 LB_CHECK_COMPILE([if 'stacktrace_ops.warning' is exist],
75 stacktrace_ops_warning, [
76         struct task_struct;
77         struct pt_regs;
78         #include <asm/stacktrace.h>
79 ],[
80         ((struct stacktrace_ops *)0)->warning(NULL, NULL);
81 ],[
82         AC_DEFINE(HAVE_STACKTRACE_WARNING, 1,
83                 [stacktrace_ops.warning is exist])
84 ])
85 ]) # LIBCFS_STACKTRACE_WARNING
86
87 #
88 # LC_SHRINKER_WANT_SHRINK_PTR
89 #
90 # RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
91 #
92 AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR], [
93 LB_CHECK_COMPILE([if 'shrinker' want self pointer in handler],
94 shrink_self_pointer, [
95         #include <linux/mm.h>
96 ],[
97         struct shrinker *tmp = NULL;
98         tmp->shrink(tmp, 0, 0);
99 ],[
100         AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
101                 [shrinker want self pointer in handler])
102 ])
103 ]) # LC_SHRINKER_WANT_SHRINK_PTR
104
105 #
106 # LIBCFS_SYSCTL_CTLNAME
107 #
108 # 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
109 #
110 AC_DEFUN([LIBCFS_SYSCTL_CTLNAME], [
111 LB_CHECK_COMPILE([if 'ctl_table' has a 'ctl_name' field],
112 ctl_table_ctl_name, [
113         #include <linux/sysctl.h>
114 ],[
115         struct ctl_table ct;
116         ct.ctl_name = sizeof(ct);
117 ],[
118         AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
119                 [ctl_table has ctl_name field])
120 ])
121 ]) # LIBCFS_SYSCTL_CTLNAME
122
123 #
124 # LC_SK_SLEEP
125 #
126 # 2.6.35 kernel has sk_sleep function
127 #
128 AC_DEFUN([LC_SK_SLEEP], [
129 LB_CHECK_COMPILE([if Linux kernel has 'sk_sleep'],
130 sk_sleep, [
131         #include <net/sock.h>
132 ],[
133         sk_sleep(NULL);
134 ],[
135         AC_DEFINE(HAVE_SK_SLEEP, 1,
136                 [kernel has sk_sleep])
137 ])
138 ]) # LC_SK_SLEEP
139
140 #
141 # LIBCFS_KSTRTOUL
142 #
143 # 2.6.38 kstrtoul is added
144 #
145 AC_DEFUN([LIBCFS_KSTRTOUL], [
146 LB_CHECK_COMPILE([if Linux kernel has 'kstrtoul'],
147 kstrtoul, [
148         #include <linux/kernel.h>
149 ],[
150         unsigned long result;
151         return kstrtoul("12345", 0, &result);
152 ],[
153         AC_DEFINE(HAVE_KSTRTOUL, 1,
154                 [kernel has kstrtoul])
155 ])
156 ]) # LIBCFS_KSTRTOUL
157
158 #
159 # LIBCFS_DUMP_TRACE_ADDRESS
160 #
161 # 2.6.39 adds a base pointer address argument to dump_trace
162 #
163 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS], [
164 LB_CHECK_COMPILE([if 'dump_trace' want address],
165 dump_trace_address, [
166         struct task_struct;
167         struct pt_regs;
168         #include <asm/stacktrace.h>
169 ],[
170         dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
171 ],[
172         AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
173                 [dump_trace want address argument])
174 ])
175 ]) # LIBCFS_DUMP_TRACE_ADDRESS
176
177 #
178 # LC_SHRINK_CONTROL
179 #
180 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
181 # pressure shrinker from Linux 3.0
182 #
183 AC_DEFUN([LC_SHRINK_CONTROL], [
184 LB_CHECK_COMPILE([if 'shrink_control' is present],
185 shrink_control, [
186         #include <linux/mm.h>
187 ],[
188         struct shrink_control tmp = {0};
189         tmp.nr_to_scan = sizeof(tmp);
190 ],[
191         AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
192                 [shrink_control is present])
193 ])
194 ]) # LC_SHRINK_CONTROL
195
196 #
197 # LIBCFS_PROCESS_NAMESPACE
198 #
199 # 3.5 introduced process namespace
200 AC_DEFUN([LIBCFS_PROCESS_NAMESPACE], [
201 LB_CHECK_LINUX_HEADER([linux/uidgid.h], [
202         AC_DEFINE(HAVE_UIDGID_HEADER, 1,
203                 [uidgid.h is present])])
204 ]) # LIBCFS_PROCESS_NAMESPACE
205
206 #
207 # LIBCFS_I_UID_READ
208 #
209 # 3.5 added helpers to read the new uid/gid types from VFS structures
210 # SLE11 SP3 has uidgid.h but not the helpers
211 #
212 AC_DEFUN([LIBCFS_I_UID_READ], [
213 LB_CHECK_COMPILE([if 'i_uid_read' is present],
214 i_uid_read, [
215         #include <linux/fs.h>
216 ],[
217         i_uid_read(NULL);
218 ],[
219         AC_DEFINE(HAVE_I_UID_READ, 1, [i_uid_read is present])
220 ])
221 ]) # LIBCFS_I_UID_READ
222
223 #
224 # LIBCFS_SOCK_ALLOC_FILE
225 #
226 # FC18 3.7.2-201 unexport sock_map_fd() change to
227 # use sock_alloc_file().
228 # upstream commit 56b31d1c9f1e6a3ad92e7bfe252721e05d92b285
229 #
230 AC_DEFUN([LIBCFS_SOCK_ALLOC_FILE], [
231 LB_CHECK_EXPORT([sock_alloc_file], [net/socket.c], [
232         LB_CHECK_COMPILE([if 'sock_alloc_file' takes 3 arguments],
233         sock_alloc_file_3args, [
234                 #include <linux/net.h>
235         ],[
236                 sock_alloc_file(NULL, 0, NULL);
237         ],[
238                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE_3ARGS, 1,
239                         [sock_alloc_file takes 3 arguments])
240         ],[
241                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE, 1,
242                         [sock_alloc_file is exported])
243         ])
244 ])
245 ]) # LIBCFS_SOCK_ALLOC_FILE
246
247 #
248 # LIBCFS_HAVE_CRC32
249 #
250 AC_DEFUN([LIBCFS_HAVE_CRC32], [
251 LB_CHECK_CONFIG_IM([CRC32],
252         [have_crc32="yes"], [have_crc32="no"])
253 AS_IF([test "x$have_crc32" = xyes],
254         [AC_DEFINE(HAVE_CRC32, 1,
255                 [kernel compiled with CRC32 functions])])
256 ]) # LIBCFS_HAVE_CRC32
257
258 #
259 # LIBCFS_ENABLE_CRC32_ACCEL
260 #
261 AC_DEFUN([LIBCFS_ENABLE_CRC32_ACCEL], [
262 LB_CHECK_CONFIG_IM([CRYPTO_CRC32_PCLMUL],
263         [enable_crc32_crypto="no"], [enable_crc32_crypto="yes"])
264 AS_IF([test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes], [
265         AC_DEFINE(NEED_CRC32_ACCEL, 1, [need pclmulqdq based crc32])
266         AC_MSG_WARN([
267
268 No crc32 pclmulqdq crypto api found, enable internal pclmulqdq based crc32
269 ])])
270 ]) # LIBCFS_ENABLE_CRC32_ACCEL
271
272 #
273 # LIBCFS_ENABLE_CRC32C_ACCEL
274 #
275 AC_DEFUN([LIBCFS_ENABLE_CRC32C_ACCEL], [
276 LB_CHECK_CONFIG_IM([CRYPTO_CRC32C_INTEL],
277         [enable_crc32c_crypto="no"], [enable_crc32c_crypto="yes"])
278 AS_IF([test "x$enable_crc32c_crypto" = xyes], [
279         AC_DEFINE(NEED_CRC32C_ACCEL, 1, [need pclmulqdq based crc32c])
280         AC_MSG_WARN([
281
282 No crc32c pclmulqdq crypto api found, enable internal pclmulqdq based crc32c
283 ])])
284 ]) # LIBCFS_ENABLE_CRC32C_ACCEL
285
286 #
287 # FC19 3.12 kernel struct shrinker change
288 #
289 AC_DEFUN([LIBCFS_SHRINKER_COUNT],[
290 LB_CHECK_COMPILE([shrinker has 'count_objects'],
291 shrinker_count_objects, [
292         #include <linux/mmzone.h>
293         #include <linux/shrinker.h>
294 ],[
295         ((struct shrinker*)0)->count_objects(NULL, NULL);
296 ],[
297         AC_DEFINE(HAVE_SHRINKER_COUNT, 1,
298                 [shrinker has count_objects member])
299 ])
300 ])
301
302 #
303 # LIBCFS_PROG_LINUX
304 #
305 # LibCFS linux kernel checks
306 #
307 AC_DEFUN([LIBCFS_PROG_LINUX], [
308 AC_MSG_NOTICE([LibCFS kernel checks
309 ==============================================================================])
310 LIBCFS_CONFIG_PANIC_DUMPLOG
311
312 # 2.6.32
313 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
314 LC_SHRINKER_WANT_SHRINK_PTR
315 # 2.6.33
316 LIBCFS_SYSCTL_CTLNAME
317 # 2.6.35
318 LC_SK_SLEEP
319 # 2.6.38
320 LIBCFS_KSTRTOUL
321 # 2.6.39
322 LIBCFS_DUMP_TRACE_ADDRESS
323 # 2.6.40 fc15
324 LC_SHRINK_CONTROL
325 # 3.0
326 LIBCFS_STACKTRACE_WARNING
327 # 3.5
328 LIBCFS_PROCESS_NAMESPACE
329 LIBCFS_I_UID_READ
330 # 3.7
331 LIBCFS_SOCK_ALLOC_FILE
332 # 3.8
333 LIBCFS_HAVE_CRC32
334 LIBCFS_ENABLE_CRC32_ACCEL
335 # 3.10
336 LIBCFS_ENABLE_CRC32C_ACCEL
337 # 3.12
338 LIBCFS_SHRINKER_COUNT
339 ]) # LIBCFS_PROG_LINUX
340
341 #
342 # LIBCFS_PATH_DEFAULTS
343 #
344 # default paths for installed files
345 #
346 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
347 ]) # LIBCFS_PATH_DEFAULTS
348
349 #
350 # LIBCFS_CONFIGURE
351 #
352 # other configure checks
353 #
354 AC_DEFUN([LIBCFS_CONFIGURE], [
355 AC_MSG_NOTICE([LibCFS core checks
356 ==============================================================================])
357
358 # lnet/utils/portals.c
359 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
360
361 # lnet/utils/debug.c
362 AC_CHECK_HEADERS([linux/version.h])
363
364 AC_CHECK_TYPE([spinlock_t],
365         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
366         [],
367         [#include <linux/spinlock.h>])
368
369 # lnet/utils/wirecheck.c
370 AC_CHECK_FUNCS([strnlen])
371
372 # lnet/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
373 AC_CHECK_FUNCS([strlcpy])
374
375 # libcfs/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
376 AC_CHECK_FUNCS([strlcat])
377
378 # --------  Check for required packages  --------------
379
380 AC_MSG_NOTICE([LibCFS required packages checks
381 ==============================================================================])
382
383 AC_MSG_CHECKING([whether to enable 'efence' debugging support])
384 AC_ARG_ENABLE(efence,
385         AC_HELP_STRING([--enable-efence],
386                 [use efence library]),
387         [], [enable_efence="no"])
388 AC_MSG_RESULT([$enable_efence])
389 AS_IF([test "$enable_efence" = yes], [
390         LIBEFENCE="-lefence"
391         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
392 ], [
393         LIBEFENCE=""
394 ])
395 AC_SUBST(LIBEFENCE)
396
397 # -------- check for -lpthread support ----
398
399 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
400 AC_ARG_ENABLE([libpthread],
401         AC_HELP_STRING([--disable-libpthread],
402                 [disable libpthread]),
403         [], [enable_libpthread="yes"])
404 AC_MSG_RESULT([$enable_libpthread])
405 AS_IF([test "x$enable_libpthread" = xyes], [
406         AC_CHECK_LIB([pthread], [pthread_create],
407                 [ENABLE_LIBPTHREAD="yes"],
408                 [ENABLE_LIBPTHREAD="no"])
409         AS_IF([test "$ENABLE_LIBPTHREAD" = yes], [
410                 PTHREAD_LIBS="-lpthread"
411                 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
412         ], [
413                 PTHREAD_LIBS=""
414         ])
415         AC_SUBST(PTHREAD_LIBS)
416 ], [
417         AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
418         ENABLE_LIBPTHREAD="no"
419 ])
420 AC_SUBST(ENABLE_LIBPTHREAD)
421 ]) # LIBCFS_CONFIGURE
422
423 #
424 # LIBCFS_CONDITIONALS
425 #
426 AC_DEFUN([LIBCFS_CONDITIONALS], [
427 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
428 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32,  [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
429 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
430 ]) # LIBCFS_CONDITIONALS
431
432 #
433 # LIBCFS_CONFIG_FILES
434 #
435 # files that should be generated with AC_OUTPUT
436 #
437 AC_DEFUN([LIBCFS_CONFIG_FILES], [
438 AC_CONFIG_FILES([
439 libcfs/Makefile
440 libcfs/autoMakefile
441 libcfs/autoconf/Makefile
442 libcfs/include/Makefile
443 libcfs/include/libcfs/Makefile
444 libcfs/include/libcfs/linux/Makefile
445 libcfs/include/libcfs/util/Makefile
446 libcfs/libcfs/Makefile
447 libcfs/libcfs/autoMakefile
448 libcfs/libcfs/linux/Makefile
449 libcfs/libcfs/util/Makefile
450 ])
451 ]) # LIBCFS_CONFIG_FILES