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