Whamcloud - gitweb
LU-6763 lnet: test for sk_sleep presence in compact-2.6.h
[fs/lustre-release.git] / libcfs / autoconf / lustre-libcfs.m4
1 #
2 # LIBCFS_CONFIG_CDEBUG
3 #
4 # whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
5 #
6 AC_DEFUN([LIBCFS_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 ]) # LIBCFS_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 # LIBCFS_KSTRTOUL
125 #
126 # 2.6.38 kstrtoul is added
127 #
128 AC_DEFUN([LIBCFS_KSTRTOUL], [
129 LB_CHECK_COMPILE([if Linux kernel has 'kstrtoul'],
130 kstrtoul, [
131         #include <linux/kernel.h>
132 ],[
133         unsigned long result;
134         return kstrtoul("12345", 0, &result);
135 ],[
136         AC_DEFINE(HAVE_KSTRTOUL, 1,
137                 [kernel has kstrtoul])
138 ])
139 ]) # LIBCFS_KSTRTOUL
140
141 #
142 # LIBCFS_DUMP_TRACE_ADDRESS
143 #
144 # 2.6.39 adds a base pointer address argument to dump_trace
145 #
146 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS], [
147 LB_CHECK_COMPILE([if 'dump_trace' want address],
148 dump_trace_address, [
149         struct task_struct;
150         struct pt_regs;
151         #include <asm/stacktrace.h>
152 ],[
153         dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
154 ],[
155         AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
156                 [dump_trace want address argument])
157 ])
158 ]) # LIBCFS_DUMP_TRACE_ADDRESS
159
160 #
161 # LC_SHRINK_CONTROL
162 #
163 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
164 # pressure shrinker from Linux 3.0
165 #
166 AC_DEFUN([LC_SHRINK_CONTROL], [
167 LB_CHECK_COMPILE([if 'shrink_control' is present],
168 shrink_control, [
169         #include <linux/atomic.h>
170         #include <linux/mm.h>
171 ],[
172         struct shrink_control tmp = {0};
173         tmp.nr_to_scan = sizeof(tmp);
174 ],[
175         AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
176                 [shrink_control is present])
177 ])
178 ]) # LC_SHRINK_CONTROL
179
180 #
181 # LIBCFS_PROCESS_NAMESPACE
182 #
183 # 3.5 introduced process namespace
184 AC_DEFUN([LIBCFS_PROCESS_NAMESPACE], [
185 LB_CHECK_LINUX_HEADER([linux/uidgid.h], [
186         AC_DEFINE(HAVE_UIDGID_HEADER, 1,
187                 [uidgid.h is present])])
188 ]) # LIBCFS_PROCESS_NAMESPACE
189
190 #
191 # LIBCFS_I_UID_READ
192 #
193 # 3.5 added helpers to read the new uid/gid types from VFS structures
194 # SLE11 SP3 has uidgid.h but not the helpers
195 #
196 AC_DEFUN([LIBCFS_I_UID_READ], [
197 LB_CHECK_COMPILE([if 'i_uid_read' is present],
198 i_uid_read, [
199         #include <linux/fs.h>
200 ],[
201         i_uid_read(NULL);
202 ],[
203         AC_DEFINE(HAVE_I_UID_READ, 1, [i_uid_read is present])
204 ])
205 ]) # LIBCFS_I_UID_READ
206
207 #
208 # LIBCFS_SOCK_ALLOC_FILE
209 #
210 # FC18 3.7.2-201 unexport sock_map_fd() change to
211 # use sock_alloc_file().
212 # upstream commit 56b31d1c9f1e6a3ad92e7bfe252721e05d92b285
213 #
214 AC_DEFUN([LIBCFS_SOCK_ALLOC_FILE], [
215 LB_CHECK_EXPORT([sock_alloc_file], [net/socket.c], [
216         LB_CHECK_COMPILE([if 'sock_alloc_file' takes 3 arguments],
217         sock_alloc_file_3args, [
218                 #include <linux/net.h>
219         ],[
220                 sock_alloc_file(NULL, 0, NULL);
221         ],[
222                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE_3ARGS, 1,
223                         [sock_alloc_file takes 3 arguments])
224         ],[
225                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE, 1,
226                         [sock_alloc_file is exported])
227         ])
228 ])
229 ]) # LIBCFS_SOCK_ALLOC_FILE
230
231 #
232 # LIBCFS_HAVE_CRC32
233 #
234 AC_DEFUN([LIBCFS_HAVE_CRC32], [
235 LB_CHECK_CONFIG_IM([CRC32],
236         [have_crc32="yes"], [have_crc32="no"])
237 AS_IF([test "x$have_crc32" = xyes],
238         [AC_DEFINE(HAVE_CRC32, 1,
239                 [kernel compiled with CRC32 functions])])
240 ]) # LIBCFS_HAVE_CRC32
241
242 #
243 # LIBCFS_ENABLE_CRC32_ACCEL
244 #
245 AC_DEFUN([LIBCFS_ENABLE_CRC32_ACCEL], [
246 LB_CHECK_CONFIG_IM([CRYPTO_CRC32_PCLMUL],
247         [enable_crc32_crypto="no"], [enable_crc32_crypto="yes"])
248 AS_IF([test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes], [
249         AC_DEFINE(NEED_CRC32_ACCEL, 1, [need pclmulqdq based crc32])
250         AC_MSG_WARN([
251
252 No crc32 pclmulqdq crypto api found, enable internal pclmulqdq based crc32
253 ])])
254 ]) # LIBCFS_ENABLE_CRC32_ACCEL
255
256 #
257 # LIBCFS_ENABLE_CRC32C_ACCEL
258 #
259 AC_DEFUN([LIBCFS_ENABLE_CRC32C_ACCEL], [
260 LB_CHECK_CONFIG_IM([CRYPTO_CRC32C_INTEL],
261         [enable_crc32c_crypto="no"], [enable_crc32c_crypto="yes"])
262 AS_IF([test "x$enable_crc32c_crypto" = xyes], [
263         AC_DEFINE(NEED_CRC32C_ACCEL, 1, [need pclmulqdq based crc32c])
264         AC_MSG_WARN([
265
266 No crc32c pclmulqdq crypto api found, enable internal pclmulqdq based crc32c
267 ])])
268 ]) # LIBCFS_ENABLE_CRC32C_ACCEL
269
270 #
271 # FC19 3.12 kernel struct shrinker change
272 #
273 AC_DEFUN([LIBCFS_SHRINKER_COUNT],[
274 LB_CHECK_COMPILE([shrinker has 'count_objects'],
275 shrinker_count_objects, [
276         #include <linux/mmzone.h>
277         #include <linux/shrinker.h>
278 ],[
279         ((struct shrinker*)0)->count_objects(NULL, NULL);
280 ],[
281         AC_DEFINE(HAVE_SHRINKER_COUNT, 1,
282                 [shrinker has count_objects member])
283 ])
284 ]) # LIBCFS_SHRINKER_COUNT
285
286 #
287 # Kernel version 3.17 changed hlist_add_after to
288 # hlist_add_behind
289 #
290 AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
291 LB_CHECK_COMPILE([does function hlist_add_after exist'],
292 hlist_add_after, [
293         #include <linux/list.h>
294 ],[
295         hlist_add_after(NULL, NULL);
296 ],[
297         AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
298                 [hlist_add_after is available])
299 ])
300 ]) # LIBCFS_HLIST_ADD_AFTER
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.38
318 LIBCFS_KSTRTOUL
319 # 2.6.39
320 LIBCFS_DUMP_TRACE_ADDRESS
321 # 2.6.40 fc15
322 LC_SHRINK_CONTROL
323 # 3.0
324 LIBCFS_STACKTRACE_WARNING
325 # 3.5
326 LIBCFS_PROCESS_NAMESPACE
327 LIBCFS_I_UID_READ
328 # 3.7
329 LIBCFS_SOCK_ALLOC_FILE
330 # 3.8
331 LIBCFS_HAVE_CRC32
332 LIBCFS_ENABLE_CRC32_ACCEL
333 # 3.10
334 LIBCFS_ENABLE_CRC32C_ACCEL
335 # 3.12
336 LIBCFS_SHRINKER_COUNT
337 # 3.17
338 LIBCFS_HLIST_ADD_AFTER
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 # libcfs/include/libcfs/linux/linux-prim.h, ...
379 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
380
381 # libcfs/include/libcfs/linux/linux-prim.h
382 AC_CHECK_HEADERS([linux/random.h], [], [],
383                  [#ifdef HAVE_LINUX_TYPES_H
384                   #include <linux/types.h>
385                   #endif
386                  ])
387
388 # libcfs/include/libcfs/linux/libcfs.h
389 # libcfs/include/libcfs/byteorder.h
390 # libcfs/libcfs/util/nidstrings.c
391 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
392 AC_CHECK_FUNCS([gethostbyname])
393
394 # --------  Check for required packages  --------------
395
396 AC_MSG_NOTICE([LibCFS required packages checks
397 ==============================================================================])
398
399 AC_MSG_CHECKING([whether to enable readline support])
400 AC_ARG_ENABLE(readline,
401         AC_HELP_STRING([--disable-readline],
402                 [disable readline support]),
403         [], [enable_readline="yes"])
404 AC_MSG_RESULT([$enable_readline])
405
406 LIBREADLINE=""
407 AS_IF([test "x$enable_readline" = xyes], [
408         AC_CHECK_LIB([readline], [readline], [
409                 LIBREADLINE="-lreadline"
410                 AC_DEFINE(HAVE_LIBREADLINE, 1,
411                         [readline library is available])
412         ])
413 ])
414 AC_SUBST(LIBREADLINE)
415
416 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
417 AC_ARG_ENABLE([libpthread],
418         AC_HELP_STRING([--disable-libpthread],
419                 [disable libpthread]),
420         [], [enable_libpthread="yes"])
421 AC_MSG_RESULT([$enable_libpthread])
422
423 PTHREAD_LIBS=""
424 AS_IF([test "x$enable_libpthread" = xyes], [
425         AC_CHECK_LIB([pthread], [pthread_create], [
426                 PTHREAD_LIBS="-lpthread"
427                 AC_DEFINE([HAVE_LIBPTHREAD], 1,
428                         [use libpthread for libcfs library])
429         ])
430 ], [
431         AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
432 ])
433 AC_SUBST(PTHREAD_LIBS)
434 ]) # LIBCFS_CONFIGURE
435
436 #
437 # LIBCFS_CONDITIONALS
438 #
439 AC_DEFUN([LIBCFS_CONDITIONALS], [
440 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
441 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32,  [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
442 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
443 ]) # LIBCFS_CONDITIONALS
444
445 #
446 # LIBCFS_CONFIG_FILES
447 #
448 # files that should be generated with AC_OUTPUT
449 #
450 AC_DEFUN([LIBCFS_CONFIG_FILES], [
451 AC_CONFIG_FILES([
452 libcfs/Makefile
453 libcfs/autoMakefile
454 libcfs/autoconf/Makefile
455 libcfs/include/Makefile
456 libcfs/include/libcfs/Makefile
457 libcfs/include/libcfs/linux/Makefile
458 libcfs/include/libcfs/util/Makefile
459 libcfs/libcfs/Makefile
460 libcfs/libcfs/autoMakefile
461 libcfs/libcfs/linux/Makefile
462 libcfs/libcfs/util/Makefile
463 ])
464 ]) # LIBCFS_CONFIG_FILES