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