Whamcloud - gitweb
first part of 2.6.26 support (lnet/libcfs part)
[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 else
17    AC_DEFINE(CDEBUG_ENABLED, 0, [disable libcfs CDEBUG, CWARN])
18 fi
19
20 AC_MSG_CHECKING([whether to enable ENTRY/EXIT])
21 AC_ARG_ENABLE([libcfs_trace],
22         AC_HELP_STRING([--disable-libcfs-trace],
23                         [disable libcfs ENTRY/EXIT]),
24         [],[enable_libcfs_trace='yes'])
25 AC_MSG_RESULT([$enable_libcfs_trace])
26 if test x$enable_libcfs_trace = xyes; then
27    AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])
28 else
29    AC_DEFINE(CDEBUG_ENTRY_EXIT, 0, [disable libcfs ENTRY/EXIT])
30 fi
31
32 AC_MSG_CHECKING([whether to enable LASSERT, LASSERTF])
33 AC_ARG_ENABLE([libcfs_assert],
34         AC_HELP_STRING([--disable-libcfs-assert],
35                         [disable libcfs LASSERT, LASSERTF]),
36         [],[enable_libcfs_assert='yes'])
37 AC_MSG_RESULT([$enable_libcfs_assert])
38 if test x$enable_libcfs_assert = xyes; then
39    AC_DEFINE(LIBCFS_DEBUG, 1, [enable libcfs LASSERT, LASSERTF])
40 fi
41 ])
42
43 #
44 # LIBCFS_CONFIG_PANIC_DUMPLOG
45 #
46 # check if tunable panic_dumplog is wanted
47 #
48 AC_DEFUN([LIBCFS_CONFIG_PANIC_DUMPLOG],
49 [AC_MSG_CHECKING([for tunable panic_dumplog support])
50 AC_ARG_ENABLE([panic_dumplog],
51        AC_HELP_STRING([--enable-panic_dumplog],
52                       [enable panic_dumplog]),
53        [],[enable_panic_dumplog='no'])
54 if test x$enable_panic_dumplog = xyes ; then
55        AC_DEFINE(LNET_DUMP_ON_PANIC, 1, [use dumplog on panic])
56        AC_MSG_RESULT([yes (by request)])
57 else
58        AC_MSG_RESULT([no])
59 fi
60 ])
61
62 #
63 # LIBCFS_STRUCT_PAGE_LIST
64 #
65 # 2.6.4 no longer has page->list
66 #
67 AC_DEFUN([LIBCFS_STRUCT_PAGE_LIST],
68 [AC_MSG_CHECKING([if struct page has a list field])
69 LB_LINUX_TRY_COMPILE([
70         #include <linux/mm.h>
71 ],[
72         struct page page;
73         &page.list;
74 ],[
75         AC_MSG_RESULT([yes])
76         AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
77 ],[
78         AC_MSG_RESULT([no])
79 ])
80 ])
81
82 #
83 # LIBCFS_STRUCT_SIGHAND
84 #
85 # red hat 2.4 adds sighand to struct task_struct
86 #
87 AC_DEFUN([LIBCFS_STRUCT_SIGHAND],
88 [AC_MSG_CHECKING([if task_struct has a sighand field])
89 LB_LINUX_TRY_COMPILE([
90         #include <linux/sched.h>
91 ],[
92         struct task_struct p;
93         p.sighand = NULL;
94 ],[
95         AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
96         AC_MSG_RESULT([yes])
97 ],[
98         AC_MSG_RESULT([no])
99 ])
100 ])
101
102 #
103 # LIBCFS_FUNC_CPU_ONLINE
104 #
105 # cpu_online is different in rh 2.4, vanilla 2.4, and 2.6
106 #
107 AC_DEFUN([LIBCFS_FUNC_CPU_ONLINE],
108 [AC_MSG_CHECKING([if kernel defines cpu_online()])
109 LB_LINUX_TRY_COMPILE([
110         #include <linux/sched.h>
111 ],[
112         cpu_online(0);
113 ],[
114         AC_MSG_RESULT([yes])
115         AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
116 ],[
117         AC_MSG_RESULT([no])
118 ])
119 ])
120
121 #
122 # LIBCFS_TYPE_GFP_T
123 #
124 # check if gfp_t is typedef-ed
125 #
126 AC_DEFUN([LIBCFS_TYPE_GFP_T],
127 [AC_MSG_CHECKING([if kernel defines gfp_t])
128 LB_LINUX_TRY_COMPILE([
129         #include <linux/gfp.h>
130 ],[
131         return sizeof(gfp_t);
132 ],[
133         AC_MSG_RESULT([yes])
134         AC_DEFINE(HAVE_GFP_T, 1, [gfp_t found])
135 ],[
136         AC_MSG_RESULT([no])
137 ])
138 ])
139
140 #
141 # LIBCFS_TYPE_CPUMASK_T
142 #
143 # same goes for cpumask_t
144 #
145 AC_DEFUN([LIBCFS_TYPE_CPUMASK_T],
146 [AC_MSG_CHECKING([if kernel defines cpumask_t])
147 LB_LINUX_TRY_COMPILE([
148         #include <linux/sched.h>
149 ],[
150         return sizeof (cpumask_t);
151 ],[
152         AC_MSG_RESULT([yes])
153         AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found])
154 ],[
155         AC_MSG_RESULT([no])
156 ])
157 ])
158
159 #
160 # LIBCFS_FUNC_SHOW_TASK
161 #
162 # we export show_task(), but not all kernels have it (yet)
163 #
164 AC_DEFUN([LIBCFS_FUNC_SHOW_TASK],
165 [LB_CHECK_SYMBOL_EXPORT([show_task],
166 [kernel/ksyms.c kernel/sched.c],[
167 AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
168 ],[
169 ])
170 ])
171
172 # check userland __u64 type
173 AC_DEFUN([LIBCFS_U64_LONG_LONG],
174 [AC_MSG_CHECKING([u64 is long long type])
175 tmp_flags="$CFLAGS"
176 CFLAGS="$CFLAGS -Werror"
177 AC_COMPILE_IFELSE([
178         #include <linux/types.h>
179         int main(void) {
180                 unsigned long long *data1;
181                 __u64 *data2;
182                 
183                 data1 = data2;
184                 return 0;
185         }
186 ],[
187         AC_MSG_RESULT([yes])
188         AC_DEFINE(HAVE_U64_LONG_LONG, 1,
189                   [__u64 is long long type])
190 ],[
191         AC_MSG_RESULT([no])
192 ])
193 CFLAGS="$tmp_flags"
194 ])
195
196 # check userland size_t type
197 AC_DEFUN([LIBCFS_SIZE_T_LONG],
198 [AC_MSG_CHECKING([size_t is unsigned long type])
199 tmp_flags="$CFLAGS"
200 CFLAGS="$CFLAGS -Werror"
201 AC_COMPILE_IFELSE([
202         #include <linux/types.h>
203         int main(void) {
204                 unsigned long *data1;
205                 size_t *data2;
206                 
207                 data1 = data2;
208                 return 0;
209         }
210 ],[
211         AC_MSG_RESULT([yes])
212         AC_DEFINE(HAVE_SIZE_T_LONG, 1,
213                   [size_t is long type])
214 ],[
215         AC_MSG_RESULT([no])
216 ])
217 CFLAGS="$tmp_flags"
218 ])
219
220 AC_DEFUN([LIBCFS_SSIZE_T_LONG],
221 [AC_MSG_CHECKING([ssize_t is signed long type])
222 tmp_flags="$CFLAGS"
223 CFLAGS="$CFLAGS -Werror"
224 AC_COMPILE_IFELSE([
225         #include <linux/types.h>
226         int main(void) {
227                 long *data1;
228                 ssize_t *data2;
229                 
230                 data1 = data2;
231                 return 0;
232         }
233 ],[
234         AC_MSG_RESULT([yes])
235         AC_DEFINE(HAVE_SSIZE_T_LONG, 1,
236                   [ssize_t is long type])
237 ],[
238         AC_MSG_RESULT([no])
239 ])
240 CFLAGS="$tmp_flags"
241 ])
242
243
244 # LIBCFS_TASKLIST_LOCK
245 # 2.6.18 remove tasklist_lock export
246 AC_DEFUN([LIBCFS_TASKLIST_LOCK],
247 [LB_CHECK_SYMBOL_EXPORT([tasklist_lock],
248 [kernel/fork.c],[
249 AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
250          [tasklist_lock exported])
251 ],[
252 ])
253 ])
254
255 # 2.6.19 API changes
256 # kmem_cache_destroy(cachep) return void instead of
257 # int
258 AC_DEFUN([LIBCFS_KMEM_CACHE_DESTROY_INT],
259 [AC_MSG_CHECKING([kmem_cache_destroy(cachep) return int])
260 LB_LINUX_TRY_COMPILE([
261         #include <linux/slab.h>
262 ],[
263         int i = kmem_cache_destroy(NULL);
264 ],[
265         AC_MSG_RESULT(yes)
266         AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT, 1,
267                 [kmem_cache_destroy(cachep) return int])
268 ],[
269         AC_MSG_RESULT(NO)
270 ])
271 ])
272
273 # 2.6.19 API change
274 #panic_notifier_list use atomic_notifier operations
275 #
276 AC_DEFUN([LIBCFS_ATOMIC_PANIC_NOTIFIER],
277 [AC_MSG_CHECKING([panic_notifier_list is atomic])
278 LB_LINUX_TRY_COMPILE([
279         #include <linux/notifier.h>
280         #include <linux/kernel.h>
281 ],[
282         struct atomic_notifier_head panic_notifier_list;
283 ],[
284         AC_MSG_RESULT(yes)
285         AC_DEFINE(HAVE_ATOMIC_PANIC_NOTIFIER, 1,
286                 [panic_notifier_list is atomic_notifier_head])
287 ],[
288         AC_MSG_RESULT(NO)
289 ])
290 ])
291
292 # 2.6.20 API change INIT_WORK use 2 args and not
293 # store data inside
294 AC_DEFUN([LIBCFS_3ARGS_INIT_WORK],
295 [AC_MSG_CHECKING([check INIT_WORK want 3 args])
296 LB_LINUX_TRY_COMPILE([
297         #include <linux/workqueue.h>
298 ],[
299         struct work_struct work;
300
301         INIT_WORK(&work, NULL, NULL);
302 ],[
303         AC_MSG_RESULT(yes)
304         AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
305                   [INIT_WORK use 3 args and store data inside])
306 ],[
307         AC_MSG_RESULT(NO)
308 ])
309 ])
310
311 # 2.6.21 api change. 'register_sysctl_table' use only one argument,
312 # instead of more old which need two.
313 AC_DEFUN([LIBCFS_2ARGS_REGISTER_SYSCTL],
314 [AC_MSG_CHECKING([check register_sysctl_table want 2 args])
315 LB_LINUX_TRY_COMPILE([
316         #include <linux/sysctl.h>
317 ],[
318         return register_sysctl_table(NULL,0);
319 ],[
320         AC_MSG_RESULT(yes)
321         AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
322                   [register_sysctl_table want 2 args])
323 ],[
324         AC_MSG_RESULT(NO)
325 ])
326 ])
327
328 # 2.6.21 marks kmem_cache_t deprecated and uses struct kmem_cache
329 # instead
330 AC_DEFUN([LIBCFS_KMEM_CACHE],
331 [AC_MSG_CHECKING([check kernel has struct kmem_cache])
332 tmp_flags="$EXTRA_KCFLAGS"
333 EXTRA_KCFLAGS="-Werror"
334 LB_LINUX_TRY_COMPILE([
335         #include <linux/slab.h>
336         typedef struct kmem_cache cache_t;
337 ],[
338         cache_t *cachep = NULL;
339
340         kmem_cache_alloc(cachep, 0);
341 ],[
342         AC_MSG_RESULT(yes)
343         AC_DEFINE(HAVE_KMEM_CACHE, 1,
344                   [kernel has struct kmem_cache])
345 ],[
346         AC_MSG_RESULT(NO)
347 ])
348 EXTRA_KCFLAGS="$tmp_flags"
349 ])
350 # 2.6.23 lost dtor argument
351 AC_DEFUN([LIBCFS_KMEM_CACHE_CREATE_DTOR],
352 [AC_MSG_CHECKING([check kmem_cache_create has dtor argument])
353 LB_LINUX_TRY_COMPILE([
354         #include <linux/slab.h>
355 ],[
356         kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);
357 ],[
358         AC_MSG_RESULT(yes)
359         AC_DEFINE(HAVE_KMEM_CACHE_CREATE_DTOR, 1,
360                   [kmem_cache_create has dtor argument])
361 ],[
362         AC_MSG_RESULT(NO)
363 ])
364 ])
365
366 # 2.6.24 request not use real numbers for ctl_name
367 AC_DEFUN([LN_SYSCTL_UNNUMBERED],
368 [AC_MSG_CHECKING([for CTL_UNNUMBERED])
369 LB_LINUX_TRY_COMPILE([
370         #include <linux/sysctl.h>
371 ],[
372         #ifndef CTL_UNNUMBERED
373         #error CTL_UNNUMBERED not exist in kernel
374         #endif
375 ],[
376         AC_MSG_RESULT(yes)
377         AC_DEFINE(HAVE_SYSCTL_UNNUMBERED, 1,
378                   [sysctl has CTL_UNNUMBERED])
379 ],[
380         AC_MSG_RESULT(NO)
381 ])
382 ])
383
384 # 2.6.24 lost scatterlist->page
385 AC_DEFUN([LN_SCATTERLIST_SETPAGE],
386 [AC_MSG_CHECKING([for exist sg_set_page])
387 LB_LINUX_TRY_COMPILE([
388         #include <linux/scatterlist.h>
389 ],[
390         sg_set_page(NULL,NULL,0,0);
391 ],[
392         AC_MSG_RESULT(yes)
393         AC_DEFINE(HAVE_SCATTERLIST_SETPAGE, 1,
394                   [struct scatterlist has page member])
395 ],[
396         AC_MSG_RESULT(NO)
397 ])
398 ])
399
400 # 2.6.26 use int instead of atomic for sem.count
401 AC_DEFUN([LN_SEM_COUNT],
402 [AC_MSG_CHECKING([atomic sem.count])
403 LB_LINUX_TRY_COMPILE([
404         #include <asm/semaphore.h>
405 ],[
406         struct semaphore s;
407         
408         atomic_read(&s.count);
409 ],[
410         AC_MSG_RESULT(yes)
411         AC_DEFINE(HAVE_SEM_COUNT_ATOMIC, 1,
412                   [semaphore counter is atomic])
413 ],[
414         AC_MSG_RESULT(NO)
415 ])
416 ])
417
418
419 #
420 # LIBCFS_PROG_LINUX
421 #
422 # LNet linux kernel checks
423 #
424 AC_DEFUN([LIBCFS_PROG_LINUX],
425 [
426 LIBCFS_FUNC_CPU_ONLINE
427 LIBCFS_TYPE_GFP_T
428 LIBCFS_TYPE_CPUMASK_T
429 LIBCFS_CONFIG_PANIC_DUMPLOG
430
431 LIBCFS_STRUCT_PAGE_LIST
432 LIBCFS_STRUCT_SIGHAND
433 LIBCFS_FUNC_SHOW_TASK
434 LIBCFS_U64_LONG_LONG
435 LIBCFS_SSIZE_T_LONG
436 LIBCFS_SIZE_T_LONG
437 # 2.6.18
438 LIBCFS_TASKLIST_LOCK
439 # 2.6.19
440 LIBCFS_KMEM_CACHE_DESTROY_INT
441 LIBCFS_ATOMIC_PANIC_NOTIFIER
442 # 2.6.20
443 LIBCFS_3ARGS_INIT_WORK
444 # 2.6.21
445 LIBCFS_2ARGS_REGISTER_SYSCTL
446 LIBCFS_KMEM_CACHE
447 # 2.6.23
448 LIBCFS_KMEM_CACHE_CREATE_DTOR
449 # 2.6.24
450 LN_SYSCTL_UNNUMBERED
451 LN_SCATTERLIST_SETPAGE
452 # 2.6.26
453 LN_SEM_COUNT
454 ])
455
456 #
457 # LIBCFS_PROG_DARWIN
458 #
459 # Darwin checks
460 #
461 AC_DEFUN([LIBCFS_PROG_DARWIN],
462 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
463 ])
464
465 #
466 # LIBCFS_PATH_DEFAULTS
467 #
468 # default paths for installed files
469 #
470 AC_DEFUN([LIBCFS_PATH_DEFAULTS],
471 [
472 ])
473
474 #
475 # LIBCFS_CONFIGURE
476 #
477 # other configure checks
478 #
479 AC_DEFUN([LIBCFS_CONFIGURE],
480 [# lnet/utils/portals.c
481 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
482
483 # lnet/utils/debug.c
484 AC_CHECK_HEADERS([linux/version.h])
485
486 AC_CHECK_TYPE([spinlock_t],
487         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
488         [],
489         [#include <linux/spinlock.h>])
490
491 # lnet/utils/wirecheck.c
492 AC_CHECK_FUNCS([strnlen])
493
494 # --------  Check for required packages  --------------
495
496
497 AC_MSG_CHECKING([if efence debugging support is requested])
498 AC_ARG_ENABLE(efence,
499         AC_HELP_STRING([--enable-efence],
500                         [use efence library]),
501         [],[enable_efence='no'])
502 AC_MSG_RESULT([$enable_efence])
503 if test "$enable_efence" = "yes" ; then
504         LIBEFENCE="-lefence"
505         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
506 else
507         LIBEFENCE=""
508 fi
509 AC_SUBST(LIBEFENCE)
510
511
512 # -------- check for -lpthread support ----
513 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
514 AC_ARG_ENABLE([libpthread],
515         AC_HELP_STRING([--disable-libpthread],
516                 [disable libpthread]),
517         [],[enable_libpthread=yes])
518 if test "$enable_libpthread" = "yes" ; then
519         AC_CHECK_LIB([pthread], [pthread_create],
520                 [ENABLE_LIBPTHREAD="yes"],
521                 [ENABLE_LIBPTHREAD="no"])
522         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
523                 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
524                 PTHREAD_LIBS="-lpthread"
525                 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
526         else
527                 PTHREAD_LIBS=""
528                 AC_MSG_RESULT([no libpthread is found])
529         fi
530         AC_SUBST(PTHREAD_LIBS)
531 else
532         AC_MSG_RESULT([no (disabled explicitly)])
533         ENABLE_LIBPTHREAD="no"
534 fi
535 AC_SUBST(ENABLE_LIBPTHREAD)
536
537
538 ])
539
540 #
541 # LIBCFS_CONDITIONALS
542 #
543 # AM_CONDITOINAL defines for lnet
544 #
545 AC_DEFUN([LIBCFS_CONDITIONALS],
546 [
547 ])
548
549 #
550 # LIBCFS_CONFIG_FILES
551 #
552 # files that should be generated with AC_OUTPUT
553 #
554 AC_DEFUN([LIBCFS_CONFIG_FILES],
555 [AC_CONFIG_FILES([
556 libcfs/Kernelenv
557 libcfs/Makefile
558 libcfs/autoMakefile
559 libcfs/autoconf/Makefile
560 libcfs/include/Makefile
561 libcfs/include/libcfs/Makefile
562 libcfs/include/libcfs/linux/Makefile
563 libcfs/include/libcfs/posix/Makefile
564 libcfs/include/libcfs/util/Makefile
565 libcfs/libcfs/Makefile
566 libcfs/libcfs/autoMakefile
567 libcfs/libcfs/linux/Makefile
568 libcfs/libcfs/posix/Makefile
569 libcfs/libcfs/util/Makefile
570 ])
571 case $lb_target_os in
572         darwin)
573                 AC_CONFIG_FILES([
574 libcfs/include/libcfs/darwin/Makefile
575 libcfs/libcfs/darwin/Makefile
576 ])
577                 ;;
578 esac
579 ])