Whamcloud - gitweb
acl includes and time_t formats cleanup.
[fs/lustre-release.git] / lustre / autoconf / lustre-core.m4
1 #* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 #* vim:expandtab:shiftwidth=8:tabstop=8:
3 #
4 # LC_CONFIG_SRCDIR
5 #
6 # Wrapper for AC_CONFIG_SUBDIR
7 #
8 AC_DEFUN([LC_CONFIG_SRCDIR],
9 [AC_CONFIG_SRCDIR([lustre/obdclass/obdo.c])
10 libcfs_is_module=yes
11 ])
12
13 #
14 # LC_PATH_DEFAULTS
15 #
16 # lustre specific paths
17 #
18 AC_DEFUN([LC_PATH_DEFAULTS],
19 [# ptlrpc kernel build requires this
20 LUSTRE="$PWD/lustre"
21 AC_SUBST(LUSTRE)
22
23 # mount.lustre
24 rootsbindir='/sbin'
25 AC_SUBST(rootsbindir)
26
27 demodir='$(docdir)/demo'
28 AC_SUBST(demodir)
29
30 pkgexampledir='${pkgdatadir}/examples'
31 AC_SUBST(pkgexampledir)
32 ])
33
34 #
35 # LC_TARGET_SUPPORTED
36 #
37 # is the target os supported?
38 #
39 AC_DEFUN([LC_TARGET_SUPPORTED],
40 [case $target_os in
41         linux* | darwin*)
42 $1
43                 ;;
44         *)
45 $2
46                 ;;
47 esac
48 ])
49
50 #
51 # LC_CONFIG_EXT3
52 #
53 # that ext3 is enabled in the kernel
54 #
55 AC_DEFUN([LC_CONFIG_EXT3],
56 [LB_LINUX_CONFIG([EXT3_FS],[],[
57         LB_LINUX_CONFIG([EXT3_FS_MODULE],[],[$2])
58 ])
59 LB_LINUX_CONFIG([EXT3_FS_XATTR],[$1],[$3])
60 ])
61
62 #
63 # LC_FSHOOKS
64 #
65 # If we have (and can build) fshooks.h
66 #
67 AC_DEFUN([LC_FSHOOKS],
68 [LB_CHECK_FILE([$LINUX/include/linux/fshooks.h],[
69         AC_MSG_CHECKING([if fshooks.h can be compiled])
70         LB_LINUX_TRY_COMPILE([
71                 #include <linux/fshooks.h>
72         ],[],[
73                 AC_MSG_RESULT([yes])
74         ],[
75                 AC_MSG_RESULT([no])
76                 AC_MSG_WARN([You might have better luck with gcc 3.3.x.])
77                 AC_MSG_WARN([You can set CC=gcc33 before running configure.])
78                 AC_MSG_ERROR([Your compiler cannot build fshooks.h.])
79         ])
80 $1
81 ],[
82 $2
83 ])
84 ])
85
86 #
87 # LC_STRUCT_KIOBUF
88 #
89 # rh 2.4.18 has iobuf->dovary, but other kernels do not
90 #
91 AC_DEFUN([LC_STRUCT_KIOBUF],
92 [AC_MSG_CHECKING([if struct kiobuf has a dovary field])
93 LB_LINUX_TRY_COMPILE([
94         #include <linux/iobuf.h>
95 ],[
96         struct kiobuf iobuf;
97         iobuf.dovary = 1;
98 ],[
99         AC_MSG_RESULT([yes])
100         AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
101 ],[
102         AC_MSG_RESULT([no])
103 ])
104 ])
105
106 #
107 # LC_FUNC_COND_RESCHED
108 #
109 # cond_resched() was introduced in 2.4.20
110 #
111 AC_DEFUN([LC_FUNC_COND_RESCHED],
112 [AC_MSG_CHECKING([if kernel offers cond_resched])
113 LB_LINUX_TRY_COMPILE([
114         #include <linux/sched.h>
115 ],[
116         cond_resched();
117 ],[
118         AC_MSG_RESULT([yes])
119         AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found])
120 ],[
121         AC_MSG_RESULT([no])
122 ])
123 ])
124
125 #
126 # LC_FUNC_ZAP_PAGE_RANGE
127 #
128 # if zap_page_range() takes a vma arg
129 #
130 AC_DEFUN([LC_FUNC_ZAP_PAGE_RANGE],
131 [AC_MSG_CHECKING([if zap_page_range with vma parameter])
132 ZAP_PAGE_RANGE_VMA="`grep -c 'zap_page_range.*struct vm_area_struct' $LINUX/include/linux/mm.h`"
133 if test "$ZAP_PAGE_RANGE_VMA" != 0 ; then
134         AC_DEFINE(ZAP_PAGE_RANGE_VMA, 1, [zap_page_range with vma parameter])
135         AC_MSG_RESULT([yes])
136 else
137         AC_MSG_RESULT([no])
138 fi
139 ])
140
141 #
142 # LC_FUNC_PDE
143 #
144 # if proc_fs.h defines PDE()
145 #
146 AC_DEFUN([LC_FUNC_PDE],
147 [AC_MSG_CHECKING([if kernel defines PDE])
148 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
149 if test "$HAVE_PDE" != 0 ; then
150         AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
151         AC_MSG_RESULT([yes])
152 else
153         AC_MSG_RESULT([no])
154 fi
155 ])
156
157 #
158 # LC_FUNC_FILEMAP_FDATASYNC
159 #
160 # if filemap_fdatasync() exists
161 #
162 AC_DEFUN([LC_FUNC_FILEMAP_FDATAWRITE],
163 [AC_MSG_CHECKING([whether filemap_fdatawrite() is defined])
164 LB_LINUX_TRY_COMPILE([
165         #include <linux/fs.h>
166 ],[
167         int (*foo)(struct address_space *)= filemap_fdatawrite;
168 ],[
169         AC_MSG_RESULT([yes])
170         AC_DEFINE(HAVE_FILEMAP_FDATAWRITE, 1, [filemap_fdatawrite() found])
171 ],[
172         AC_MSG_RESULT([no])
173 ])
174 ])
175
176 #
177 # LC_FUNC_DIRECT_IO
178 #
179 # if direct_IO takes a struct file argument
180 #
181 AC_DEFUN([LC_FUNC_DIRECT_IO],
182 [AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
183 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
184 if test "$HAVE_DIO_FILE" != 0 ; then
185         AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
186         AC_MSG_RESULT(yes)
187 else
188         AC_MSG_RESULT(no)
189 fi
190 ])
191
192 #
193 # LC_HEADER_MM_INLINE
194 #
195 # RHEL kernels define page_count in mm_inline.h
196 #
197 AC_DEFUN([LC_HEADER_MM_INLINE],
198 [AC_MSG_CHECKING([if kernel has mm_inline.h header])
199 LB_LINUX_TRY_COMPILE([
200         #include <linux/mm_inline.h>
201 ],[
202         #ifndef page_count
203         #error mm_inline.h does not define page_count
204         #endif
205 ],[
206         AC_MSG_RESULT([yes])
207         AC_DEFINE(HAVE_MM_INLINE, 1, [mm_inline found])
208 ],[
209         AC_MSG_RESULT([no])
210 ])
211 ])
212
213 #
214 # LC_STRUCT_INODE
215 #
216 # if inode->i_alloc_sem exists
217 #
218 AC_DEFUN([LC_STRUCT_INODE],
219 [AC_MSG_CHECKING([if struct inode has i_alloc_sem])
220 LB_LINUX_TRY_COMPILE([
221         #include <linux/fs.h>
222         #include <linux/version.h>
223 ],[
224         #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24))
225         #error "down_read_trylock broken before 2.4.24"
226         #endif
227         struct inode i;
228         return (char *)&i.i_alloc_sem - (char *)&i;
229 ],[
230         AC_MSG_RESULT([yes])
231         AC_DEFINE(HAVE_I_ALLOC_SEM, 1, [struct inode has i_alloc_sem])
232 ],[
233         AC_MSG_RESULT([no])
234 ])
235 ])
236
237 #
238 # LC_FUNC_REGISTER_CACHE
239 #
240 # if register_cache() is defined by kernel
241
242 # There are two ways to shrink one customized cache in linux kernels. For the
243 # kernels are prior than 2.6.5(?), register_cache() is used, and for latest 
244 # kernels, set_shrinker() is used instead.
245 #
246 AC_DEFUN([LC_FUNC_REGISTER_CACHE],
247 [AC_MSG_CHECKING([if kernel defines cache pressure hook])
248 LB_LINUX_TRY_COMPILE([
249         #include <linux/mm.h>
250 ],[
251         shrinker_t shrinker;
252
253         set_shrinker(1, shrinker);
254 ],[
255         AC_MSG_RESULT([set_shrinker])
256         AC_DEFINE(HAVE_SHRINKER_CACHE, 1, [shrinker_cache found])
257         AC_DEFINE(HAVE_CACHE_RETURN_INT, 1, [shrinkers should return int])
258 ],[
259         LB_LINUX_TRY_COMPILE([
260                 #include <linux/list.h>
261                 #include <linux/cache_def.h>
262         ],[
263                 struct cache_definition cache;
264         ],[
265                 AC_MSG_RESULT([register_cache])
266                 AC_DEFINE(HAVE_REGISTER_CACHE, 1, [register_cache found])
267                 AC_MSG_CHECKING([if kernel expects return from cache shrink ])
268                 tmp_flags="$EXTRA_KCFLAGS"
269                 EXTRA_KCFLAGS="-Werror"
270                 LB_LINUX_TRY_COMPILE([
271                         #include <linux/list.h>
272                         #include <linux/cache_def.h>
273                 ],[
274                         struct cache_definition c;
275                         c.shrinker = (int (*)(int, unsigned int))1;
276                 ],[
277                         AC_DEFINE(HAVE_CACHE_RETURN_INT, 1,
278                                   [kernel expects return from shrink_cache])
279                         AC_MSG_RESULT(yes)
280                 ],[
281                         AC_MSG_RESULT(no)
282                 ])
283                 EXTRA_KCFLAGS="$tmp_flags"
284         ],[
285                 AC_MSG_RESULT([no])
286         ])
287 ])
288 ])
289
290 #
291 # LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
292 #
293 # check for our patched grab_cache_page_nowait_gfp() function
294 #
295 AC_DEFUN([LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP],
296 [AC_MSG_CHECKING([if kernel defines grab_cache_page_nowait_gfp()])
297 HAVE_GCPN_GFP="`grep -c 'grab_cache_page_nowait_gfp' $LINUX/include/linux/pagemap.h`"
298 if test "$HAVE_GCPN_GFP" != 0 ; then
299         AC_DEFINE(HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP, 1,
300                 [kernel has grab_cache_page_nowait_gfp()])
301         AC_MSG_RESULT(yes)
302 else
303         AC_MSG_RESULT(no)
304 fi
305 ])
306
307 #
308 # LC_FUNC_DEV_SET_RDONLY
309 #
310 # check for the old-style dev_set_rdonly which took an extra "devno" param
311 # and can only set a single device to discard writes at one time
312 #
313 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY],
314 [AC_MSG_CHECKING([if kernel has new dev_set_rdonly])
315 LB_LINUX_TRY_COMPILE([
316         #include <linux/fs.h>
317 ],[
318         #ifndef HAVE_CLEAR_RDONLY_ON_PUT
319         #error needs to be patched by lustre kernel patches from Lustre version 1.4.3 or above.
320         #endif
321 ],[
322         AC_MSG_RESULT([yes])
323         AC_DEFINE(HAVE_DEV_SET_RDONLY, 1, [kernel has new dev_set_rdonly])
324 ],[
325         AC_MSG_RESULT([no, Linux kernel source needs to be patches by lustre 
326 kernel patches from Lustre version 1.4.3 or above.])
327 ])
328 ])
329
330 #
331 # LC_CONFIG_BACKINGFS
332 #
333 # setup, check the backing filesystem
334 #
335 AC_DEFUN([LC_CONFIG_BACKINGFS],
336 [
337 BACKINGFS="ldiskfs"
338
339 if test x$with_ldiskfs = xno ; then
340         BACKINGFS="ext3"
341
342         if test x$linux25$enable_server = xyesyes ; then
343                 AC_MSG_ERROR([ldiskfs is required for 2.6-based servers.])
344         fi
345
346         # --- Check that ext3 and ext3 xattr are enabled in the kernel
347         LC_CONFIG_EXT3([],[
348                 AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel])
349         ],[
350                 AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel])
351                 AC_MSG_WARN([This build may fail.])
352         ])
353 else
354         # ldiskfs is enabled
355         LB_DEFINE_LDISKFS_OPTIONS
356 fi #ldiskfs
357
358 AC_MSG_CHECKING([which backing filesystem to use])
359 AC_MSG_RESULT([$BACKINGFS])
360 AC_SUBST(BACKINGFS)
361 ])
362
363 #
364 # LC_CONFIG_PINGER
365 #
366 # the pinger is temporary, until we have the recovery node in place
367 #
368 AC_DEFUN([LC_CONFIG_PINGER],
369 [AC_MSG_CHECKING([whether to enable pinger support])
370 AC_ARG_ENABLE([pinger],
371         AC_HELP_STRING([--disable-pinger],
372                         [disable recovery pinger support]),
373         [],[enable_pinger='yes'])
374 AC_MSG_RESULT([$enable_pinger])
375 if test x$enable_pinger != xno ; then
376   AC_DEFINE(ENABLE_PINGER, 1, Use the Pinger)
377 fi
378 ])
379
380 #
381 # LC_CONFIG_CHECKSUM
382 #
383 # do checksum of bulk data between client and OST
384 #
385 AC_DEFUN([LC_CONFIG_CHECKSUM],
386 [AC_MSG_CHECKING([whether to enable data checksum support])
387 AC_ARG_ENABLE([checksum],
388        AC_HELP_STRING([--disable-checksum],
389                        [disable data checksum support]),
390        [],[enable_checksum='yes'])
391 AC_MSG_RESULT([$enable_checksum])
392 if test x$enable_checksum != xno ; then
393   AC_DEFINE(ENABLE_CHECKSUM, 1, do data checksums)
394 fi
395 ])
396
397 #
398 # LC_CONFIG_HEALTH_CHECK_WRITE
399 #
400 # Turn off the actual write to the disk
401 #
402 AC_DEFUN([LC_CONFIG_HEALTH_CHECK_WRITE],
403 [AC_MSG_CHECKING([whether to enable a write with the health check])
404 AC_ARG_ENABLE([health_write],
405         AC_HELP_STRING([--enable-health_write],
406                         [enable disk writes when doing health check]),
407         [],[enable_health_write='no'])
408 AC_MSG_RESULT([$enable_health_write])
409 if test x$enable_health_write != xno ; then
410   AC_DEFINE(USE_HEALTH_CHECK_WRITE, 1, Write when Checking Health)
411 fi
412 ])
413
414 #
415 # LC_CONFIG_LIBLUSTRE_RECOVERY
416 #
417 AC_DEFUN([LC_CONFIG_LIBLUSTRE_RECOVERY],
418 [AC_MSG_CHECKING([whether to enable liblustre recovery support])
419 AC_ARG_ENABLE([liblustre-recovery],
420         AC_HELP_STRING([--disable-liblustre-recovery],
421                         [disable liblustre recovery support]),
422         [],[enable_liblustre_recovery='yes'])
423 AC_MSG_RESULT([$enable_liblustre_recovery])
424 if test x$enable_liblustre_recovery != xno ; then
425   AC_DEFINE(ENABLE_LIBLUSTRE_RECOVERY, 1, Liblustre Can Recover)
426 fi
427 ])
428
429 #
430 # LC_CONFIG_OBD_BUFFER_SIZE
431 #
432 # the maximum buffer size of lctl ioctls
433 #
434 AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],
435 [AC_MSG_CHECKING([maximum OBD ioctl size])
436 AC_ARG_WITH([obd-buffer-size],
437         AC_HELP_STRING([--with-obd-buffer-size=[size]],
438                         [set lctl ioctl maximum bytes (default=8192)]),
439         [
440                 OBD_BUFFER_SIZE=$with_obd_buffer_size
441         ],[
442                 OBD_BUFFER_SIZE=8192
443         ])
444 AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
445 AC_DEFINE_UNQUOTED(OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
446 ])
447
448 #
449 # LC_STRUCT_STATFS
450 #
451 # AIX does not have statfs.f_namelen
452 #
453 AC_DEFUN([LC_STRUCT_STATFS],
454 [AC_MSG_CHECKING([if struct statfs has a f_namelen field])
455 LB_LINUX_TRY_COMPILE([
456         #include <linux/vfs.h>
457 ],[
458         struct statfs sfs;
459         sfs.f_namelen = 1;
460 ],[
461         AC_MSG_RESULT([yes])
462         AC_DEFINE(HAVE_STATFS_NAMELEN, 1, [struct statfs has a namelen field])
463 ],[
464         AC_MSG_RESULT([no])
465 ])
466 ])
467
468 #
469 # LC_READLINK_SSIZE_T
470 #
471 AC_DEFUN([LC_READLINK_SSIZE_T],
472 [AC_MSG_CHECKING([if readlink returns ssize_t])
473 AC_TRY_COMPILE([
474         #include <unistd.h>
475 ],[
476         ssize_t readlink(const char *, char *, size_t);
477 ],[
478         AC_MSG_RESULT([yes])
479         AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
480 ],[
481         AC_MSG_RESULT([no])
482 ])
483 ])
484
485 AC_DEFUN([LC_FUNC_PAGE_MAPPED],
486 [AC_MSG_CHECKING([if kernel offers page_mapped])
487 LB_LINUX_TRY_COMPILE([
488         #include <linux/mm.h>
489 ],[
490         page_mapped(NULL);
491 ],[
492         AC_MSG_RESULT([yes])
493         AC_DEFINE(HAVE_PAGE_MAPPED, 1, [page_mapped found])
494 ],[
495         AC_MSG_RESULT([no])
496 ])
497 ])
498
499 AC_DEFUN([LC_STRUCT_FILE_OPS_UNLOCKED_IOCTL],
500 [AC_MSG_CHECKING([if struct file_operations has an unlocked_ioctl field])
501 LB_LINUX_TRY_COMPILE([
502         #include <linux/fs.h>
503 ],[
504         struct file_operations fops;
505         &fops.unlocked_ioctl;
506 ],[
507         AC_MSG_RESULT([yes])
508         AC_DEFINE(HAVE_UNLOCKED_IOCTL, 1, [struct file_operations has an unlock ed_ioctl field])
509 ],[
510         AC_MSG_RESULT([no])
511 ])
512 ])
513
514 AC_DEFUN([LC_FILEMAP_POPULATE],
515 [AC_MSG_CHECKING([for exported filemap_populate])
516 LB_LINUX_TRY_COMPILE([
517         #include <asm/page.h>
518         #include <linux/mm.h>
519 ],[
520        filemap_populate(NULL, 0, 0, __pgprot(0), 0, 0);
521 ],[
522         AC_MSG_RESULT([yes])
523         AC_DEFINE(HAVE_FILEMAP_POPULATE, 1, [Kernel exports filemap_populate])
524 ],[
525         AC_MSG_RESULT([no])
526 ])
527 ])
528
529 AC_DEFUN([LC_D_ADD_UNIQUE],
530 [AC_MSG_CHECKING([for d_add_unique])
531 LB_LINUX_TRY_COMPILE([
532         #include <linux/dcache.h>
533 ],[
534        d_add_unique(NULL, NULL);
535 ],[
536         AC_MSG_RESULT([yes])
537         AC_DEFINE(HAVE_D_ADD_UNIQUE, 1, [Kernel has d_add_unique])
538 ],[
539         AC_MSG_RESULT([no])
540 ])
541 ])
542
543 AC_DEFUN([LC_BIT_SPINLOCK_H],
544 [LB_CHECK_FILE([$LINUX/include/linux/bit_spinlock.h],[
545         AC_MSG_CHECKING([if bit_spinlock.h can be compiled])
546         LB_LINUX_TRY_COMPILE([
547                 #include <asm/processor.h>
548                 #include <linux/spinlock.h>
549                 #include <linux/bit_spinlock.h>
550         ],[],[
551                 AC_MSG_RESULT([yes])
552                 AC_DEFINE(HAVE_BIT_SPINLOCK_H, 1, [Kernel has bit_spinlock.h])
553         ],[
554                 AC_MSG_RESULT([no])
555         ])
556 ],
557 [])
558 ])
559
560 #
561 # LC_POSIX_ACL_XATTR
562 #
563 # If we have xattr_acl.h 
564 #
565 AC_DEFUN([LC_XATTR_ACL],
566 [LB_CHECK_FILE([$LINUX/include/linux/xattr_acl.h],[
567         AC_MSG_CHECKING([if xattr_acl.h can be compiled])
568         LB_LINUX_TRY_COMPILE([
569                 #include <linux/xattr_acl.h>
570         ],[],[
571                 AC_MSG_RESULT([yes])
572                 AC_DEFINE(HAVE_XATTR_ACL, 1, [Kernel has xattr_acl])
573         ],[
574                 AC_MSG_RESULT([no])
575         ])
576 ],
577 [])
578 ])
579
580 AC_DEFUN([LC_STRUCT_INTENT_FILE],
581 [AC_MSG_CHECKING([if struct open_intent has a file field])
582 LB_LINUX_TRY_COMPILE([
583         #include <linux/fs.h>
584         #include <linux/namei.h>
585 ],[
586         struct open_intent intent;
587         &intent.file;
588 ],[
589         AC_MSG_RESULT([yes])
590         AC_DEFINE(HAVE_FILE_IN_STRUCT_INTENT, 1, [struct open_intent has a file field])
591 ],[
592         AC_MSG_RESULT([no])
593 ])
594 ])
595
596
597 AC_DEFUN([LC_POSIX_ACL_XATTR_H],
598 [LB_CHECK_FILE([$LINUX/include/linux/posix_acl_xattr.h],[
599         AC_MSG_CHECKING([if linux/posix_acl_xattr.h can be compiled])
600         LB_LINUX_TRY_COMPILE([
601                 #include <linux/posix_acl_xattr.h>
602         ],[],[
603                 AC_MSG_RESULT([yes])
604                 AC_DEFINE(HAVE_LINUX_POSIX_ACL_XATTR_H, 1, [linux/posix_acl_xattr.h found])
605
606         ],[
607                 AC_MSG_RESULT([no])
608         ])
609 $1
610 ],[
611 AC_MSG_RESULT([no])
612 ])
613 ])
614
615 #
616 # LC_EXPORT___IGET
617 # starting from 2.6.19 linux kernel exports __iget()
618 #
619 AC_DEFUN([LC_EXPORT___IGET],
620 [LB_CHECK_SYMBOL_EXPORT([__iget],
621 [fs/inode.c],[
622         AC_DEFINE(HAVE_EXPORT___IGET, 1, [kernel exports __iget])
623 ],[
624 ])
625 ])
626
627 AC_DEFUN([LC_LUSTRE_VERSION_H],
628 [LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
629         rm -f "$LUSTRE/include/linux/lustre_version.h"
630 ],[
631         touch "$LUSTRE/include/linux/lustre_version.h"
632         if test x$enable_server = xyes ; then
633                 AC_MSG_WARN([Unpatched kernel detected.])
634                 AC_MSG_WARN([Lustre servers cannot be built with an unpatched kernel;])
635                 AC_MSG_WARN([disabling server build])
636                 enable_server='no'
637         fi
638 ])
639 ])
640
641 AC_DEFUN([LC_FUNC_SET_FS_PWD],
642 [LB_CHECK_SYMBOL_EXPORT([set_fs_pwd],
643 [fs/namespace.c],[
644         AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd is exported])
645 ],[
646 ])
647 ])
648
649 #
650 # LC_CAPA_CRYPTO
651 #
652 AC_DEFUN([LC_CAPA_CRYPTO],
653 [LB_LINUX_CONFIG_IM([CRYPTO],[],[
654         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO is enabled in your kernel.])
655 ])
656 LB_LINUX_CONFIG_IM([CRYPTO_HMAC],[],[
657         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_HMAC is enabled in your kernel.])
658 ])
659 LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],[
660         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_SHA1 is enabled in your kernel.])
661 ])
662 ])
663
664 AC_DEFUN([LC_SUNRPC_CACHE],
665 [AC_MSG_CHECKING([if sunrpc struct cache_head uses kref])
666 LB_LINUX_TRY_COMPILE([
667         #include <linux/sunrpc/cache.h>
668 ],[
669         struct cache_head ch;
670         &ch.ref.refcount;
671 ],[
672         AC_MSG_RESULT([yes])
673         AC_DEFINE(HAVE_SUNRPC_CACHE_V2, 1, [sunrpc cache facility v2])
674 ],[
675         AC_MSG_RESULT([no])
676 ])
677 ])
678
679 AC_DEFUN([LC_CONFIG_SUNRPC],
680 [LB_LINUX_CONFIG_IM([SUNRPC],[],
681                     [AC_MSG_ERROR([kernel SUNRPC support is required by using GSS.])])
682  LC_SUNRPC_CACHE
683 ])
684
685 #
686 # LC_CONFIG_GSS_KEYRING (default enabled, if gss is enabled)
687 #
688 AC_DEFUN([LC_CONFIG_GSS_KEYRING],
689 [AC_MSG_CHECKING([whether to enable gss keyring backend])
690  AC_ARG_ENABLE([gss_keyring], 
691                [AC_HELP_STRING([--disable-gss-keyring],
692                                [disable gss keyring backend])],
693                [],[enable_gss_keyring='yes'])
694  AC_MSG_RESULT([$enable_gss_keyring])
695
696  if test x$enable_gss_keyring != xno; then
697         LB_LINUX_CONFIG_IM([KEYS],[],
698                            [AC_MSG_ERROR([GSS keyring backend require that CONFIG_KEYS be enabled in your kernel.])])
699
700         AC_CHECK_LIB([keyutils], [keyctl_search], [],
701                      [AC_MSG_ERROR([libkeyutils is not found, which is required by gss keyring backend])],)
702
703         AC_DEFINE([HAVE_GSS_KEYRING], [1],
704                   [Define this if you enable gss keyring backend])
705  fi
706 ])
707
708 m4_pattern_allow(AC_KERBEROS_V5)
709
710 #
711 # LC_CONFIG_GSS (default disabled)
712 #
713 # Build gss and related tools of Lustre. Currently both kernel and user space
714 # parts are depend on linux platform.
715 #
716 AC_DEFUN([LC_CONFIG_GSS],
717 [AC_MSG_CHECKING([whether to enable gss/krb5 support])
718  AC_ARG_ENABLE([gss], 
719                [AC_HELP_STRING([--enable-gss], [enable gss/krb5 support])],
720                [],[enable_gss='no'])
721  AC_MSG_RESULT([$enable_gss])
722
723  if test x$enable_gss == xyes; then
724         LC_CONFIG_GSS_KEYRING
725         LC_CONFIG_SUNRPC
726
727         LB_LINUX_CONFIG_IM([CRYPTO_MD5],[],
728                            [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
729         LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],
730                            [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
731         LB_LINUX_CONFIG_IM([CRYPTO_SHA256],[],
732                            [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
733         LB_LINUX_CONFIG_IM([CRYPTO_SHA512],[],
734                            [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
735         LB_LINUX_CONFIG_IM([CRYPTO_WP512],[],
736                            [AC_MSG_WARN([kernel WP512 support is recommended by using GSS.])])
737         LB_LINUX_CONFIG_IM([CRYPTO_ARC4],[],
738                            [AC_MSG_WARN([kernel ARC4 support is recommended by using GSS.])])
739         LB_LINUX_CONFIG_IM([CRYPTO_DES],[],
740                            [AC_MSG_WARN([kernel DES support is recommended by using GSS.])])
741         LB_LINUX_CONFIG_IM([CRYPTO_TWOFISH],[],
742                            [AC_MSG_WARN([kernel TWOFISH support is recommended by using GSS.])])
743         LB_LINUX_CONFIG_IM([CRYPTO_CAST6],[],
744                            [AC_MSG_WARN([kernel CAST6 support is recommended by using GSS.])])
745         dnl FIXME
746         dnl the AES symbol usually tied with arch, e.g. CRYPTO_AES_586
747         dnl FIXME
748         LB_LINUX_CONFIG_IM([CRYPTO_AES],[],
749                            [AC_MSG_WARN([kernel AES support is recommended by using GSS.])])
750
751         AC_CHECK_LIB([gssapi], [gss_init_sec_context],
752                      [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi"],
753                      [AC_CHECK_LIB([gssglue], [gss_init_sec_context],
754                                    [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssglue"],
755                                    [AC_MSG_ERROR([libgssapi or libgssglue is not found, which is required by GSS.])])],)
756
757         AC_SUBST(GSSAPI_LIBS)
758
759         AC_KERBEROS_V5
760  fi
761 ])
762
763 # LC_FUNC_MS_FLOCK_LOCK
764 #
765 # SLES9 kernel has MS_FLOCK_LOCK sb flag
766 #
767 AC_DEFUN([LC_FUNC_MS_FLOCK_LOCK],
768 [AC_MSG_CHECKING([if kernel has MS_FLOCK_LOCK sb flag])
769 LB_LINUX_TRY_COMPILE([
770         #include <linux/fs.h>
771 ],[
772         int flags = MS_FLOCK_LOCK;
773 ],[
774         AC_DEFINE(HAVE_MS_FLOCK_LOCK, 1,
775                 [kernel has MS_FLOCK_LOCK flag])
776         AC_MSG_RESULT([yes])
777 ],[
778         AC_MSG_RESULT([no])
779 ])
780 ])
781
782 #
783 # LC_FUNC_HAVE_CAN_SLEEP_ARG
784 #
785 # SLES9 kernel has third arg can_sleep
786 # in fs/locks.c: flock_lock_file_wait()
787 #
788 AC_DEFUN([LC_FUNC_HAVE_CAN_SLEEP_ARG],
789 [AC_MSG_CHECKING([if kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
790 LB_LINUX_TRY_COMPILE([
791         #include <linux/fs.h>
792 ],[
793         int cansleep;
794         struct file *file;
795         struct file_lock *file_lock;
796         flock_lock_file_wait(file, file_lock, cansleep);
797 ],[
798         AC_DEFINE(HAVE_CAN_SLEEP_ARG, 1,
799                 [kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
800         AC_MSG_RESULT([yes])
801 ],[
802         AC_MSG_RESULT([no])
803 ])
804 ])
805
806 #
807 # LC_FUNC_F_OP_FLOCK
808 #
809 # rhel4.2 kernel has f_op->flock field
810 #
811 AC_DEFUN([LC_FUNC_F_OP_FLOCK],
812 [AC_MSG_CHECKING([if struct file_operations has flock field])
813 LB_LINUX_TRY_COMPILE([
814         #include <linux/fs.h>
815 ],[
816         struct file_operations ll_file_operations_flock;
817         ll_file_operations_flock.flock = NULL;
818 ],[
819         AC_DEFINE(HAVE_F_OP_FLOCK, 1,
820                 [struct file_operations has flock field])
821         AC_MSG_RESULT([yes])
822 ],[
823         AC_MSG_RESULT([no])
824 ])
825 ])
826
827 #
828 # LC_TASK_PPTR
829 #
830 # task struct has p_pptr instead of parent
831 #
832 AC_DEFUN([LC_TASK_PPTR],
833 [AC_MSG_CHECKING([task p_pptr found])
834 LB_LINUX_TRY_COMPILE([
835         #include <linux/sched.h>
836 ],[
837         struct task_struct *p;
838         
839         p = p->p_pptr;
840 ],[
841         AC_MSG_RESULT([yes])
842         AC_DEFINE(HAVE_TASK_PPTR, 1, [task p_pptr found])
843 ],[
844         AC_MSG_RESULT([no])
845 ])
846 ])
847
848 #
849 # LC_FUNC_F_OP_FLOCK
850 #
851 # rhel4.2 kernel has f_op->flock field
852 #
853 AC_DEFUN([LC_FUNC_F_OP_FLOCK],
854 [AC_MSG_CHECKING([if struct file_operations has flock field])
855 LB_LINUX_TRY_COMPILE([
856         #include <linux/fs.h>
857 ],[
858         struct file_operations ll_file_operations_flock;
859         ll_file_operations_flock.flock = NULL;
860 ],[
861         AC_DEFINE(HAVE_F_OP_FLOCK, 1,
862                 [struct file_operations has flock field])
863         AC_MSG_RESULT([yes])
864 ],[
865         AC_MSG_RESULT([no])
866 ])
867 ])
868
869 # LC_INODE_I_MUTEX
870 # after 2.6.15 inode have i_mutex intead of i_sem
871 AC_DEFUN([LC_INODE_I_MUTEX],
872 [AC_MSG_CHECKING([use inode have i_mutex ])
873 LB_LINUX_TRY_COMPILE([
874         #include <linux/mutex.h>
875         #include <linux/fs.h>
876         #undef i_mutex
877 ],[
878         struct inode i;
879
880         mutex_unlock(&i.i_mutex);
881 ],[
882         AC_MSG_RESULT(yes)
883         AC_DEFINE(HAVE_INODE_I_MUTEX, 1,
884                 [after 2.6.15 inode have i_mutex intead of i_sem])
885 ],[
886         AC_MSG_RESULT(NO)
887 ])
888 ])
889
890 # LC_DQUOTOFF_MUTEX
891 # after 2.6.17 dquote use mutex instead if semaphore
892 AC_DEFUN([LC_DQUOTOFF_MUTEX],
893 [AC_MSG_CHECKING([use dqonoff_mutex])
894 LB_LINUX_TRY_COMPILE([
895         #include <linux/mutex.h>
896         #include <linux/fs.h>
897         #include <linux/quota.h>
898 ],[
899         struct quota_info dq;
900
901         mutex_unlock(&dq.dqonoff_mutex);
902 ],[
903         AC_MSG_RESULT(yes)
904         AC_DEFINE(HAVE_DQUOTOFF_MUTEX, 1,
905                 [after 2.6.17 dquote use mutex instead if semaphore])
906 ],[
907         AC_MSG_RESULT(NO)
908 ])
909 ])
910  
911 #
912 # LC_STATFS_DENTRY_PARAM
913 # starting from 2.6.18 linux kernel uses dentry instead of
914 # super_block for first vfs_statfs argument
915 #
916 AC_DEFUN([LC_STATFS_DENTRY_PARAM],
917 [AC_MSG_CHECKING([first vfs_statfs parameter is dentry])
918 LB_LINUX_TRY_COMPILE([
919         #include <linux/fs.h>
920 ],[
921         int vfs_statfs(struct dentry *, struct kstatfs *);
922 ],[
923         AC_DEFINE(HAVE_STATFS_DENTRY_PARAM, 1,
924                 [first parameter of vfs_statfs is dentry])
925         AC_MSG_RESULT([yes])
926 ],[
927         AC_MSG_RESULT([no])
928 ])
929 ])
930
931 #
932 # LC_VFS_KERN_MOUNT
933 # starting from 2.6.18 kernel don't export do_kern_mount
934 # and want to use vfs_kern_mount instead.
935 #
936 AC_DEFUN([LC_VFS_KERN_MOUNT],
937 [AC_MSG_CHECKING([vfs_kern_mount exist in kernel])
938 LB_LINUX_TRY_COMPILE([
939         #include <linux/mount.h>
940 ],[
941         vfs_kern_mount(NULL, 0, NULL, NULL);
942 ],[
943         AC_DEFINE(HAVE_VFS_KERN_MOUNT, 1,
944                 [vfs_kern_mount exist in kernel])
945         AC_MSG_RESULT([yes])
946 ],[
947         AC_MSG_RESULT([no])
948 ])
949 ])
950
951
952 # LC_INVALIDATEPAGE_RETURN_INT
953 # more 2.6 api changes.  return type for the invalidatepage
954 # address_space_operation is 'void' in new kernels but 'int' in old
955 #
956 AC_DEFUN([LC_INVALIDATEPAGE_RETURN_INT],
957 [AC_MSG_CHECKING([invalidatepage has return int])
958 LB_LINUX_TRY_COMPILE([
959         #include <linux/buffer_head.h>
960 ],[
961         int rc = block_invalidatepage(NULL, 0);
962 ],[
963         AC_MSG_RESULT(yes)
964         AC_DEFINE(HAVE_INVALIDATEPAGE_RETURN_INT, 1,
965                 [Define if return type of invalidatepage should be int])
966 ],[
967         AC_MSG_RESULT(NO)
968 ])
969 ])
970
971 # LC_UMOUNTBEGIN_HAS_VFSMOUNT
972 # more 2.6 API changes. 2.6.18 umount_begin has different parameters
973 AC_DEFUN([LC_UMOUNTBEGIN_HAS_VFSMOUNT],
974 [AC_MSG_CHECKING([if umount_begin needs vfsmount parameter instead of super_block])
975 tmp_flags="$EXTRA_KCFLAGS"
976 EXTRA_KCFLAGS="-Werror"
977 LB_LINUX_TRY_COMPILE([
978         #include <linux/fs.h>
979
980         struct vfsmount;
981         static void cfg_umount_begin (struct vfsmount *v, int flags)
982         {
983                 ;
984         }
985
986         static struct super_operations cfg_super_operations = {
987                 .umount_begin   = cfg_umount_begin,
988         };
989 ],[
990         cfg_super_operations.umount_begin(NULL,0);
991 ],[
992         AC_MSG_RESULT(yes)
993         AC_DEFINE(HAVE_UMOUNTBEGIN_VFSMOUNT, 1,
994                 [Define umount_begin need second argument])
995 ],[
996         AC_MSG_RESULT(NO)
997 ])
998 EXTRA_KCFLAGS="$tmp_flags"
999 ])
1000
1001 # 2.6.19 API changes
1002 # inode don't have i_blksize field
1003 AC_DEFUN([LC_INODE_BLKSIZE],
1004 [AC_MSG_CHECKING([inode has i_blksize field])
1005 LB_LINUX_TRY_COMPILE([
1006 #include <linux/fs.h>
1007 ],[
1008         struct inode i;
1009         i.i_blksize = 0; 
1010 ],[
1011         AC_MSG_RESULT(yes)
1012         AC_DEFINE(HAVE_INODE_BLKSIZE, 1,
1013                 [struct inode has i_blksize field])
1014 ],[
1015         AC_MSG_RESULT(NO)
1016 ])
1017 ])
1018
1019 # LC_VFS_READDIR_U64_INO
1020 # 2.6.19 use u64 for inode number instead of inode_t
1021 AC_DEFUN([LC_VFS_READDIR_U64_INO],
1022 [AC_MSG_CHECKING([check vfs_readdir need 64bit inode number])
1023 tmp_flags="$EXTRA_KCFLAGS"
1024 EXTRA_KCFLAGS="-Werror"
1025 LB_LINUX_TRY_COMPILE([
1026 #include <linux/fs.h>
1027         int fillonedir(void * __buf, const char * name, int namlen, loff_t offset,
1028                       u64 ino, unsigned int d_type)
1029         {
1030                 return 0;
1031         }
1032 ],[
1033         filldir_t filter;
1034
1035         filter = fillonedir;
1036         return 1;
1037 ],[
1038         AC_MSG_RESULT(yes)
1039         AC_DEFINE(HAVE_VFS_READDIR_U64_INO, 1,
1040                 [if vfs_readdir need 64bit inode number])
1041 ],[
1042         AC_MSG_RESULT(NO)
1043 ])
1044 EXTRA_KCFLAGS="$tmp_flags"
1045 ])
1046
1047 # LC_GENERIC_FILE_WRITE
1048 # 2.6.19 introduce do_sync_write instead of
1049 # generic_file_write
1050 AC_DEFUN([LC_GENERIC_FILE_WRITE],
1051 [AC_MSG_CHECKING([use generic_file_write])
1052 LB_LINUX_TRY_COMPILE([
1053         #include <linux/fs.h>
1054 ],[
1055         int result = generic_file_read(NULL, NULL, 0, 0);
1056 ],[
1057         AC_MSG_RESULT(yes)
1058         AC_DEFINE(HAVE_GENERIC_FILE_WRITE, 1,
1059                 [use generic_file_write])
1060 ],[
1061         AC_MSG_RESULT(NO)
1062 ])
1063 ])
1064
1065 # LC_GENERIC_FILE_READ
1066 # 2.6.19 need to use do_sync_read instead of
1067 # generic_file_read
1068 AC_DEFUN([LC_GENERIC_FILE_READ],
1069 [AC_MSG_CHECKING([use generic_file_read])
1070 LB_LINUX_TRY_COMPILE([
1071         #include <linux/fs.h>
1072 ],[
1073         int result = generic_file_read(NULL, NULL, 0, 0);
1074 ],[
1075         AC_MSG_RESULT(yes)
1076         AC_DEFINE(HAVE_GENERIC_FILE_READ, 1,
1077                 [use generic_file_read])
1078 ],[
1079         AC_MSG_RESULT(NO)
1080 ])
1081 ])
1082
1083 # LC_NR_PAGECACHE
1084 # 2.6.18 don't export nr_pagecahe
1085 AC_DEFUN([LC_NR_PAGECACHE],
1086 [AC_MSG_CHECKING([kernel export nr_pagecache])
1087 LB_LINUX_TRY_COMPILE([
1088         #include <linux/pagemap.h>
1089 ],[
1090         return atomic_read(&nr_pagecache);
1091 ],[
1092         AC_MSG_RESULT(yes)
1093         AC_DEFINE(HAVE_NR_PAGECACHE, 1,
1094                 [is kernel export nr_pagecache])
1095 ],[
1096         AC_MSG_RESULT(NO)
1097 ])
1098 ])
1099
1100 # LC_CANCEL_DIRTY_PAGE
1101 # 2.6.20 introduse cancel_dirty_page instead of 
1102 # clear_page_dirty.
1103 AC_DEFUN([LC_CANCEL_DIRTY_PAGE],
1104 [AC_MSG_CHECKING([kernel has cancel_dirty_page])
1105 LB_LINUX_TRY_COMPILE([
1106         #include <linux/page-flags.h>
1107 ],[
1108         cancel_dirty_page(NULL, 0);
1109 ],[
1110         AC_MSG_RESULT(yes)
1111         AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
1112                   [kernel has cancel_dirty_page instead of clear_page_dirty])
1113 ],[
1114         AC_MSG_RESULT(NO)
1115 ])
1116 ])
1117
1118 #
1119 # LC_PAGE_CONSTANT
1120 #
1121 # In order to support raid5 zerocopy patch, we have to patch the kernel to make
1122 # it support constant page, which means the page won't be modified during the
1123 # IO.
1124 #
1125 AC_DEFUN([LC_PAGE_CONSTANT],
1126 [AC_MSG_CHECKING([if kernel have PageConstant defined])
1127 LB_LINUX_TRY_COMPILE([
1128         #include <linux/page-flags.h>
1129 ],[
1130         #ifndef PG_constant
1131         #error "Have no raid5 zcopy patch"
1132         #endif
1133 ],[
1134         AC_MSG_RESULT(yes)
1135         AC_DEFINE(HAVE_PAGE_CONSTANT, 1, [kernel have PageConstant supported])
1136 ],[
1137         AC_MSG_RESULT(no);
1138 ])
1139 ])
1140
1141 # RHEL5 in FS-cache patch rename PG_checked flag
1142 # into PG_fs_misc
1143 AC_DEFUN([LC_PG_FS_MISC],
1144 [AC_MSG_CHECKING([kernel has PG_fs_misc])
1145 LB_LINUX_TRY_COMPILE([
1146         #include <linux/page-flags.h>
1147 ],[
1148         #ifndef PG_fs_misc
1149         #error PG_fs_misc not defined in kernel
1150         #endif
1151 ],[
1152         AC_MSG_RESULT(yes)
1153         AC_DEFINE(HAVE_PG_FS_MISC, 1,
1154                   [is kernel have PG_fs_misc])
1155 ],[
1156         AC_MSG_RESULT(NO)
1157 ])
1158 ])
1159
1160 # RHEL5 PageChecked and SetPageChecked defined
1161 AC_DEFUN([LC_PAGE_CHECKED],
1162 [AC_MSG_CHECKING([kernel has PageChecked and SetPageChecked])
1163 LB_LINUX_TRY_COMPILE([
1164         #include <linux/page-flags.h>
1165 ],[
1166         #ifndef PageChecked
1167         #error PageChecked not defined in kernel
1168         #endif
1169         #ifndef SetPageChecked
1170         #error SetPageChecked not defined in kernel
1171         #endif
1172 ],[
1173         AC_MSG_RESULT(yes)
1174         AC_DEFINE(HAVE_PAGE_CHECKED, 1,
1175                   [does kernel have PageChecked and SetPageChecked])
1176 ],[
1177         AC_MSG_RESULT(NO)
1178 ])
1179 ])
1180
1181 AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
1182 [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
1183 [mm/truncate.c],[
1184 AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
1185             [kernel export truncate_complete_page])
1186 ],[
1187 ])
1188 ])
1189
1190 AC_DEFUN([LC_EXPORT_D_REHASH_COND],
1191 [LB_CHECK_SYMBOL_EXPORT([d_rehash_cond],
1192 [fs/dcache.c],[
1193 AC_DEFINE(HAVE_D_REHASH_COND, 1,
1194             [d_rehash_cond is exported by the kernel])
1195 ],[
1196 ])
1197 ])
1198
1199 AC_DEFUN([LC_EXPORT___D_REHASH],
1200 [LB_CHECK_SYMBOL_EXPORT([__d_rehash],
1201 [fs/dcache.c],[
1202 AC_DEFINE(HAVE___D_REHASH, 1,
1203             [__d_rehash is exported by the kernel])
1204 ],[
1205 ])
1206 ])
1207
1208 AC_DEFUN([LC_EXPORT_D_MOVE_LOCKED],
1209 [LB_CHECK_SYMBOL_EXPORT([d_move_locked],
1210 [fs/dcache.c],[
1211 AC_DEFINE(HAVE_D_MOVE_LOCKED, 1,
1212             [d_move_locked is exported by the kernel])
1213 ],[
1214 ])
1215 ])
1216
1217 AC_DEFUN([LC_EXPORT___D_MOVE],
1218 [LB_CHECK_SYMBOL_EXPORT([__d_move],
1219 [fs/dcache.c],[
1220 AC_DEFINE(HAVE___D_MOVE, 1,
1221             [__d_move is exported by the kernel])
1222 ],[
1223 ])
1224 ])
1225
1226 # The actual symbol exported varies among architectures, so we need
1227 # to check many symbols (but only in the current architecture.)  No
1228 # matter what symbol is exported, the kernel #defines node_to_cpumask
1229 # to the appropriate function and that's what we use.
1230 AC_DEFUN([LC_EXPORT_NODE_TO_CPUMASK],
1231          [LB_CHECK_SYMBOL_EXPORT([node_to_cpumask],
1232                                  [arch/$LINUX_ARCH/mm/numa.c],
1233                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1234                                             [node_to_cpumask is exported by
1235                                              the kernel])]) # x86_64
1236           LB_CHECK_SYMBOL_EXPORT([node_to_cpu_mask],
1237                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
1238                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1239                                             [node_to_cpumask is exported by
1240                                              the kernel])]) # ia64
1241           LB_CHECK_SYMBOL_EXPORT([node_2_cpu_mask],
1242                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
1243                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1244                                             [node_to_cpumask is exported by
1245                                              the kernel])]) # i386
1246           ])
1247
1248 # 2.6.22 lost second parameter for invalidate_bdev
1249 AC_DEFUN([LC_INVALIDATE_BDEV_2ARG],
1250 [AC_MSG_CHECKING([if invalidate_bdev has second argument])
1251 LB_LINUX_TRY_COMPILE([
1252         #include <linux/buffer_head.h>
1253 ],[
1254         invalidate_bdev(NULL,0);
1255 ],[
1256         AC_MSG_RESULT([yes])
1257         AC_DEFINE(HAVE_INVALIDATE_BDEV_2ARG, 1,
1258                 [invalidate_bdev has second argument])
1259 ],[
1260         AC_MSG_RESULT([no])
1261 ])
1262 ])
1263
1264 # 2.6.23 have return type 'void' for unregister_blkdev
1265 AC_DEFUN([LC_UNREGISTER_BLKDEV_RETURN_INT],
1266 [AC_MSG_CHECKING([if unregister_blkdev return int])
1267 LB_LINUX_TRY_COMPILE([
1268         #include <linux/fs.h>
1269 ],[
1270         int i = unregister_blkdev(0,NULL);
1271 ],[
1272         AC_MSG_RESULT([yes])
1273         AC_DEFINE(HAVE_UNREGISTER_BLKDEV_RETURN_INT, 1, 
1274                 [unregister_blkdev return int])
1275 ],[
1276         AC_MSG_RESULT([no])
1277 ])
1278 ])
1279
1280 # 2.6.23 change .sendfile to .splice_read
1281 AC_DEFUN([LC_KERNEL_SPLICE_READ],
1282 [AC_MSG_CHECKING([if kernel has .splice_read])
1283 LB_LINUX_TRY_COMPILE([
1284         #include <linux/fs.h>
1285 ],[
1286         struct file_operations file;
1287
1288         file.splice_read = NULL;
1289 ], [
1290         AC_MSG_RESULT([yes])
1291         AC_DEFINE(HAVE_KERNEL_SPLICE_READ, 1,
1292                 [kernel has .slice_read])
1293 ],[
1294         AC_MSG_RESULT([no])
1295 ])
1296 ])
1297
1298 # 2.6.23 extract nfs export related data into exportfs.h
1299 AC_DEFUN([LC_HAVE_EXPORTFS_H],
1300 [
1301 tmpfl="$CFLAGS"
1302 CFLAGS="$CFLAGS -I$LINUX_OBJ/include"
1303 AC_CHECK_HEADERS([linux/exportfs.h])
1304 CFLAGS="$tmpfl"
1305 ])
1306
1307 #
1308 # LC_VFS_INTENT_PATCHES
1309 #
1310 # check if the kernel has the VFS intent patches
1311 AC_DEFUN([LC_VFS_INTENT_PATCHES],
1312 [AC_MSG_CHECKING([if the kernel has the VFS intent patches])
1313 LB_LINUX_TRY_COMPILE([
1314         #include <linux/fs.h>
1315         #include <linux/namei.h>
1316 ],[
1317         struct nameidata nd;
1318         struct lookup_intent *it;
1319
1320         it = &nd.intent;
1321         intent_init(it, IT_OPEN);
1322         it->d.lustre.it_disposition = 0;
1323         it->d.lustre.it_data = NULL;
1324 ],[
1325         AC_MSG_RESULT([yes])
1326         AC_DEFINE(HAVE_VFS_INTENT_PATCHES, 1, [VFS intent patches are applied])
1327 ],[
1328         AC_MSG_RESULT([no])
1329 ])
1330 ])
1331
1332 AC_DEFUN([LC_S_TIME_GRAN],
1333 [AC_MSG_CHECKING([if super block has s_time_gran member])
1334 LB_LINUX_TRY_COMPILE([
1335         #include <linux/fs.h>
1336 ],[
1337         struct super_block sb;
1338
1339         return sb.s_time_gran;
1340 ],[
1341         AC_MSG_RESULT([yes])
1342         AC_DEFINE(HAVE_S_TIME_GRAN, 1, [super block has s_time_gran member])
1343 ],[
1344         AC_MSG_RESULT([no])
1345 ])
1346 ])
1347
1348 AC_DEFUN([LC_SB_TIME_GRAN],
1349 [AC_MSG_CHECKING([if kernel has old get_sb_time_gran])
1350 LB_LINUX_TRY_COMPILE([
1351         #include <linux/fs.h>
1352 ],[
1353         return get_sb_time_gran(NULL);
1354 ],[
1355         AC_MSG_RESULT([yes])
1356         AC_DEFINE(HAVE_SB_TIME_GRAN, 1, [kernel has old get_sb_time_gran])
1357 ],[
1358         AC_MSG_RESULT([no])
1359 ])
1360 ])
1361
1362
1363 # ~2.6.12 merge patch from oracle to convert tree_lock from spinlock to rwlock
1364 AC_DEFUN([LC_RW_TREE_LOCK],
1365 [AC_MSG_CHECKING([if kernel has tree_lock as rwlock])
1366 tmp_flags="$EXTRA_KCFLAGS"
1367 EXTRA_KCFLAGS="-Werror"
1368 LB_LINUX_TRY_COMPILE([
1369         #include <linux/fs.h>
1370 ],[
1371         struct address_space a;
1372
1373         write_lock(&a.tree_lock);
1374 ],[
1375         AC_MSG_RESULT([yes])
1376         AC_DEFINE(HAVE_RW_TREE_LOCK, 1, [kernel has tree_lock as rw_lock])
1377 ],[
1378         AC_MSG_RESULT([no])
1379 ])
1380 EXTRA_KCFLAGS="$tmp_flags"
1381 ])
1382
1383 AC_DEFUN([LC_CONST_ACL_SIZE],
1384 [AC_MSG_CHECKING([calc acl size])
1385 tmp_flags="$CFLAGS"
1386 CFLAGS="$CFLAGS -I $LINUX_OBJ/include $EXTRA_KCFLAGS"
1387 AC_TRY_RUN([
1388 #define __KERNEL__
1389 #include <linux/autoconf.h>
1390 #include <linux/types.h>
1391 #undef __KERNEL__
1392 // block include 
1393 #define __LINUX_POSIX_ACL_H
1394
1395 # ifdef CONFIG_FS_POSIX_ACL
1396 #  ifdef HAVE_XATTR_ACL
1397 #   include <linux/xattr_acl.h>
1398 #  endif
1399 #  ifdef HAVE_LINUX_POSIX_ACL_XATTR_H
1400 #   include <linux/posix_acl_xattr.h>
1401 #  endif
1402 # endif
1403
1404 #include <lustre_acl.h>
1405
1406 #include <stdio.h>
1407
1408 int main(void)
1409 {
1410     int size = mds_xattr_acl_size(LUSTRE_POSIX_ACL_MAX_ENTRIES);
1411     FILE *f = fopen("acl.size","w+");
1412     fprintf(f,"%d", size);
1413     fclose(f);
1414
1415     return 0;
1416 }
1417
1418 ],[
1419         acl_size=`cat acl.size`
1420         AC_MSG_RESULT([ACL size $acl_size])
1421         AC_DEFINE_UNQUOTED(XATTR_ACL_SIZE, AS_TR_SH([$acl_size]), [size of xattr acl])
1422 ],[
1423         AC_ERROR([ACL size can't computed])
1424 ])
1425 CFLAGS="$tmp_flags"
1426 ])
1427
1428 #
1429 # check for crypto API 
1430 #
1431 AC_DEFUN([LC_ASYNC_BLOCK_CIPHER],
1432 [AC_MSG_CHECKING([if kernel has block cipher support])
1433 LB_LINUX_TRY_COMPILE([
1434         #include <linux/crypto.h>
1435 ],[
1436         int v = CRYPTO_ALG_TYPE_BLKCIPHER;
1437 ],[
1438         AC_MSG_RESULT([yes])
1439         AC_DEFINE(HAVE_ASYNC_BLOCK_CIPHER, 1, [kernel has block cipher support])
1440 ],[
1441         AC_MSG_RESULT([no])
1442 ])
1443 ])
1444
1445 #
1446 # check for FS_RENAME_DOES_D_MOVE flag
1447 #
1448 AC_DEFUN([LC_FS_RENAME_DOES_D_MOVE],
1449 [AC_MSG_CHECKING([if kernel has FS_RENAME_DOES_D_MOVE flag])
1450 LB_LINUX_TRY_COMPILE([
1451         #include <linux/fs.h>
1452 ],[
1453         int v = FS_RENAME_DOES_D_MOVE;
1454 ],[
1455         AC_MSG_RESULT([yes])
1456         AC_DEFINE(HAVE_FS_RENAME_DOES_D_MOVE, 1, [kernel has FS_RENAME_DOES_D_MOVE flag])
1457 ],[
1458         AC_MSG_RESULT([no])
1459 ])
1460 ])
1461
1462 #
1463 # LC_PROG_LINUX
1464 #
1465 # Lustre linux kernel checks
1466 #
1467 AC_DEFUN([LC_PROG_LINUX],
1468          [LC_LUSTRE_VERSION_H
1469          if test x$enable_server = xyes ; then
1470              AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
1471              LC_CONFIG_BACKINGFS
1472          fi
1473          LC_CONFIG_PINGER
1474          LC_CONFIG_CHECKSUM
1475          LC_CONFIG_LIBLUSTRE_RECOVERY
1476          LC_CONFIG_QUOTA
1477          LC_CONFIG_HEALTH_CHECK_WRITE
1478          LC_CONFIG_LRU_RESIZE
1479
1480          LC_TASK_PPTR
1481          # RHEL4 patches
1482          LC_EXPORT_TRUNCATE_COMPLETE
1483          LC_EXPORT_D_REHASH_COND
1484          LC_EXPORT___D_REHASH
1485          LC_EXPORT_D_MOVE_LOCKED
1486          LC_EXPORT___D_MOVE
1487          LC_EXPORT_NODE_TO_CPUMASK
1488
1489          LC_STRUCT_KIOBUF
1490          LC_FUNC_COND_RESCHED
1491          LC_FUNC_ZAP_PAGE_RANGE
1492          LC_FUNC_PDE
1493          LC_FUNC_DIRECT_IO
1494          LC_HEADER_MM_INLINE
1495          LC_STRUCT_INODE
1496          LC_FUNC_REGISTER_CACHE
1497          LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
1498          LC_FUNC_DEV_SET_RDONLY
1499          LC_FUNC_FILEMAP_FDATAWRITE
1500          LC_STRUCT_STATFS
1501          LC_FUNC_PAGE_MAPPED
1502          LC_STRUCT_FILE_OPS_UNLOCKED_IOCTL
1503          LC_FILEMAP_POPULATE
1504          LC_D_ADD_UNIQUE
1505          LC_BIT_SPINLOCK_H
1506
1507          LC_XATTR_ACL
1508          LC_POSIX_ACL_XATTR_H
1509          LC_CONST_ACL_SIZE
1510
1511          LC_STRUCT_INTENT_FILE
1512
1513          LC_FUNC_SET_FS_PWD
1514          LC_CAPA_CRYPTO
1515          LC_CONFIG_GSS
1516          LC_FUNC_MS_FLOCK_LOCK
1517          LC_FUNC_HAVE_CAN_SLEEP_ARG
1518          LC_FUNC_F_OP_FLOCK
1519          LC_QUOTA_READ
1520          LC_COOKIE_FOLLOW_LINK
1521          LC_FUNC_RCU
1522          LC_PERCPU_COUNTER
1523
1524          # does the kernel have VFS intent patches?
1525          LC_VFS_INTENT_PATCHES
1526
1527          # ~2.6.11
1528          LC_S_TIME_GRAN
1529          LC_SB_TIME_GRAN
1530
1531          # 2.6.12
1532          LC_RW_TREE_LOCK
1533
1534          # 2.6.15
1535          LC_INODE_I_MUTEX
1536
1537          # 2.6.16
1538          LC_SECURITY_PLUG  # for SLES10 SP2
1539
1540          # 2.6.17
1541          LC_DQUOTOFF_MUTEX
1542
1543          # 2.6.18
1544          LC_NR_PAGECACHE
1545          LC_STATFS_DENTRY_PARAM
1546          LC_VFS_KERN_MOUNT
1547          LC_INVALIDATEPAGE_RETURN_INT
1548          LC_UMOUNTBEGIN_HAS_VFSMOUNT
1549
1550          #2.6.18 + RHEL5 (fc6)
1551          LC_PG_FS_MISC
1552          LC_PAGE_CHECKED
1553
1554          # 2.6.19
1555          LC_INODE_BLKSIZE
1556          LC_VFS_READDIR_U64_INO
1557          LC_GENERIC_FILE_READ
1558          LC_GENERIC_FILE_WRITE
1559
1560          # 2.6.20
1561          LC_CANCEL_DIRTY_PAGE
1562
1563          # raid5-zerocopy patch
1564          LC_PAGE_CONSTANT
1565                   
1566          # 2.6.22
1567          LC_INVALIDATE_BDEV_2ARG
1568          LC_ASYNC_BLOCK_CIPHER
1569          LC_FS_RENAME_DOES_D_MOVE
1570          # 2.6.23
1571          LC_UNREGISTER_BLKDEV_RETURN_INT
1572          LC_KERNEL_SPLICE_READ
1573          LC_HAVE_EXPORTFS_H
1574 ])
1575
1576 #
1577 # LC_CONFIG_CLIENT_SERVER
1578 #
1579 # Build client/server sides of Lustre
1580 #
1581 AC_DEFUN([LC_CONFIG_CLIENT_SERVER],
1582 [AC_MSG_CHECKING([whether to build Lustre server support])
1583 AC_ARG_ENABLE([server],
1584         AC_HELP_STRING([--disable-server],
1585                         [disable Lustre server support]),
1586         [],[enable_server='yes'])
1587 AC_MSG_RESULT([$enable_server])
1588
1589 AC_MSG_CHECKING([whether to build Lustre client support])
1590 AC_ARG_ENABLE([client],
1591         AC_HELP_STRING([--disable-client],
1592                         [disable Lustre client support]),
1593         [],[enable_client='yes'])
1594 AC_MSG_RESULT([$enable_client])])
1595
1596 #
1597 # LC_CONFIG_LIBLUSTRE
1598 #
1599 # whether to build liblustre
1600 #
1601 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
1602 [AC_MSG_CHECKING([whether to build Lustre library])
1603 AC_ARG_ENABLE([liblustre],
1604         AC_HELP_STRING([--disable-liblustre],
1605                         [disable building of Lustre library]),
1606         [],[enable_liblustre=$with_sysio])
1607 AC_MSG_RESULT([$enable_liblustre])
1608 # only build sysio if liblustre is built
1609 with_sysio="$enable_liblustre"
1610
1611 AC_MSG_CHECKING([whether to build liblustre tests])
1612 AC_ARG_ENABLE([liblustre-tests],
1613         AC_HELP_STRING([--enable-liblustre-tests],
1614                         [enable liblustre tests, if --disable-tests is used]),
1615         [],[enable_liblustre_tests=$enable_tests])
1616 if test x$enable_liblustre != xyes ; then
1617    enable_liblustre_tests='no'
1618 fi
1619 AC_MSG_RESULT([$enable_liblustre_tests])
1620
1621 AC_MSG_CHECKING([whether to enable liblustre acl])
1622 AC_ARG_ENABLE([liblustre-acl],
1623         AC_HELP_STRING([--disable-liblustre-acl],
1624                         [disable ACL support for liblustre]),
1625         [],[enable_liblustre_acl=yes])
1626 AC_MSG_RESULT([$enable_liblustre_acl])
1627 if test x$enable_liblustre_acl = xyes ; then
1628   AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
1629 fi
1630
1631 AC_MSG_CHECKING([whether to build mpitests])
1632 AC_ARG_ENABLE([mpitests],
1633         AC_HELP_STRING([--enable-mpitests],
1634                         [build liblustre mpi tests]),
1635         [],[enable_mpitests=no])
1636 AC_MSG_RESULT([$enable_mpitests])
1637
1638 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
1639 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
1640
1641 LC_CONFIG_PINGER
1642 LC_CONFIG_LIBLUSTRE_RECOVERY
1643 ])
1644
1645 AC_DEFUN([LC_CONFIG_LRU_RESIZE],
1646 [AC_MSG_CHECKING([whether to enable lru self-adjusting])
1647 AC_ARG_ENABLE([lru_resize], 
1648         AC_HELP_STRING([--enable-lru-resize],
1649                         [enable lru resize support]),
1650         [],[enable_lru_resize='yes'])
1651 AC_MSG_RESULT([$enable_lru_resize])
1652 if test x$enable_lru_resize != xno; then
1653    AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])
1654 fi
1655 ])
1656
1657 #
1658 # LC_CONFIG_QUOTA
1659 #
1660 # whether to enable quota support
1661 #
1662 AC_DEFUN([LC_CONFIG_QUOTA],
1663 [AC_ARG_ENABLE([quota], 
1664         AC_HELP_STRING([--enable-quota],
1665                         [enable quota support]),
1666         [],[enable_quota='default'])
1667 if test x$linux25 != xyes; then
1668         enable_quota='no'
1669 fi
1670 LB_LINUX_CONFIG([QUOTA],[
1671         if test x$enable_quota = xdefault; then
1672                 enable_quota='yes'
1673         fi
1674 ],[
1675         if test x$enable_quota = xdefault; then
1676                 enable_quota='no'
1677                 AC_MSG_WARN([quota is not enabled because the kernel lacks quota support])
1678         else
1679                 if test x$enable_quota = xyes; then
1680                         AC_MSG_ERROR([cannot enable quota because the kernel lacks quota support])
1681                 fi
1682         fi
1683 ])
1684 if test x$enable_quota != xno; then
1685         AC_DEFINE(HAVE_QUOTA_SUPPORT, 1, [Enable quota support])
1686 fi
1687 ])
1688
1689 #
1690 # LC_CONFIG_SPLIT
1691 #
1692 # whether to enable split support
1693 #
1694 AC_DEFUN([LC_CONFIG_SPLIT],
1695 [AC_MSG_CHECKING([whether to enable split support])
1696 AC_ARG_ENABLE([split], 
1697         AC_HELP_STRING([--enable-split],
1698                         [enable split support]),
1699         [],[enable_split='no'])
1700 AC_MSG_RESULT([$enable_split])
1701 if test x$enable_split != xno; then
1702    AC_DEFINE(HAVE_SPLIT_SUPPORT, 1, [enable split support])
1703 fi
1704 ])
1705  
1706 AC_DEFUN([LC_QUOTA_READ],
1707 [AC_MSG_CHECKING([if kernel supports quota_read])
1708 LB_LINUX_TRY_COMPILE([
1709         #include <linux/fs.h>
1710 ],[
1711         struct super_operations sp;
1712         void *i = (void *)sp.quota_read;
1713 ],[
1714         AC_MSG_RESULT([yes])
1715         AC_DEFINE(KERNEL_SUPPORTS_QUOTA_READ, 1, [quota_read found])
1716 ],[
1717         AC_MSG_RESULT([no])
1718 ])
1719 ])
1720
1721 #
1722 # LC_COOKIE_FOLLOW_LINK
1723 #
1724 # kernel 2.6.13+ ->follow_link returns a cookie
1725 #
1726
1727 AC_DEFUN([LC_COOKIE_FOLLOW_LINK],
1728 [AC_MSG_CHECKING([if inode_operations->follow_link returns a cookie])
1729 LB_LINUX_TRY_COMPILE([
1730         #include <linux/fs.h>
1731         #include <linux/namei.h>
1732 ],[
1733         struct dentry dentry;
1734         struct nameidata nd;
1735
1736         dentry.d_inode->i_op->put_link(&dentry, &nd, NULL);
1737 ],[
1738         AC_DEFINE(HAVE_COOKIE_FOLLOW_LINK, 1, [inode_operations->follow_link returns a cookie])
1739         AC_MSG_RESULT([yes])
1740 ],[
1741         AC_MSG_RESULT([no])
1742 ])
1743 ])
1744
1745 #
1746 # LC_FUNC_RCU
1747 #
1748 # kernels prior than 2.6.0(?) have no RCU supported; in kernel 2.6.5(SUSE), 
1749 # call_rcu takes three parameters.
1750 #
1751 AC_DEFUN([LC_FUNC_RCU],
1752 [AC_MSG_CHECKING([if kernel have RCU supported])
1753 LB_LINUX_TRY_COMPILE([
1754         #include <linux/rcupdate.h>
1755 ],[],[
1756         AC_DEFINE(HAVE_RCU, 1, [have RCU defined])
1757         AC_MSG_RESULT([yes])
1758
1759         AC_MSG_CHECKING([if call_rcu takes three parameters])
1760         LB_LINUX_TRY_COMPILE([
1761                 #include <linux/rcupdate.h>
1762         ],[
1763                 struct rcu_head rh;
1764                 call_rcu(&rh, (void (*)(struct rcu_head *))1, NULL);
1765         ],[
1766                 AC_DEFINE(HAVE_CALL_RCU_PARAM, 1, [call_rcu takes three parameters])
1767                 AC_MSG_RESULT([yes])
1768         ],[
1769                 AC_MSG_RESULT([no]) 
1770         ])
1771 ],[
1772         AC_MSG_RESULT([no])
1773 ])
1774 ])
1775
1776 # LC_SECURITY_PLUG  # for SLES10 SP2
1777 # check security plug in sles10 sp2 kernel 
1778 AC_DEFUN([LC_SECURITY_PLUG],
1779 [AC_MSG_CHECKING([If kernel has security plug support])
1780 LB_LINUX_TRY_COMPILE([
1781         #include <linux/fs.h>
1782 ],[
1783         struct dentry   *dentry;
1784         struct vfsmount *mnt;
1785         struct iattr    *iattr;
1786
1787         notify_change(dentry, mnt, iattr);
1788 ],[
1789         AC_MSG_RESULT(yes)
1790         AC_DEFINE(HAVE_SECURITY_PLUG, 1,
1791                 [SLES10 SP2 use extra parameter in vfs])
1792 ],[
1793         AC_MSG_RESULT(NO)
1794 ])
1795 ])
1796
1797 AC_DEFUN([LC_PERCPU_COUNTER],
1798 [AC_MSG_CHECKING([if have struct percpu_counter defined])
1799 LB_LINUX_TRY_COMPILE([
1800         #include <linux/percpu_counter.h>
1801 ],[],[
1802         AC_DEFINE(HAVE_PERCPU_COUNTER, 1, [percpu_counter found])
1803         AC_MSG_RESULT([yes])
1804
1805         AC_MSG_CHECKING([if percpu_counter_inc takes the 2nd argument])
1806         LB_LINUX_TRY_COMPILE([
1807                 #include <linux/percpu_counter.h>
1808         ],[
1809                 struct percpu_counter c;
1810                 percpu_counter_init(&c, 0);
1811         ],[
1812                 AC_DEFINE(HAVE_PERCPU_2ND_ARG, 1, [percpu_counter_init has two
1813                                                    arguments])
1814                 AC_MSG_RESULT([yes])
1815         ],[
1816                 AC_MSG_RESULT([no])
1817         ])
1818 ],[
1819         AC_MSG_RESULT([no])
1820 ])
1821 ])
1822
1823 #
1824 # LC_CONFIGURE
1825 #
1826 # other configure checks
1827 #
1828 AC_DEFUN([LC_CONFIGURE],
1829 [LC_CONFIG_OBD_BUFFER_SIZE
1830
1831 # include/liblustre.h
1832 AC_CHECK_HEADERS([sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
1833
1834 # liblustre/llite_lib.h
1835 AC_CHECK_HEADERS([xtio.h file.h])
1836
1837 # liblustre/dir.c
1838 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
1839
1840 # liblustre/lutil.c
1841 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
1842 AC_CHECK_FUNCS([inet_ntoa])
1843
1844 # libsysio/src/readlink.c
1845 LC_READLINK_SSIZE_T
1846
1847 # lvfs/prng.c - depends on linux/types.h from liblustre/dir.c
1848 AC_CHECK_HEADERS([linux/random.h], [], [],
1849                  [#ifdef HAVE_LINUX_TYPES_H
1850                   # include <linux/types.h>
1851                   #endif
1852                  ])
1853
1854 # utils/llverfs.c
1855 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
1856
1857 # check for -lz support
1858 ZLIB=""
1859 AC_CHECK_LIB([z],
1860              [adler32],
1861              [AC_CHECK_HEADERS([zlib.h],
1862                                [ZLIB="-lz"
1863                                 AC_DEFINE([HAVE_ADLER], 1,
1864                                           [support alder32 checksum type])],
1865                                [AC_MSG_WARN([No zlib-devel package found,
1866                                              unable to use adler32 checksum])])],
1867              [AC_MSG_WARN([No zlib package found, unable to use adler32 checksum])]
1868 )
1869 AC_SUBST(ZLIB)
1870
1871 # Super safe df
1872 AC_ARG_ENABLE([mindf],
1873       AC_HELP_STRING([--enable-mindf],
1874                       [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
1875       [],[])
1876 if test "$enable_mindf" = "yes" ;  then
1877       AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
1878 fi
1879
1880 AC_ARG_ENABLE([fail_alloc],
1881         AC_HELP_STRING([--disable-fail-alloc],
1882                 [disable randomly alloc failure]),
1883         [],[enable_fail_alloc=yes])
1884 AC_MSG_CHECKING([whether to randomly failing memory alloc])
1885 AC_MSG_RESULT([$enable_fail_alloc])
1886 if test x$enable_fail_alloc != xno ; then
1887         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
1888 fi
1889
1890 ])
1891
1892 #
1893 # LC_CONDITIONALS
1894 #
1895 # AM_CONDITIONALS for lustre
1896 #
1897 AC_DEFUN([LC_CONDITIONALS],
1898 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
1899 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
1900 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
1901 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
1902 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
1903 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
1904 AM_CONDITIONAL(QUOTA, test x$enable_quota = xyes)
1905 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
1906 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
1907 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
1908 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
1909 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
1910 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
1911 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
1912 ])
1913
1914 #
1915 # LC_CONFIG_FILES
1916 #
1917 # files that should be generated with AC_OUTPUT
1918 #
1919 AC_DEFUN([LC_CONFIG_FILES],
1920 [AC_CONFIG_FILES([
1921 lustre/Makefile
1922 lustre/autoMakefile
1923 lustre/autoconf/Makefile
1924 lustre/contrib/Makefile
1925 lustre/doc/Makefile
1926 lustre/include/Makefile
1927 lustre/include/lustre_ver.h
1928 lustre/include/linux/Makefile
1929 lustre/include/lustre/Makefile
1930 lustre/kernel_patches/targets/2.6-vanilla.target
1931 lustre/kernel_patches/targets/2.6-rhel4.target
1932 lustre/kernel_patches/targets/2.6-rhel5.target
1933 lustre/kernel_patches/targets/2.6-fc5.target
1934 lustre/kernel_patches/targets/2.6-patchless.target
1935 lustre/kernel_patches/targets/2.6-sles10.target
1936 lustre/ldlm/Makefile
1937 lustre/fid/Makefile
1938 lustre/fid/autoMakefile
1939 lustre/liblustre/Makefile
1940 lustre/liblustre/tests/Makefile
1941 lustre/llite/Makefile
1942 lustre/llite/autoMakefile
1943 lustre/lov/Makefile
1944 lustre/lov/autoMakefile
1945 lustre/lvfs/Makefile
1946 lustre/lvfs/autoMakefile
1947 lustre/mdc/Makefile
1948 lustre/mdc/autoMakefile
1949 lustre/lmv/Makefile
1950 lustre/lmv/autoMakefile
1951 lustre/mds/Makefile
1952 lustre/mds/autoMakefile
1953 lustre/mdt/Makefile
1954 lustre/mdt/autoMakefile
1955 lustre/cmm/Makefile
1956 lustre/cmm/autoMakefile
1957 lustre/mdd/Makefile
1958 lustre/mdd/autoMakefile
1959 lustre/fld/Makefile
1960 lustre/fld/autoMakefile
1961 lustre/obdclass/Makefile
1962 lustre/obdclass/autoMakefile
1963 lustre/obdclass/linux/Makefile
1964 lustre/obdecho/Makefile
1965 lustre/obdecho/autoMakefile
1966 lustre/obdfilter/Makefile
1967 lustre/obdfilter/autoMakefile
1968 lustre/osc/Makefile
1969 lustre/osc/autoMakefile
1970 lustre/ost/Makefile
1971 lustre/ost/autoMakefile
1972 lustre/osd/Makefile
1973 lustre/osd/autoMakefile
1974 lustre/mgc/Makefile
1975 lustre/mgc/autoMakefile
1976 lustre/mgs/Makefile
1977 lustre/mgs/autoMakefile
1978 lustre/ptlrpc/Makefile
1979 lustre/ptlrpc/autoMakefile
1980 lustre/ptlrpc/gss/Makefile
1981 lustre/ptlrpc/gss/autoMakefile
1982 lustre/quota/Makefile
1983 lustre/quota/autoMakefile
1984 lustre/scripts/Makefile
1985 lustre/scripts/version_tag.pl
1986 lustre/tests/Makefile
1987 lustre/utils/Makefile
1988 lustre/utils/gss/Makefile
1989 ])
1990 case $lb_target_os in
1991         darwin)
1992                 AC_CONFIG_FILES([ lustre/obdclass/darwin/Makefile ])
1993                 ;;
1994 esac
1995
1996 ])