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