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