Whamcloud - gitweb
07fb2ce99afad710119771d3050f9fa167f5f928
[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 & kernel __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         #include <linux/stddef.h>
180         int main(void) {
181                 unsigned long long *data1;
182                 __u64 *data2 = NULL;
183
184                 data1 = data2;
185                 return 0;
186         }
187 ],[
188         AC_MSG_RESULT([yes])
189         AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
190                   [__u64 is long long type])
191 ],[
192         AC_MSG_RESULT([no])
193 ])
194 CFLAGS="$tmp_flags"
195 AC_MSG_CHECKING([kernel __u64 is long long type])
196 tmp_flags="$EXTRA_KCFLAGS"
197 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
198 LB_LINUX_TRY_COMPILE([
199         #include <linux/types.h>
200         #include <linux/stddef.h>
201 ],[
202         unsigned long long *data1;
203         __u64 *data2 = NULL;
204
205         data1 = data2;
206 ],[
207         AC_MSG_RESULT([yes])
208         AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
209                   [kernel __u64 is long long type])
210 ],[
211         AC_MSG_RESULT([no])
212 ])
213 EXTRA_KCFLAGS="$tmp_flags"
214 ])
215
216 # check if task_struct with rcu memeber
217 AC_DEFUN([LIBCFS_TASK_RCU],
218 [AC_MSG_CHECKING([if task_struct has a rcu field])
219 LB_LINUX_TRY_COMPILE([
220         #include <linux/sched.h>
221 ],[
222         struct task_struct tsk;
223
224         tsk.rcu.next = NULL;
225 ],[
226         AC_MSG_RESULT([yes])
227         AC_DEFINE(HAVE_TASK_RCU, 1,
228                   [task_struct has rcu field])
229 ],[
230         AC_MSG_RESULT([no])
231 ])
232 ])
233
234 # LIBCFS_TASKLIST_LOCK
235 # 2.6.18 remove tasklist_lock export
236 AC_DEFUN([LIBCFS_TASKLIST_LOCK],
237 [LB_CHECK_SYMBOL_EXPORT([tasklist_lock],
238 [kernel/fork.c],[
239 AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
240          [tasklist_lock exported])
241 ],[
242 ])
243 ])
244
245 # 2.6.19 API changes
246 # kmem_cache_destroy(cachep) return void instead of
247 # int
248 AC_DEFUN([LIBCFS_KMEM_CACHE_DESTROY_INT],
249 [AC_MSG_CHECKING([kmem_cache_destroy(cachep) return int])
250 LB_LINUX_TRY_COMPILE([
251         #include <linux/slab.h>
252 ],[
253         int i = kmem_cache_destroy(NULL);
254 ],[
255         AC_MSG_RESULT(yes)
256         AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT, 1,
257                 [kmem_cache_destroy(cachep) return int])
258 ],[
259         AC_MSG_RESULT(NO)
260 ])
261 ])
262
263 # 2.6.19 API change
264 #panic_notifier_list use atomic_notifier operations
265 #
266 AC_DEFUN([LIBCFS_ATOMIC_PANIC_NOTIFIER],
267 [AC_MSG_CHECKING([panic_notifier_list is atomic])
268 LB_LINUX_TRY_COMPILE([
269         #include <linux/notifier.h>
270         #include <linux/kernel.h>
271 ],[
272         struct atomic_notifier_head panic_notifier_list;
273 ],[
274         AC_MSG_RESULT(yes)
275         AC_DEFINE(HAVE_ATOMIC_PANIC_NOTIFIER, 1,
276                 [panic_notifier_list is atomic_notifier_head])
277 ],[
278         AC_MSG_RESULT(NO)
279 ])
280 ])
281
282 # since 2.6.19 nlmsg_multicast() needs 5 argument.
283 AC_DEFUN([LIBCFS_NLMSG_MULTICAST],
284 [AC_MSG_CHECKING([nlmsg_multicast needs 5 argument])
285 LB_LINUX_TRY_COMPILE([
286         #include <net/netlink.h>
287 ],[
288         nlmsg_multicast(NULL, NULL, 0, 0, 0);
289 ],[
290         AC_MSG_RESULT(yes)
291         AC_DEFINE(HAVE_NLMSG_MULTICAST_5ARGS, 1,
292                   [nlmsg_multicast needs 5 argument])
293 ],[
294         AC_MSG_RESULT(NO)
295 ])
296 ])
297
298 #
299 # LIBCFS_NETLINK
300 #
301 # If we have netlink.h, and nlmsg_new takes 2 args (2.6.19)
302 #
303 AC_DEFUN([LIBCFS_NETLINK],
304 [AC_MSG_CHECKING([if netlink.h can be compiled])
305 LB_LINUX_TRY_COMPILE([
306         #include <net/netlink.h>
307 ],[],[
308         AC_MSG_RESULT([yes])
309         AC_DEFINE(HAVE_NETLINK, 1, [net/netlink.h found])
310
311         AC_MSG_CHECKING([if nlmsg_new takes a 2nd argument])
312         LB_LINUX_TRY_COMPILE([
313                 #include <net/netlink.h>
314         ],[
315                 nlmsg_new(100, GFP_KERNEL);
316         ],[
317                 AC_MSG_RESULT([yes])
318                 AC_DEFINE(HAVE_NETLINK_NL2, 1, [nlmsg_new takes 2 args])
319         ],[
320                 AC_MSG_RESULT([no])
321         ])
322 ],[
323         AC_MSG_RESULT([no])
324 ])
325 ])
326
327 # 2.6.20 API change INIT_WORK use 2 args and not
328 # store data inside
329 AC_DEFUN([LIBCFS_3ARGS_INIT_WORK],
330 [AC_MSG_CHECKING([check INIT_WORK want 3 args])
331 LB_LINUX_TRY_COMPILE([
332         #include <linux/workqueue.h>
333 ],[
334         struct work_struct work;
335
336         INIT_WORK(&work, NULL, NULL);
337 ],[
338         AC_MSG_RESULT(yes)
339         AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
340                   [INIT_WORK use 3 args and store data inside])
341 ],[
342         AC_MSG_RESULT(NO)
343 ])
344 ])
345
346 # 2.6.21 api change. 'register_sysctl_table' use only one argument,
347 # instead of more old which need two.
348 AC_DEFUN([LIBCFS_2ARGS_REGISTER_SYSCTL],
349 [AC_MSG_CHECKING([check register_sysctl_table want 2 args])
350 LB_LINUX_TRY_COMPILE([
351         #include <linux/sysctl.h>
352 ],[
353         return register_sysctl_table(NULL,0);
354 ],[
355         AC_MSG_RESULT(yes)
356         AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
357                   [register_sysctl_table want 2 args])
358 ],[
359         AC_MSG_RESULT(NO)
360 ])
361 ])
362
363 # 2.6.21 marks kmem_cache_t deprecated and uses struct kmem_cache
364 # instead
365 AC_DEFUN([LIBCFS_KMEM_CACHE],
366 [AC_MSG_CHECKING([check kernel has struct kmem_cache])
367 tmp_flags="$EXTRA_KCFLAGS"
368 EXTRA_KCFLAGS="-Werror"
369 LB_LINUX_TRY_COMPILE([
370         #include <linux/slab.h>
371         typedef struct kmem_cache cache_t;
372 ],[
373         cache_t *cachep = NULL;
374
375         kmem_cache_alloc(cachep, 0);
376 ],[
377         AC_MSG_RESULT(yes)
378         AC_DEFINE(HAVE_KMEM_CACHE, 1,
379                   [kernel has struct kmem_cache])
380 ],[
381         AC_MSG_RESULT(NO)
382 ])
383 EXTRA_KCFLAGS="$tmp_flags"
384 ])
385
386 # 2.6.23 lost dtor argument
387 AC_DEFUN([LIBCFS_KMEM_CACHE_CREATE_DTOR],
388 [AC_MSG_CHECKING([check kmem_cache_create has dtor argument])
389 LB_LINUX_TRY_COMPILE([
390         #include <linux/slab.h>
391 ],[
392         kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);
393 ],[
394         AC_MSG_RESULT(yes)
395         AC_DEFINE(HAVE_KMEM_CACHE_CREATE_DTOR, 1,
396                   [kmem_cache_create has dtor argument])
397 ],[
398         AC_MSG_RESULT(NO)
399 ])
400 ])
401
402 # 2.6.24 
403 AC_DEFUN([LIBCFS_NETLINK_CBMUTEX],
404 [AC_MSG_CHECKING([for mutex in netlink_kernel_create])
405 LB_LINUX_TRY_COMPILE([
406         #include <linux/netlink.h>
407 ],[
408         struct mutex *lock = NULL;
409
410         netlink_kernel_create(0, 0, NULL, lock, NULL);
411 ],[
412         AC_MSG_RESULT(yes)
413         AC_DEFINE(HAVE_NETLINK_CBMUTEX, 1,
414                   [netlink_kernel_create want mutex for callback])
415 ],[
416         AC_MSG_RESULT(NO)
417 ])
418 ])
419
420 # 2.6.24 request not use real numbers for ctl_name
421 AC_DEFUN([LIBCFS_SYSCTL_UNNUMBERED],
422 [AC_MSG_CHECKING([for CTL_UNNUMBERED])
423 LB_LINUX_TRY_COMPILE([
424         #include <linux/sysctl.h>
425 ],[
426         #ifndef CTL_UNNUMBERED
427         #error CTL_UNNUMBERED not exist in kernel
428         #endif
429 ],[
430         AC_MSG_RESULT(yes)
431         AC_DEFINE(HAVE_SYSCTL_UNNUMBERED, 1,
432                   [sysctl has CTL_UNNUMBERED])
433 ],[
434         AC_MSG_RESULT(NO)
435 ])
436 ])
437
438 # 2.6.24 lost scatterlist->page
439 AC_DEFUN([LIBCFS_SCATTERLIST_SETPAGE],
440 [AC_MSG_CHECKING([for exist sg_set_page])
441 LB_LINUX_TRY_COMPILE([
442         #include <asm/types.h>
443         #include <linux/scatterlist.h>
444 ],[
445         sg_set_page(NULL,NULL,0,0);
446 ],[
447         AC_MSG_RESULT(yes)
448         AC_DEFINE(HAVE_SCATTERLIST_SETPAGE, 1,
449                   [struct scatterlist has page member])
450 ],[
451         AC_MSG_RESULT(NO)
452 ])
453 ])
454
455 # 2.6.24 
456 AC_DEFUN([LIBCFS_NETWORK_NAMESPACE],
457 [AC_MSG_CHECKING([for network stack has namespaces])
458 LB_LINUX_TRY_COMPILE([
459         #include <net/net_namespace.h>
460 ],[
461         struct net *net = &init_net;
462 ],[
463         AC_MSG_RESULT(yes)
464         AC_DEFINE(HAVE_INIT_NET, 1,
465                   [kernel is support network namespaces ])
466 ],[
467         AC_MSG_RESULT(NO)
468 ])
469 ])
470
471
472 # 2.6.24 
473 AC_DEFUN([LIBCFS_NETLINK_NETNS],
474 [AC_MSG_CHECKING([for netlink support net ns])
475 LB_LINUX_TRY_COMPILE([
476         #include <linux/netlink.h>
477 ],[
478         struct net *net = NULL;
479         struct mutex *lock = NULL;
480
481         netlink_kernel_create(net, 0, 0, NULL,
482                               lock,
483                               NULL);
484 ],[
485         AC_MSG_RESULT(yes)
486         AC_DEFINE(HAVE_NETLINK_NS, 1,
487                   [netlink is support network namespace])
488 # XXX
489 # for now - if kernel have netlink ns - he uses cbmutex
490         AC_DEFINE(HAVE_NETLINK_CBMUTEX, 1,
491                   [netlink_kernel_create want mutex for callback])
492
493 ],[
494         AC_MSG_RESULT(NO)
495 ])
496 ])
497
498 # ~2.6.24
499 AC_DEFUN([LIBCFS_NL_BROADCAST_GFP],
500 [AC_MSG_CHECKING([for netlink_broadcast is want to have gfp parameter])
501 LB_LINUX_TRY_COMPILE([
502         #include <linux/netlink.h>
503 ],[
504         gfp_t gfp = GFP_KERNEL;
505
506         netlink_broadcast(NULL, NULL, 0, 0, gfp);
507 ],[
508         AC_MSG_RESULT(yes)
509         AC_DEFINE(HAVE_NL_BROADCAST_GFP, 1,
510                   [netlink brouacast is want to have gfp paramter])
511 ],[
512         AC_MSG_RESULT(NO)
513 ])
514 ])
515
516 #
517 # LIBCFS_FUNC_DUMP_TRACE
518 #
519 # 2.6.23 exports dump_trace() so we can dump_stack() on any task
520 # 2.6.24 has stacktrace_ops.address with "reliable" parameter
521 #
522 AC_DEFUN([LIBCFS_FUNC_DUMP_TRACE],
523 [LB_CHECK_SYMBOL_EXPORT([dump_trace],
524 [kernel/ksyms.c arch/${LINUX_ARCH%_64}/kernel/traps_64.c],[
525         tmp_flags="$EXTRA_KCFLAGS"
526         EXTRA_KCFLAGS="-Werror"
527         AC_MSG_CHECKING([whether we can really use dump_trace])
528         LB_LINUX_TRY_COMPILE([
529                 struct task_struct;
530                 struct pt_regs;
531                 #include <asm/stacktrace.h>
532         ],[
533         ],[
534                 AC_MSG_RESULT(yes)
535                 AC_DEFINE(HAVE_DUMP_TRACE, 1, [dump_trace is exported])
536         ],[
537                 AC_MSG_RESULT(no)
538         ],[
539         ])
540         AC_MSG_CHECKING([whether print_trace_address has reliable argument])
541         LB_LINUX_TRY_COMPILE([
542                 struct task_struct;
543                 struct pt_regs;
544                 void print_addr(void *data, unsigned long addr, int reliable);
545                 #include <asm/stacktrace.h>
546         ],[
547                 struct stacktrace_ops ops;
548
549                 ops.address = print_addr;
550         ],[
551                 AC_MSG_RESULT(yes)
552                 AC_DEFINE(HAVE_TRACE_ADDRESS_RELIABLE, 1,
553                           [print_trace_address has reliable argument])
554         ],[
555                 AC_MSG_RESULT(no)
556         ],[
557         ])
558 EXTRA_KCFLAGS="$tmp_flags"
559 ])
560 ])
561
562
563 # 2.6.26 use int instead of atomic for sem.count
564 AC_DEFUN([LIBCFS_SEM_COUNT],
565 [AC_MSG_CHECKING([atomic sem.count])
566 LB_LINUX_TRY_COMPILE([
567         #include <asm/semaphore.h>
568 ],[
569         struct semaphore s;
570         
571         atomic_read(&s.count);
572 ],[
573         AC_MSG_RESULT(yes)
574         AC_DEFINE(HAVE_SEM_COUNT_ATOMIC, 1,
575                   [semaphore counter is atomic])
576 ],[
577         AC_MSG_RESULT(NO)
578 ])
579 ])
580
581 # 2.6.27 have second argument to sock_map_fd
582 AC_DEFUN([LIBCFS_SOCK_MAP_FD_2ARG],
583 [AC_MSG_CHECKING([sock_map_fd have second argument])
584 LB_LINUX_TRY_COMPILE([
585         #include <linux/net.h>
586 ],[
587         sock_map_fd(NULL, 0);
588 ],[
589         AC_MSG_RESULT(yes)
590         AC_DEFINE(HAVE_SOCK_MAP_FD_2ARG, 1,
591                   [sock_map_fd have second argument])
592 ],[
593         AC_MSG_RESULT(NO)
594 ])
595 ])
596
597 # LIBCFS_CRED_WRAPPERS
598 #
599 # wrappers for task's credentials are in sles11
600 #
601 AC_DEFUN([LIBCFS_CRED_WRAPPERS],
602 [AC_MSG_CHECKING([if kernel has wrappers for task's credentials])
603 LB_LINUX_TRY_COMPILE([
604        #include <linux/sched.h>
605 ],[
606        uid_t uid;
607
608        uid = current_uid();
609 ],[
610        AC_MSG_RESULT([yes])
611        AC_DEFINE(HAVE_CRED_WRAPPERS, 1, [task's cred wrappers found])
612 ],[
613        AC_MSG_RESULT([no])
614 ])
615 ])
616
617 #
618 # LN_STRUCT_CRED_IN_TASK
619 #
620 # struct cred was introduced in 2.6.29 to streamline credentials in task struct
621 #
622 AC_DEFUN([LIBCFS_STRUCT_CRED_IN_TASK],
623 [AC_MSG_CHECKING([if kernel has struct cred])
624 LB_LINUX_TRY_COMPILE([
625        #include <linux/sched.h>
626 ],[
627        struct task_struct *tsk = NULL;
628        tsk->real_cred = NULL;
629 ],[
630        AC_MSG_RESULT([yes])
631        AC_DEFINE(HAVE_STRUCT_CRED, 1, [struct cred found])
632 ],[
633        AC_MSG_RESULT([no])
634 ])
635 ])
636
637 #
638 # LIBCFS_FUNC_UNSHARE_FS_STRUCT
639 #
640 # unshare_fs_struct was introduced in 2.6.30 to prevent others to directly
641 # mess with copy_fs_struct
642 #
643 AC_DEFUN([LIBCFS_FUNC_UNSHARE_FS_STRUCT],
644 [AC_MSG_CHECKING([if kernel defines unshare_fs_struct()])
645 tmp_flags="$EXTRA_KCFLAGS"
646 EXTRA_KCFLAGS="-Werror"
647 LB_LINUX_TRY_COMPILE([
648        #include <linux/sched.h>
649        #include <linux/fs_struct.h>
650 ],[
651        unshare_fs_struct();
652 ],[
653        AC_MSG_RESULT([yes])
654        AC_DEFINE(HAVE_UNSHARE_FS_STRUCT, 1, [unshare_fs_struct found])
655 ],[
656        AC_MSG_RESULT([no])
657 ])
658 EXTRA_KCFLAGS="$tmp_flags"
659 ])
660
661 #
662 # LIBCFS_HAVE_IS_COMPAT_TASK
663 #
664 # Added in 2.6.17, it wasn't until 2.6.29 that all
665 # Linux architectures have is_compat_task()
666 #
667 AC_DEFUN([LIBCFS_HAVE_IS_COMPAT_TASK],
668 [AC_MSG_CHECKING([if is_compat_task() is declared])
669 LB_LINUX_TRY_COMPILE([
670         #include <linux/compat.h>
671 ],[
672         int i = is_compat_task();
673 ],[
674         AC_MSG_RESULT([yes])
675         AC_DEFINE(HAVE_IS_COMPAT_TASK, 1, [is_compat_task() is available])
676 ],[
677         AC_MSG_RESULT([no])
678 ])
679 ])
680
681 #
682 # LIBCFS_PROG_LINUX
683 #
684 # LNet linux kernel checks
685 #
686 AC_DEFUN([LIBCFS_PROG_LINUX],
687 [
688 LIBCFS_FUNC_CPU_ONLINE
689 LIBCFS_TYPE_GFP_T
690 LIBCFS_TYPE_CPUMASK_T
691 LIBCFS_CONFIG_PANIC_DUMPLOG
692
693 LIBCFS_STRUCT_PAGE_LIST
694 LIBCFS_STRUCT_SIGHAND
695 LIBCFS_FUNC_SHOW_TASK
696 LIBCFS_U64_LONG_LONG
697 LIBCFS_TASK_RCU
698 # 2.6.18
699 LIBCFS_TASKLIST_LOCK
700 LIBCFS_HAVE_IS_COMPAT_TASK
701 # 2.6.19
702 LIBCFS_NETLINK
703 LIBCFS_NLMSG_MULTICAST
704 LIBCFS_KMEM_CACHE_DESTROY_INT
705 LIBCFS_ATOMIC_PANIC_NOTIFIER
706 # 2.6.20
707 LIBCFS_3ARGS_INIT_WORK
708 # 2.6.21
709 LIBCFS_2ARGS_REGISTER_SYSCTL
710 LIBCFS_KMEM_CACHE
711 # 2.6.23
712 LIBCFS_KMEM_CACHE_CREATE_DTOR
713 LIBCFS_NETLINK_CBMUTEX
714 # 2.6.24
715 LIBCFS_SYSCTL_UNNUMBERED
716 LIBCFS_SCATTERLIST_SETPAGE
717 LIBCFS_NL_BROADCAST_GFP
718 LIBCFS_NETWORK_NAMESPACE
719 LIBCFS_NETLINK_NETNS
720 LIBCFS_FUNC_DUMP_TRACE
721 # 2.6.26
722 LIBCFS_SEM_COUNT
723 # 2.6.27
724 LIBCFS_CRED_WRAPPERS
725 # 2.6.29
726 LIBCFS_STRUCT_CRED_IN_TASK
727 # 2.6.30
728 LIBCFS_FUNC_UNSHARE_FS_STRUCT
729 LIBCFS_SOCK_MAP_FD_2ARG
730 ])
731
732 #
733 # LIBCFS_PROG_DARWIN
734 #
735 # Darwin checks
736 #
737 AC_DEFUN([LIBCFS_PROG_DARWIN],
738 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
739 ])
740
741 #
742 # LIBCFS_PATH_DEFAULTS
743 #
744 # default paths for installed files
745 #
746 AC_DEFUN([LIBCFS_PATH_DEFAULTS],
747 [
748 ])
749
750 #
751 # LIBCFS_CONFIGURE
752 #
753 # other configure checks
754 #
755 AC_DEFUN([LIBCFS_CONFIGURE],
756 [# lnet/utils/portals.c
757 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
758
759 # lnet/utils/debug.c
760 AC_CHECK_HEADERS([linux/version.h])
761
762 AC_CHECK_TYPE([spinlock_t],
763         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
764         [],
765         [#include <linux/spinlock.h>])
766
767 # lnet/utils/wirecheck.c
768 AC_CHECK_FUNCS([strnlen])
769
770 AC_CHECK_TYPE([umode_t],
771         [AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
772         [],
773         [#include <asm/types.h>])
774
775 AC_CHECK_TYPE([__s8],
776         [AC_DEFINE(HAVE___S8, 1, [__s8 is defined])],
777         [],
778         [#include <asm/types.h>])
779
780 AC_CHECK_TYPE([__u8],
781         [AC_DEFINE(HAVE___U8, 1, [__u8 is defined])],
782         [],
783         [#include <asm/types.h>])
784
785 AC_CHECK_TYPE([__s16],
786         [AC_DEFINE(HAVE___S16, 1, [__s16 is defined])],
787         [],
788         [#include <asm/types.h>])
789
790 AC_CHECK_TYPE([__u16],
791         [AC_DEFINE(HAVE___U16, 1, [__u16 is defined])],
792         [],
793         [#include <asm/types.h>])
794
795 AC_CHECK_TYPE([__s32],
796         [AC_DEFINE(HAVE___S32, 1, [__s32 is defined])],
797         [],
798         [#include <asm/types.h>])
799
800 AC_CHECK_TYPE([__u32],
801         [AC_DEFINE(HAVE___U32, 1, [__u32 is defined])],
802         [],
803         [#include <asm/types.h>])
804
805 AC_CHECK_TYPE([__u64],
806         [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
807         [],
808         [#include <asm/types.h>])
809
810 AC_CHECK_TYPE([__s64],
811         [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
812         [],
813         [#include <asm/types.h>])
814
815 # --------  Check for required packages  --------------
816
817
818 AC_MSG_CHECKING([if efence debugging support is requested])
819 AC_ARG_ENABLE(efence,
820         AC_HELP_STRING([--enable-efence],
821                         [use efence library]),
822         [],[enable_efence='no'])
823 AC_MSG_RESULT([$enable_efence])
824 if test "$enable_efence" = "yes" ; then
825         LIBEFENCE="-lefence"
826         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
827 else
828         LIBEFENCE=""
829 fi
830 AC_SUBST(LIBEFENCE)
831
832
833 # -------- check for -lpthread support ----
834 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
835 AC_ARG_ENABLE([libpthread],
836         AC_HELP_STRING([--disable-libpthread],
837                 [disable libpthread]),
838         [],[enable_libpthread=yes])
839 if test "$enable_libpthread" = "yes" ; then
840         AC_CHECK_LIB([pthread], [pthread_create],
841                 [ENABLE_LIBPTHREAD="yes"],
842                 [ENABLE_LIBPTHREAD="no"])
843         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
844                 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
845                 PTHREAD_LIBS="-lpthread"
846                 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
847         else
848                 PTHREAD_LIBS=""
849                 AC_MSG_RESULT([no libpthread is found])
850         fi
851         AC_SUBST(PTHREAD_LIBS)
852 else
853         AC_MSG_RESULT([no (disabled explicitly)])
854         ENABLE_LIBPTHREAD="no"
855 fi
856 AC_SUBST(ENABLE_LIBPTHREAD)
857
858
859 ])
860
861 #
862 # LIBCFS_CONDITIONALS
863 #
864 # AM_CONDITOINAL defines for lnet
865 #
866 AC_DEFUN([LIBCFS_CONDITIONALS],
867 [
868 ])
869
870 #
871 # LIBCFS_CONFIG_FILES
872 #
873 # files that should be generated with AC_OUTPUT
874 #
875 AC_DEFUN([LIBCFS_CONFIG_FILES],
876 [AC_CONFIG_FILES([
877 libcfs/Kernelenv
878 libcfs/Makefile
879 libcfs/autoMakefile
880 libcfs/autoconf/Makefile
881 libcfs/include/Makefile
882 libcfs/include/libcfs/Makefile
883 libcfs/include/libcfs/linux/Makefile
884 libcfs/include/libcfs/posix/Makefile
885 libcfs/include/libcfs/util/Makefile
886 libcfs/libcfs/Makefile
887 libcfs/libcfs/autoMakefile
888 libcfs/libcfs/linux/Makefile
889 libcfs/libcfs/posix/Makefile
890 libcfs/libcfs/util/Makefile
891 libcfs/include/libcfs/darwin/Makefile
892 libcfs/libcfs/darwin/Makefile
893 ])
894 ])