Whamcloud - gitweb
- make HEAD from b_post_cmd3
[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_ZAP_PAGE_RANGE
126 #
127 # if zap_page_range() takes a vma arg
128 #
129 AC_DEFUN([LC_FUNC_ZAP_PAGE_RANGE],
130 [AC_MSG_CHECKING([if zap_page_range with vma parameter])
131 ZAP_PAGE_RANGE_VMA="`grep -c 'zap_page_range.*struct vm_area_struct' $LINUX/include/linux/mm.h`"
132 if test "$ZAP_PAGE_RANGE_VMA" != 0 ; then
133         AC_DEFINE(ZAP_PAGE_RANGE_VMA, 1, [zap_page_range with vma parameter])
134         AC_MSG_RESULT([yes])
135 else
136         AC_MSG_RESULT([no])
137 fi
138 ])
139
140 #
141 # LC_FUNC_PDE
142 #
143 # if proc_fs.h defines PDE()
144 #
145 AC_DEFUN([LC_FUNC_PDE],
146 [AC_MSG_CHECKING([if kernel defines PDE])
147 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
148 if test "$HAVE_PDE" != 0 ; then
149         AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
150         AC_MSG_RESULT([yes])
151 else
152         AC_MSG_RESULT([no])
153 fi
154 ])
155
156 #
157 # LC_FUNC_FILEMAP_FDATASYNC
158 #
159 # if filemap_fdatasync() exists
160 #
161 AC_DEFUN([LC_FUNC_FILEMAP_FDATAWRITE],
162 [AC_MSG_CHECKING([whether filemap_fdatawrite() is defined])
163 LB_LINUX_TRY_COMPILE([
164         #include <linux/fs.h>
165 ],[
166         int (*foo)(struct address_space *)= filemap_fdatawrite;
167 ],[
168         AC_MSG_RESULT([yes])
169         AC_DEFINE(HAVE_FILEMAP_FDATAWRITE, 1, [filemap_fdatawrite() found])
170 ],[
171         AC_MSG_RESULT([no])
172 ])
173 ])
174
175 #
176 # LC_FUNC_DIRECT_IO
177 #
178 # if direct_IO takes a struct file argument
179 #
180 AC_DEFUN([LC_FUNC_DIRECT_IO],
181 [AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
182 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
183 if test "$HAVE_DIO_FILE" != 0 ; then
184         AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
185         AC_MSG_RESULT(yes)
186 else
187         AC_MSG_RESULT(no)
188 fi
189 ])
190
191 #
192 # LC_HEADER_MM_INLINE
193 #
194 # RHEL kernels define page_count in mm_inline.h
195 #
196 AC_DEFUN([LC_HEADER_MM_INLINE],
197 [AC_MSG_CHECKING([if kernel has mm_inline.h header])
198 LB_LINUX_TRY_COMPILE([
199         #include <linux/mm_inline.h>
200 ],[
201         #ifndef page_count
202         #error mm_inline.h does not define page_count
203         #endif
204 ],[
205         AC_MSG_RESULT([yes])
206         AC_DEFINE(HAVE_MM_INLINE, 1, [mm_inline found])
207 ],[
208         AC_MSG_RESULT([no])
209 ])
210 ])
211
212 #
213 # LC_STRUCT_INODE
214 #
215 # if inode->i_alloc_sem exists
216 #
217 AC_DEFUN([LC_STRUCT_INODE],
218 [AC_MSG_CHECKING([if struct inode has i_alloc_sem])
219 LB_LINUX_TRY_COMPILE([
220         #include <linux/fs.h>
221         #include <linux/version.h>
222 ],[
223         #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24))
224         #error "down_read_trylock broken before 2.4.24"
225         #endif
226         struct inode i;
227         return (char *)&i.i_alloc_sem - (char *)&i;
228 ],[
229         AC_MSG_RESULT([yes])
230         AC_DEFINE(HAVE_I_ALLOC_SEM, 1, [struct inode has i_alloc_sem])
231 ],[
232         AC_MSG_RESULT([no])
233 ])
234 ])
235
236 #
237 # LC_FUNC_REGISTER_CACHE
238 #
239 # if register_cache() is defined by kernel
240 #
241 AC_DEFUN([LC_FUNC_REGISTER_CACHE],
242 [AC_MSG_CHECKING([if kernel defines register_cache()])
243 LB_LINUX_TRY_COMPILE([
244         #include <linux/list.h>
245         #include <linux/cache_def.h>
246 ],[
247         struct cache_definition cache;
248 ],[
249         AC_MSG_RESULT([yes])
250         AC_DEFINE(HAVE_REGISTER_CACHE, 1, [register_cache found])
251         AC_MSG_CHECKING([if kernel expects return from cache shrink function])
252         HAVE_CACHE_RETURN_INT="`grep -c 'int.*shrink' $LINUX/include/linux/cache_def.h`"
253         if test "$HAVE_CACHE_RETURN_INT" != 0 ; then
254                 AC_DEFINE(HAVE_CACHE_RETURN_INT, 1, [kernel expects return from shrink_cache])
255                 AC_MSG_RESULT(yes)
256         else
257                 AC_MSG_RESULT(no)
258         fi
259 ],[
260         AC_MSG_RESULT([no])
261 ])
262 ])
263
264 #
265 # LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
266 #
267 # check for our patched grab_cache_page_nowait_gfp() function
268 #
269 AC_DEFUN([LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP],
270 [AC_MSG_CHECKING([if kernel defines grab_cache_page_nowait_gfp()])
271 HAVE_GCPN_GFP="`grep -c 'grab_cache_page_nowait_gfp' $LINUX/include/linux/pagemap.h`"
272 if test "$HAVE_GCPN_GFP" != 0 ; then
273         AC_DEFINE(HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP, 1,
274                 [kernel has grab_cache_page_nowait_gfp()])
275         AC_MSG_RESULT(yes)
276 else
277         AC_MSG_RESULT(no)
278 fi
279 ])
280
281 #
282 # LC_FUNC_DEV_SET_RDONLY
283 #
284 # check for the old-style dev_set_rdonly which took an extra "devno" param
285 # and can only set a single device to discard writes at one time
286 #
287 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY],
288 [AC_MSG_CHECKING([if kernel has new dev_set_rdonly])
289 LB_LINUX_TRY_COMPILE([
290         #include <linux/fs.h>
291 ],[
292         #ifndef HAVE_CLEAR_RDONLY_ON_PUT
293         #error needs to be patched by lustre kernel patches from Lustre version 1.4.3 or above.
294         #endif
295 ],[
296         AC_MSG_RESULT([yes])
297         AC_DEFINE(HAVE_DEV_SET_RDONLY, 1, [kernel has new dev_set_rdonly])
298 ],[
299         AC_MSG_RESULT([no, Linux kernel source needs to be patches by lustre 
300 kernel patches from Lustre version 1.4.3 or above.])
301 ])
302 ])
303
304 #
305 # LC_CONFIG_BACKINGFS
306 #
307 # setup, check the backing filesystem
308 #
309 AC_DEFUN([LC_CONFIG_BACKINGFS],
310 [
311 BACKINGFS="ldiskfs"
312
313 if test x$with_ldiskfs = xno ; then
314         BACKINGFS="ext3"
315
316         if test x$linux25$enable_server = xyesyes ; then
317                 AC_MSG_ERROR([ldiskfs is required for 2.6-based servers.])
318         fi
319
320         # --- Check that ext3 and ext3 xattr are enabled in the kernel
321         LC_CONFIG_EXT3([],[
322                 AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel])
323         ],[
324                 AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel])
325                 AC_MSG_WARN([This build may fail.])
326         ])
327 else
328         # ldiskfs is enabled
329         LB_DEFINE_LDISKFS_OPTIONS
330 fi #ldiskfs
331
332 AC_MSG_CHECKING([which backing filesystem to use])
333 AC_MSG_RESULT([$BACKINGFS])
334 AC_SUBST(BACKINGFS)
335 ])
336
337 #
338 # LC_CONFIG_PINGER
339 #
340 # the pinger is temporary, until we have the recovery node in place
341 #
342 AC_DEFUN([LC_CONFIG_PINGER],
343 [AC_MSG_CHECKING([whether to enable pinger support])
344 AC_ARG_ENABLE([pinger],
345         AC_HELP_STRING([--disable-pinger],
346                         [disable recovery pinger support]),
347         [],[enable_pinger='yes'])
348 AC_MSG_RESULT([$enable_pinger])
349 if test x$enable_pinger != xno ; then
350   AC_DEFINE(ENABLE_PINGER, 1, Use the Pinger)
351 fi
352 ])
353
354 #
355 # LC_CONFIG_HEALTH_CHECK_WRITE
356 #
357 # Turn off the actual write to the disk
358 #
359 AC_DEFUN([LC_CONFIG_HEALTH_CHECK_WRITE],
360 [AC_MSG_CHECKING([whether to enable a write with the health check])
361 AC_ARG_ENABLE([health_write],
362         AC_HELP_STRING([--enable-health_write],
363                         [enable disk writes when doing health check]),
364         [],[enable_health_write='no'])
365 AC_MSG_RESULT([$enable_health_write])
366 if test x$enable_health_write != xno ; then
367   AC_DEFINE(USE_HEALTH_CHECK_WRITE, 1, Write when Checking Health)
368 fi
369 ])
370
371 #
372 # LC_CONFIG_LIBLUSTRE_RECOVERY
373 #
374 AC_DEFUN([LC_CONFIG_LIBLUSTRE_RECOVERY],
375 [AC_MSG_CHECKING([whether to enable liblustre recovery support])
376 AC_ARG_ENABLE([liblustre-recovery],
377         AC_HELP_STRING([--disable-liblustre-recovery],
378                         [disable liblustre recovery support]),
379         [],[enable_liblustre_recovery='yes'])
380 AC_MSG_RESULT([$enable_liblustre_recovery])
381 if test x$enable_liblustre_recovery != xno ; then
382   AC_DEFINE(ENABLE_LIBLUSTRE_RECOVERY, 1, Liblustre Can Recover)
383 fi
384 ])
385
386 #
387 # LC_CONFIG_OBD_BUFFER_SIZE
388 #
389 # the maximum buffer size of lctl ioctls
390 #
391 AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],
392 [AC_MSG_CHECKING([maximum OBD ioctl size])
393 AC_ARG_WITH([obd-buffer-size],
394         AC_HELP_STRING([--with-obd-buffer-size=[size]],
395                         [set lctl ioctl maximum bytes (default=8192)]),
396         [
397                 OBD_BUFFER_SIZE=$with_obd_buffer_size
398         ],[
399                 OBD_BUFFER_SIZE=8192
400         ])
401 AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
402 AC_DEFINE_UNQUOTED(OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
403 ])
404
405 #
406 # LC_STRUCT_STATFS
407 #
408 # AIX does not have statfs.f_namelen
409 #
410 AC_DEFUN([LC_STRUCT_STATFS],
411 [AC_MSG_CHECKING([if struct statfs has a f_namelen field])
412 LB_LINUX_TRY_COMPILE([
413         #include <linux/vfs.h>
414 ],[
415         struct statfs sfs;
416         sfs.f_namelen = 1;
417 ],[
418         AC_MSG_RESULT([yes])
419         AC_DEFINE(HAVE_STATFS_NAMELEN, 1, [struct statfs has a namelen field])
420 ],[
421         AC_MSG_RESULT([no])
422 ])
423 ])
424
425 #
426 # LC_READLINK_SSIZE_T
427 #
428 AC_DEFUN([LC_READLINK_SSIZE_T],
429 [AC_MSG_CHECKING([if readlink returns ssize_t])
430 AC_TRY_COMPILE([
431         #include <unistd.h>
432 ],[
433         ssize_t readlink(const char *, char *, size_t);
434 ],[
435         AC_MSG_RESULT([yes])
436         AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
437 ],[
438         AC_MSG_RESULT([no])
439 ])
440 ])
441
442 AC_DEFUN([LC_FUNC_PAGE_MAPPED],
443 [AC_MSG_CHECKING([if kernel offers page_mapped])
444 LB_LINUX_TRY_COMPILE([
445         #include <linux/mm.h>
446 ],[
447         page_mapped(NULL);
448 ],[
449         AC_MSG_RESULT([yes])
450         AC_DEFINE(HAVE_PAGE_MAPPED, 1, [page_mapped found])
451 ],[
452         AC_MSG_RESULT([no])
453 ])
454 ])
455
456 AC_DEFUN([LC_STRUCT_FILE_OPS_UNLOCKED_IOCTL],
457 [AC_MSG_CHECKING([if struct file_operations has an unlocked_ioctl field])
458 LB_LINUX_TRY_COMPILE([
459         #include <linux/fs.h>
460 ],[
461         struct file_operations fops;
462         &fops.unlocked_ioctl;
463 ],[
464         AC_MSG_RESULT([yes])
465         AC_DEFINE(HAVE_UNLOCKED_IOCTL, 1, [struct file_operations has an unlock ed_ioctl field])
466 ],[
467         AC_MSG_RESULT([no])
468 ])
469 ])
470
471 AC_DEFUN([LC_FILEMAP_POPULATE],
472 [AC_MSG_CHECKING([for exported filemap_populate])
473 LB_LINUX_TRY_COMPILE([
474         #include <asm/page.h>
475         #include <linux/mm.h>
476 ],[
477        filemap_populate(NULL, 0, 0, __pgprot(0), 0, 0);
478 ],[
479         AC_MSG_RESULT([yes])
480         AC_DEFINE(HAVE_FILEMAP_POPULATE, 1, [Kernel exports filemap_populate])
481 ],[
482         AC_MSG_RESULT([no])
483 ])
484 ])
485
486 AC_DEFUN([LC_D_ADD_UNIQUE],
487 [AC_MSG_CHECKING([for d_add_unique])
488 LB_LINUX_TRY_COMPILE([
489         #include <linux/dcache.h>
490 ],[
491        d_add_unique(NULL, NULL);
492 ],[
493         AC_MSG_RESULT([yes])
494         AC_DEFINE(HAVE_D_ADD_UNIQUE, 1, [Kernel has d_add_unique])
495 ],[
496         AC_MSG_RESULT([no])
497 ])
498 ])
499
500 AC_DEFUN([LC_BIT_SPINLOCK_H],
501 [LB_CHECK_FILE([$LINUX/include/linux/bit_spinlock.h],[
502         AC_MSG_CHECKING([if bit_spinlock.h can be compiled])
503         LB_LINUX_TRY_COMPILE([
504                 #include <asm/processor.h>
505                 #include <linux/spinlock.h>
506                 #include <linux/bit_spinlock.h>
507         ],[],[
508                 AC_MSG_RESULT([yes])
509                 AC_DEFINE(HAVE_BIT_SPINLOCK_H, 1, [Kernel has bit_spinlock.h])
510         ],[
511                 AC_MSG_RESULT([no])
512         ])
513 ],
514 [])
515 ])
516
517 #
518 # LC_POSIX_ACL_XATTR
519 #
520 # If we have xattr_acl.h 
521 #
522 AC_DEFUN([LC_XATTR_ACL],
523 [LB_CHECK_FILE([$LINUX/include/linux/xattr_acl.h],[
524         AC_MSG_CHECKING([if xattr_acl.h can be compiled])
525         LB_LINUX_TRY_COMPILE([
526                 #include <linux/xattr_acl.h>
527         ],[],[
528                 AC_MSG_RESULT([yes])
529                 AC_DEFINE(HAVE_XATTR_ACL, 1, [Kernel has xattr_acl])
530         ],[
531                 AC_MSG_RESULT([no])
532         ])
533 ],
534 [])
535 ])
536
537 AC_DEFUN([LC_STRUCT_INTENT_FILE],
538 [AC_MSG_CHECKING([if struct open_intent has a file field])
539 LB_LINUX_TRY_COMPILE([
540         #include <linux/fs.h>
541         #include <linux/namei.h>
542 ],[
543         struct open_intent intent;
544         &intent.file;
545 ],[
546         AC_MSG_RESULT([yes])
547         AC_DEFINE(HAVE_FILE_IN_STRUCT_INTENT, 1, [struct open_intent has a file field])
548 ],[
549         AC_MSG_RESULT([no])
550 ])
551 ])
552
553
554 AC_DEFUN([LC_POSIX_ACL_XATTR_H],
555 [LB_CHECK_FILE([$LINUX/include/linux/posix_acl_xattr.h],[
556         AC_MSG_CHECKING([if linux/posix_acl_xattr.h can be compiled])
557         LB_LINUX_TRY_COMPILE([
558                 #include <linux/posix_acl_xattr.h>
559         ],[],[
560                 AC_MSG_RESULT([yes])
561                 AC_DEFINE(HAVE_LINUX_POSIX_ACL_XATTR_H, 1, [linux/posix_acl_xattr.h found])
562
563         ],[
564                 AC_MSG_RESULT([no])
565         ])
566 $1
567 ],[
568 AC_MSG_RESULT([no])
569 ])
570 ])
571
572 #
573 # LC_EXPORT___IGET
574 # starting from 2.6.19 linux kernel exports __iget()
575 #
576 AC_DEFUN([LC_EXPORT___IGET],
577 [LB_CHECK_SYMBOL_EXPORT([__iget],
578 [fs/inode.c],[
579         AC_DEFINE(HAVE_EXPORT___IGET, 1, [kernel exports __iget])
580 ],[
581 ])
582 ])
583
584
585 AC_DEFUN([LC_LUSTRE_VERSION_H],
586 [LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
587         rm -f "$LUSTRE/include/linux/lustre_version.h"
588 ],[
589         touch "$LUSTRE/include/linux/lustre_version.h"
590         if test x$enable_server = xyes ; then
591                 AC_MSG_WARN([Unpatched kernel detected.])
592                 AC_MSG_WARN([Lustre servers cannot be built with an unpatched kernel;])
593                 AC_MSG_WARN([disabling server build])
594                 enable_server='no'
595         fi
596 ])
597 ])
598
599 AC_DEFUN([LC_FUNC_SET_FS_PWD],
600 [LB_CHECK_SYMBOL_EXPORT([set_fs_pwd],
601 [fs/namespace.c],[
602         AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd is exported])
603 ],[
604 ])
605 ])
606
607 #
608 # LC_CAPA_CRYPTO
609 #
610 AC_DEFUN([LC_CAPA_CRYPTO],
611 [LB_LINUX_CONFIG_IM([CRYPTO],[],[
612         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO is enabled in your kernel.])
613 ])
614 LB_LINUX_CONFIG_IM([CRYPTO_HMAC],[],[
615         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_HMAC is enabled in your kernel.])
616 ])
617 LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],[
618         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_SHA1 is enabled in your kernel.])
619 ])
620 ])
621
622 m4_pattern_allow(AC_KERBEROS_V5)
623
624 #
625 # LC_CONFIG_GSS
626 #
627 # Build gss and related tools of Lustre. Currently both kernel and user space
628 # parts are depend on linux platform.
629 #
630 AC_DEFUN([LC_CONFIG_GSS],
631 [AC_MSG_CHECKING([whether to enable gss/krb5 support])
632 AC_ARG_ENABLE([gss], 
633         AC_HELP_STRING([--enable-gss], [enable gss/krb5 support]),
634         [],[enable_gss='no'])
635 AC_MSG_RESULT([$enable_gss])
636
637 if test x$enable_gss == xyes; then
638         LB_LINUX_CONFIG_IM([SUNRPC],[],[
639                 AC_MSG_ERROR([GSS require that CONFIG_SUNRPC is enabled in your kernel.])
640         ])
641         LB_LINUX_CONFIG_IM([CRYPTO_DES],[],[
642                 AC_MSG_WARN([DES support is recommended by using GSS.])
643         ])
644         LB_LINUX_CONFIG_IM([CRYPTO_MD5],[],[
645                 AC_MSG_WARN([MD5 support is recommended by using GSS.])
646         ])
647         LB_LINUX_CONFIG_IM([CRYPTO_SHA256],[],[
648                 AC_MSG_WARN([SHA256 support is recommended by using GSS.])
649         ])
650         LB_LINUX_CONFIG_IM([CRYPTO_SHA512],[],[
651                 AC_MSG_WARN([SHA512 support is recommended by using GSS.])
652         ])
653         LB_LINUX_CONFIG_IM([CRYPTO_ARC4],[],[
654                 AC_MSG_WARN([ARC4 support is recommended by using GSS.])
655         ])
656         #
657         # AES symbol is uncertain (optimized & depend on arch)
658         #
659
660         AC_CHECK_LIB(gssapi, gss_init_sec_context, [
661                 GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi"
662                 ], [
663                 AC_MSG_ERROR([libgssapi is not found, consider --disable-gss.])
664                 ], 
665         )
666
667         AC_SUBST(GSSAPI_LIBS)
668         AC_KERBEROS_V5
669 fi
670 ])
671
672 # LC_FUNC_MS_FLOCK_LOCK
673 #
674 # SLES9 kernel has MS_FLOCK_LOCK sb flag
675 #
676 AC_DEFUN([LC_FUNC_MS_FLOCK_LOCK],
677 [AC_MSG_CHECKING([if kernel has MS_FLOCK_LOCK sb flag])
678 LB_LINUX_TRY_COMPILE([
679         #include <linux/fs.h>
680 ],[
681         int flags = MS_FLOCK_LOCK;
682 ],[
683         AC_DEFINE(HAVE_MS_FLOCK_LOCK, 1,
684                 [kernel has MS_FLOCK_LOCK flag])
685         AC_MSG_RESULT([yes])
686 ],[
687         AC_MSG_RESULT([no])
688 ])
689 ])
690
691 #
692 # LC_FUNC_HAVE_CAN_SLEEP_ARG
693 #
694 # SLES9 kernel has third arg can_sleep
695 # in fs/locks.c: flock_lock_file_wait()
696 #
697 AC_DEFUN([LC_FUNC_HAVE_CAN_SLEEP_ARG],
698 [AC_MSG_CHECKING([if kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
699 LB_LINUX_TRY_COMPILE([
700         #include <linux/fs.h>
701 ],[
702         int cansleep;
703         struct file *file;
704         struct file_lock *file_lock;
705         flock_lock_file_wait(file, file_lock, cansleep);
706 ],[
707         AC_DEFINE(HAVE_CAN_SLEEP_ARG, 1,
708                 [kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
709         AC_MSG_RESULT([yes])
710 ],[
711         AC_MSG_RESULT([no])
712 ])
713 ])
714
715 #
716 # LC_FUNC_F_OP_FLOCK
717 #
718 # rhel4.2 kernel has f_op->flock field
719 #
720 AC_DEFUN([LC_FUNC_F_OP_FLOCK],
721 [AC_MSG_CHECKING([if struct file_operations has flock field])
722 LB_LINUX_TRY_COMPILE([
723         #include <linux/fs.h>
724 ],[
725         struct file_operations ll_file_operations_flock;
726         ll_file_operations_flock.flock = NULL;
727 ],[
728         AC_DEFINE(HAVE_F_OP_FLOCK, 1,
729                 [struct file_operations has flock field])
730         AC_MSG_RESULT([yes])
731 ],[
732         AC_MSG_RESULT([no])
733 ])
734 ])
735
736 #
737 # LC_TASK_PPTR
738 #
739 # task struct has p_pptr instead of parent
740 #
741 AC_DEFUN([LC_TASK_PPTR],
742 [AC_MSG_CHECKING([task p_pptr found])
743 LB_LINUX_TRY_COMPILE([
744         #include <linux/sched.h>
745 ],[
746         struct task_struct *p;
747         
748         p = p->p_pptr;
749 ],[
750         AC_MSG_RESULT([yes])
751         AC_DEFINE(HAVE_TASK_PPTR, 1, [task p_pptr found])
752 ],[
753         AC_MSG_RESULT([no])
754 ])
755 ])
756
757 #
758 # LC_FUNC_F_OP_FLOCK
759 #
760 # rhel4.2 kernel has f_op->flock field
761 #
762 AC_DEFUN([LC_FUNC_F_OP_FLOCK],
763 [AC_MSG_CHECKING([if struct file_operations has flock field])
764 LB_LINUX_TRY_COMPILE([
765         #include <linux/fs.h>
766 ],[
767         struct file_operations ll_file_operations_flock;
768         ll_file_operations_flock.flock = NULL;
769 ],[
770         AC_DEFINE(HAVE_F_OP_FLOCK, 1,
771                 [struct file_operations has flock field])
772         AC_MSG_RESULT([yes])
773 ],[
774         AC_MSG_RESULT([no])
775 ])
776 ])
777
778 # LC_INODE_I_MUTEX
779 # after 2.6.15 inode have i_mutex intead of i_sem
780 AC_DEFUN([LC_INODE_I_MUTEX],
781 [AC_MSG_CHECKING([use inode have i_mutex ])
782 LB_LINUX_TRY_COMPILE([
783         #include <linux/mutex.h>
784         #include <linux/fs.h>
785 ],[
786         struct inode i;
787
788         mutex_unlock(&i.i_mutex);
789 ],[
790         AC_MSG_RESULT(yes)
791         AC_DEFINE(HAVE_INODE_I_MUTEX, 1,
792                 [after 2.6.15 inode have i_mutex intead of i_sem])
793 ],[
794         AC_MSG_RESULT(NO)
795 ])
796 ])
797
798
799 # LC_DQUOTOFF_MUTEX
800 # after 2.6.17 dquote use mutex instead if semaphore
801 AC_DEFUN([LC_DQUOTOFF_MUTEX],
802 [AC_MSG_CHECKING([use dqonoff_mutex])
803 LB_LINUX_TRY_COMPILE([
804         #include <linux/mutex.h>
805         #include <linux/fs.h>
806         #include <linux/quota.h>
807 ],[
808         struct quota_info dq;
809
810         mutex_unlock(&dq.dqonoff_mutex);
811 ],[
812         AC_MSG_RESULT(yes)
813         AC_DEFINE(HAVE_DQUOTOFF_MUTEX, 1,
814                 [after 2.6.17 dquote use mutex instead if semaphore])
815 ],[
816         AC_MSG_RESULT(NO)
817 ])
818 ])
819  
820 #
821 # LC_STATFS_DENTRY_PARAM
822 # starting from 2.6.18 linux kernel uses dentry instead of
823 # super_block for first vfs_statfs argument
824 #
825 AC_DEFUN([LC_STATFS_DENTRY_PARAM],
826 [AC_MSG_CHECKING([first vfs_statfs parameter is dentry])
827 LB_LINUX_TRY_COMPILE([
828         #include <linux/fs.h>
829 ],[
830         int vfs_statfs(struct dentry *, struct kstatfs *);
831 ],[
832         AC_DEFINE(HAVE_STATFS_DENTRY_PARAM, 1,
833                 [first parameter of vfs_statfs is dentry])
834         AC_MSG_RESULT([yes])
835 ],[
836         AC_MSG_RESULT([no])
837 ])
838 ])
839
840 #
841 # LC_VFS_KERN_MOUNT
842 # starting from 2.6.18 kernel don't export do_kern_mount
843 # and want to use vfs_kern_mount instead.
844 #
845 AC_DEFUN([LC_VFS_KERN_MOUNT],
846 [AC_MSG_CHECKING([vfs_kern_mount exist in kernel])
847 LB_LINUX_TRY_COMPILE([
848         #include <linux/mount.h>
849 ],[
850         vfs_kern_mount(NULL, 0, NULL, NULL);
851 ],[
852         AC_DEFINE(HAVE_VFS_KERN_MOUNT, 1,
853                 [vfs_kern_mount exist in kernel])
854         AC_MSG_RESULT([yes])
855 ],[
856         AC_MSG_RESULT([no])
857 ])
858 ])
859
860
861 # LC_INVALIDATEPAGE_RETURN_INT
862 # more 2.6 api changes.  return type for the invalidatepage
863 # address_space_operation is 'void' in new kernels but 'int' in old
864 #
865 AC_DEFUN([LC_INVALIDATEPAGE_RETURN_INT],
866 [AC_MSG_CHECKING([invalidatepage has return int])
867 LB_LINUX_TRY_COMPILE([
868         #include <linux/buffer_head.h>
869 ],[
870         int rc = block_invalidatepage(NULL, 0);
871 ],[
872         AC_MSG_RESULT(yes)
873         AC_DEFINE(HAVE_INVALIDATEPAGE_RETURN_INT, 1,
874                 [Define if return type of invalidatepage should be int])
875 ],[
876         AC_MSG_RESULT(NO)
877 ])
878 ])
879
880 # LC_UMOUNTBEGIN_HAS_VFSMOUNT
881 # more 2.6 API changes. 2.6.18 umount_begin has different parameters
882 AC_DEFUN([LC_UMOUNTBEGIN_HAS_VFSMOUNT],
883 [AC_MSG_CHECKING([if umount_begin needs vfsmount parameter instead of super_block])
884 tmp_flags="$EXTRA_KCFLAGS"
885 EXTRA_KCFLAGS="-Werror"
886 LB_LINUX_TRY_COMPILE([
887         #include <linux/fs.h>
888
889         struct vfsmount;
890         static void cfg_umount_begin (struct vfsmount *v, int flags)
891         {
892                 ;
893         }
894
895         static struct super_operations cfg_super_operations = {
896                 .umount_begin   = cfg_umount_begin,
897         };
898 ],[
899         cfg_super_operations.umount_begin(NULL,0);
900 ],[
901         AC_MSG_RESULT(yes)
902         AC_DEFINE(HAVE_UMOUNTBEGIN_VFSMOUNT, 1,
903                 [Define umount_begin need second argument])
904 ],[
905         AC_MSG_RESULT(NO)
906 ])
907 EXTRA_KCFLAGS="$tmp_flags"
908 ])
909
910 # 2.6.19 API changes
911 # inode don't have i_blksize field
912 AC_DEFUN([LC_INODE_BLKSIZE],
913 [AC_MSG_CHECKING([inode has i_blksize field])
914 LB_LINUX_TRY_COMPILE([
915 #include <linux/fs.h>
916 ],[
917         struct inode i;
918         i.i_blksize = 0; 
919 ],[
920         AC_MSG_RESULT(yes)
921         AC_DEFINE(HAVE_INODE_BLKSIZE, 1,
922                 [struct inode has i_blksize field])
923 ],[
924         AC_MSG_RESULT(NO)
925 ])
926 ])
927
928 # LC_VFS_READDIR_U64_INO
929 # 2.6.19 use u64 for inode number instead of inode_t
930 AC_DEFUN([LC_VFS_READDIR_U64_INO],
931 [AC_MSG_CHECKING([check vfs_readdir need 64bit inode number])
932 tmp_flags="$EXTRA_KCFLAGS"
933 EXTRA_KCFLAGS="-Werror"
934 LB_LINUX_TRY_COMPILE([
935 #include <linux/fs.h>
936         int fillonedir(void * __buf, const char * name, int namlen, loff_t offset,
937                       u64 ino, unsigned int d_type)
938         {
939                 return 0;
940         }
941 ],[
942         filldir_t filter;
943
944         filter = fillonedir;
945         return 1;
946 ],[
947         AC_MSG_RESULT(yes)
948         AC_DEFINE(HAVE_VFS_READDIR_U64_INO, 1,
949                 [if vfs_readdir need 64bit inode number])
950 ],[
951         AC_MSG_RESULT(NO)
952 ])
953 EXTRA_KCFLAGS="$tmp_flags"
954 ])
955
956 # LC_GENERIC_FILE_WRITE
957 # 2.6.19 introduce do_sync_write instead of
958 # generic_file_write
959 AC_DEFUN([LC_GENERIC_FILE_WRITE],
960 [AC_MSG_CHECKING([use generic_file_write])
961 LB_LINUX_TRY_COMPILE([
962         #include <linux/fs.h>
963 ],[
964         int result = generic_file_read(NULL, NULL, 0, 0);
965 ],[
966         AC_MSG_RESULT(yes)
967         AC_DEFINE(HAVE_GENERIC_FILE_WRITE, 1,
968                 [use generic_file_write])
969 ],[
970         AC_MSG_RESULT(NO)
971 ])
972 ])
973
974 # LC_GENERIC_FILE_READ
975 # 2.6.19 need to use do_sync_read instead of
976 # generic_file_read
977 AC_DEFUN([LC_GENERIC_FILE_READ],
978 [AC_MSG_CHECKING([use generic_file_read])
979 LB_LINUX_TRY_COMPILE([
980         #include <linux/fs.h>
981 ],[
982         int result = generic_file_read(NULL, NULL, 0, 0);
983 ],[
984         AC_MSG_RESULT(yes)
985         AC_DEFINE(HAVE_GENERIC_FILE_READ, 1,
986                 [use generic_file_read])
987 ],[
988         AC_MSG_RESULT(NO)
989 ])
990 ])
991
992 # LC_NR_PAGECACHE
993 # 2.6.18 don't export nr_pagecahe
994 AC_DEFUN([LC_NR_PAGECACHE],
995 [AC_MSG_CHECKING([kernel export nr_pagecache])
996 LB_LINUX_TRY_COMPILE([
997         #include <linux/pagemap.h>
998 ],[
999         return atomic_read(&nr_pagecache);
1000 ],[
1001         AC_MSG_RESULT(yes)
1002         AC_DEFINE(HAVE_NR_PAGECACHE, 1,
1003                 [is kernel export nr_pagecache])
1004 ],[
1005         AC_MSG_RESULT(NO)
1006 ])
1007 ])
1008
1009 # LC_CANCEL_DIRTY_PAGE
1010 # 2.6.20 introduse cancel_dirty_page instead of 
1011 # clear_page_dirty.
1012 AC_DEFUN([LC_CANCEL_DIRTY_PAGE],
1013 [AC_MSG_CHECKING([kernel has cancel_dirty_page])
1014 LB_LINUX_TRY_COMPILE([
1015         #include <linux/page-flags.h>
1016 ],[
1017         cancel_dirty_page(NULL, 0);
1018 ],[
1019         AC_MSG_RESULT(yes)
1020         AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
1021                   [kernel has cancel_dirty_page instead of clear_page_dirty])
1022 ],[
1023         AC_MSG_RESULT(NO)
1024 ])
1025 ])
1026
1027 #
1028 # LC_PAGE_CONSTANT
1029 #
1030 # In order to support raid5 zerocopy patch, we have to patch the kernel to make
1031 # it support constant page, which means the page won't be modified during the
1032 # IO.
1033 #
1034 AC_DEFUN([LC_PAGE_CONSTANT],
1035 [AC_MSG_CHECKING([if kernel have PageConstant defined])
1036 LB_LINUX_TRY_COMPILE([
1037         #include <linux/page-flags.h>
1038 ],[
1039         #ifndef PG_constant
1040         #error "Have no raid5 zcopy patch"
1041         #endif
1042 ],[
1043         AC_MSG_RESULT(yes)
1044         AC_DEFINE(HAVE_PAGE_CONSTANT, 1, [kernel have PageConstant supported])
1045 ],[
1046         AC_MSG_RESULT(no);
1047 ])
1048 ])
1049
1050 # RHEL5 in FS-cache patch rename PG_checked flag
1051 # into PG_fs_misc
1052 AC_DEFUN([LC_PG_FS_MISC],
1053 [AC_MSG_CHECKING([kernel has PG_fs_misc])
1054 LB_LINUX_TRY_COMPILE([
1055         #include <linux/page-flags.h>
1056 ],[
1057         #ifndef PG_fs_misc
1058         #error PG_fs_misc not defined in kernel
1059         #endif
1060 ],[
1061         AC_MSG_RESULT(yes)
1062         AC_DEFINE(HAVE_PG_FS_MISC, 1,
1063                   [is kernel have PG_fs_misc])
1064 ],[
1065         AC_MSG_RESULT(NO)
1066 ])
1067 ])
1068
1069 AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
1070 [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
1071 [mm/truncate.c],[
1072 AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
1073             [kernel export truncate_complete_page])
1074 ],[
1075 ])
1076 ])
1077
1078 AC_DEFUN([LC_EXPORT_D_REHASH_COND],
1079 [LB_CHECK_SYMBOL_EXPORT([d_rehash_cond],
1080 [fs/dcache.c],[
1081 AC_DEFINE(HAVE_D_REHASH_COND, 1,
1082             [d_rehash_cond is exported by the kernel])
1083 ],[
1084 ])
1085 ])
1086
1087 AC_DEFUN([LC_EXPORT___D_REHASH],
1088 [LB_CHECK_SYMBOL_EXPORT([__d_rehash],
1089 [fs/dcache.c],[
1090 AC_DEFINE(HAVE___D_REHASH, 1,
1091             [__d_rehash is exported by the kernel])
1092 ],[
1093 ])
1094 ])
1095
1096 #
1097 # LC_VFS_INTENT_PATCHES
1098 #
1099 # check if the kernel has the VFS intent patches
1100 AC_DEFUN([LC_VFS_INTENT_PATCHES],
1101 [AC_MSG_CHECKING([if the kernel has the VFS intent patches])
1102 LB_LINUX_TRY_COMPILE([
1103         #include <linux/fs.h>
1104         #include <linux/namei.h>
1105 ],[
1106         struct nameidata nd;
1107         struct lookup_intent *it;
1108
1109         it = &nd.intent;
1110         intent_init(it, IT_OPEN);
1111         it->d.lustre.it_disposition = 0;
1112         it->d.lustre.it_data = NULL;
1113 ],[
1114         AC_MSG_RESULT([yes])
1115         AC_DEFINE(HAVE_VFS_INTENT_PATCHES, 1, [VFS intent patches are applied])
1116 ],[
1117         AC_MSG_RESULT([no])
1118 ])
1119 ])
1120
1121 #
1122 # LC_PROG_LINUX
1123 #
1124 # Lustre linux kernel checks
1125 #
1126 AC_DEFUN([LC_PROG_LINUX],
1127 [ LC_LUSTRE_VERSION_H
1128 if test x$enable_server = xyes ; then
1129         LC_CONFIG_BACKINGFS
1130 fi
1131 LC_CONFIG_PINGER
1132 LC_CONFIG_LIBLUSTRE_RECOVERY
1133 LC_CONFIG_QUOTA
1134 LC_CONFIG_HEALTH_CHECK_WRITE
1135
1136 LC_TASK_PPTR
1137 # RHEL4 pachess
1138 LC_EXPORT_TRUNCATE_COMPLETE
1139 LC_EXPORT_D_REHASH_COND
1140 LC_EXPORT___D_REHASH
1141
1142 LC_STRUCT_KIOBUF
1143 LC_FUNC_COND_RESCHED
1144 LC_FUNC_ZAP_PAGE_RANGE
1145 LC_FUNC_PDE
1146 LC_FUNC_DIRECT_IO
1147 LC_HEADER_MM_INLINE
1148 LC_STRUCT_INODE
1149 LC_FUNC_REGISTER_CACHE
1150 LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
1151 LC_FUNC_DEV_SET_RDONLY
1152 LC_FUNC_FILEMAP_FDATAWRITE
1153 LC_STRUCT_STATFS
1154 LC_FUNC_PAGE_MAPPED
1155 LC_STRUCT_FILE_OPS_UNLOCKED_IOCTL
1156 LC_FILEMAP_POPULATE
1157 LC_D_ADD_UNIQUE
1158 LC_BIT_SPINLOCK_H
1159 LC_XATTR_ACL
1160 LC_STRUCT_INTENT_FILE
1161 LC_POSIX_ACL_XATTR_H
1162 LC_FUNC_SET_FS_PWD
1163 LC_CAPA_CRYPTO
1164 LC_CONFIG_GSS
1165 LC_FUNC_MS_FLOCK_LOCK
1166 LC_FUNC_HAVE_CAN_SLEEP_ARG
1167 LC_FUNC_F_OP_FLOCK
1168 LC_QUOTA_READ
1169 LC_COOKIE_FOLLOW_LINK
1170 LC_FUNC_RCU
1171
1172 # does the kernel have VFS intent patches?
1173 LC_VFS_INTENT_PATCHES
1174
1175 # 2.6.15
1176 LC_INODE_I_MUTEX
1177
1178 # 2.6.17
1179 LC_DQUOTOFF_MUTEX
1180
1181 # 2.6.18
1182 LC_NR_PAGECACHE
1183 LC_STATFS_DENTRY_PARAM
1184 LC_VFS_KERN_MOUNT
1185 LC_INVALIDATEPAGE_RETURN_INT
1186 LC_UMOUNTBEGIN_HAS_VFSMOUNT
1187
1188 #2.6.18 + RHEL5 (fc6)
1189 LC_PG_FS_MISC
1190
1191 # 2.6.19
1192 LC_INODE_BLKSIZE
1193 LC_VFS_READDIR_U64_INO
1194 LC_GENERIC_FILE_READ
1195 LC_GENERIC_FILE_WRITE
1196
1197 # 2.6.20
1198 LC_CANCEL_DIRTY_PAGE
1199
1200 # raid5-zerocopy patch
1201 LC_PAGE_CONSTANT
1202 ])
1203
1204 #
1205 # LC_CONFIG_CLIENT_SERVER
1206 #
1207 # Build client/server sides of Lustre
1208 #
1209 AC_DEFUN([LC_CONFIG_CLIENT_SERVER],
1210 [AC_MSG_CHECKING([whether to build Lustre server support])
1211 AC_ARG_ENABLE([server],
1212         AC_HELP_STRING([--disable-server],
1213                         [disable Lustre server support]),
1214         [],[enable_server='yes'])
1215 AC_MSG_RESULT([$enable_server])
1216
1217 AC_MSG_CHECKING([whether to build Lustre client support])
1218 AC_ARG_ENABLE([client],
1219         AC_HELP_STRING([--disable-client],
1220                         [disable Lustre client support]),
1221         [],[enable_client='yes'])
1222 AC_MSG_RESULT([$enable_client])])
1223
1224 #
1225 # LC_CONFIG_LIBLUSTRE
1226 #
1227 # whether to build liblustre
1228 #
1229 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
1230 [AC_MSG_CHECKING([whether to build Lustre library])
1231 AC_ARG_ENABLE([liblustre],
1232         AC_HELP_STRING([--disable-liblustre],
1233                         [disable building of Lustre library]),
1234         [],[enable_liblustre=$with_sysio])
1235 AC_MSG_RESULT([$enable_liblustre])
1236 # only build sysio if liblustre is built
1237 with_sysio="$enable_liblustre"
1238
1239 AC_MSG_CHECKING([whether to build liblustre tests])
1240 AC_ARG_ENABLE([liblustre-tests],
1241         AC_HELP_STRING([--enable-liblustre-tests],
1242                         [enable liblustre tests, if --disable-tests is used]),
1243         [],[enable_liblustre_tests=$enable_tests])
1244 if test x$enable_liblustre != xyes ; then
1245    enable_liblustre_tests='no'
1246 fi
1247 AC_MSG_RESULT([$enable_liblustre_tests])
1248
1249 AC_MSG_CHECKING([whether to build mpitests])
1250 AC_ARG_ENABLE([mpitests],
1251         AC_HELP_STRING([--enable-mpitests],
1252                         [build liblustre mpi tests]),
1253         [],[enable_mpitests=no])
1254 AC_MSG_RESULT([$enable_mpitests])
1255
1256 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
1257 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
1258
1259 LC_CONFIG_PINGER
1260 LC_CONFIG_LIBLUSTRE_RECOVERY
1261 ])
1262
1263 #
1264 # LC_CONFIG_QUOTA
1265 #
1266 # whether to enable quota support
1267 #
1268 AC_DEFUN([LC_CONFIG_QUOTA],
1269 [AC_MSG_CHECKING([whether to disable quota support])
1270 AC_ARG_ENABLE([quota], 
1271         AC_HELP_STRING([--disable-quota],
1272                         [disable quota support]),
1273         [],[enable_quota='yes'])
1274 AC_MSG_RESULT([$enable_quota])
1275 if test x$linux25 != xyes; then
1276    enable_quota='no'
1277 fi
1278 if test x$enable_quota != xno; then
1279    AC_DEFINE(HAVE_QUOTA_SUPPORT, 1, [Enable quota support])
1280 fi
1281 ])
1282  
1283 #
1284 # LC_CONFIG_SPLIT
1285 #
1286 # whether to enable split support
1287 #
1288 AC_DEFUN([LC_CONFIG_SPLIT],
1289 [AC_MSG_CHECKING([whether to enable split support])
1290 AC_ARG_ENABLE([split], 
1291         AC_HELP_STRING([--enable-split],
1292                         [enable split support]),
1293         [],[enable_split='no'])
1294 AC_MSG_RESULT([$enable_split])
1295 if test x$enable_split != xno; then
1296    AC_DEFINE(HAVE_SPLIT_SUPPORT, 1, [enable split support])
1297 fi
1298 ])
1299  
1300 AC_DEFUN([LC_QUOTA_READ],
1301 [AC_MSG_CHECKING([if kernel supports quota_read])
1302 LB_LINUX_TRY_COMPILE([
1303         #include <linux/fs.h>
1304 ],[
1305         struct super_operations sp;
1306         void *i = (void *)sp.quota_read;
1307 ],[
1308         AC_MSG_RESULT([yes])
1309         AC_DEFINE(KERNEL_SUPPORTS_QUOTA_READ, 1, [quota_read found])
1310 ],[
1311         AC_MSG_RESULT([no])
1312 ])
1313 ])
1314
1315 #
1316 # LC_COOKIE_FOLLOW_LINK
1317 #
1318 # kernel 2.6.13+ ->follow_link returns a cookie
1319 #
1320
1321 AC_DEFUN([LC_COOKIE_FOLLOW_LINK],
1322 [AC_MSG_CHECKING([if inode_operations->follow_link returns a cookie])
1323 LB_LINUX_TRY_COMPILE([
1324         #include <linux/fs.h>
1325         #include <linux/namei.h>
1326 ],[
1327         struct dentry dentry;
1328         struct nameidata nd;
1329
1330         dentry.d_inode->i_op->put_link(&dentry, &nd, NULL);
1331 ],[
1332         AC_DEFINE(HAVE_COOKIE_FOLLOW_LINK, 1, [inode_operations->follow_link returns a cookie])
1333         AC_MSG_RESULT([yes])
1334 ],[
1335         AC_MSG_RESULT([no])
1336 ])
1337 ])
1338
1339 #
1340 # LC_FUNC_RCU
1341 #
1342 # kernels prior than 2.6.0(?) have no RCU supported; in kernel 2.6.5(SUSE), 
1343 # call_rcu takes three parameters.
1344 #
1345 AC_DEFUN([LC_FUNC_RCU],
1346 [AC_MSG_CHECKING([if kernel have RCU supported])
1347 LB_LINUX_TRY_COMPILE([
1348         #include <linux/rcupdate.h>
1349 ],[],[
1350         AC_DEFINE(HAVE_RCU, 1, [have RCU defined])
1351         AC_MSG_RESULT([yes])
1352
1353         AC_MSG_CHECKING([if call_rcu takes three parameters])
1354         LB_LINUX_TRY_COMPILE([
1355                 #include <linux/rcupdate.h>
1356         ],[
1357                 struct rcu_head rh;
1358                 call_rcu(&rh, (void (*)(struct rcu_head *))1, NULL);
1359         ],[
1360                 AC_DEFINE(HAVE_CALL_RCU_PARAM, 1, [call_rcu takes three parameters])
1361                 AC_MSG_RESULT([yes])
1362         ],[
1363                 AC_MSG_RESULT([no]) 
1364         ])
1365 ],[
1366         AC_MSG_RESULT([no])
1367 ])
1368 ])
1369
1370 #
1371 # LC_CONFIGURE
1372 #
1373 # other configure checks
1374 #
1375 AC_DEFUN([LC_CONFIGURE],
1376 [LC_CONFIG_OBD_BUFFER_SIZE
1377
1378 # include/liblustre.h
1379 AC_CHECK_HEADERS([asm/page.h sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
1380
1381 # include/lustre/lustre_user.h
1382 # See note there re: __ASM_X86_64_PROCESSOR_H
1383 AC_CHECK_HEADERS([linux/quota.h])
1384
1385 # liblustre/llite_lib.h
1386 AC_CHECK_HEADERS([xtio.h file.h])
1387
1388 # liblustre/dir.c
1389 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
1390
1391 # liblustre/lutil.c
1392 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
1393 AC_CHECK_FUNCS([inet_ntoa])
1394
1395 # libsysio/src/readlink.c
1396 LC_READLINK_SSIZE_T
1397
1398 # utils/llverfs.c
1399 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
1400
1401 # Super safe df
1402 AC_ARG_ENABLE([mindf],
1403       AC_HELP_STRING([--enable-mindf],
1404                       [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
1405       [],[])
1406 if test "$enable_mindf" = "yes" ;  then
1407       AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
1408 fi
1409
1410 AC_ARG_ENABLE([fail_alloc],
1411         AC_HELP_STRING([--disable-fail-alloc],
1412                 [disable randomly alloc failure]),
1413         [],[enable_fail_alloc=yes])
1414 AC_MSG_CHECKING([whether to randomly failing memory alloc])
1415 AC_MSG_RESULT([$enable_fail_alloc])
1416 if test x$enable_fail_alloc != xno ; then
1417         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
1418 fi
1419
1420 ])
1421
1422 #
1423 # LC_CONDITIONALS
1424 #
1425 # AM_CONDITIONALS for lustre
1426 #
1427 AC_DEFUN([LC_CONDITIONALS],
1428 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
1429 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
1430 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
1431 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
1432 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
1433 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
1434 AM_CONDITIONAL(QUOTA, test x$enable_quota = xyes)
1435 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
1436 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
1437 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
1438 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
1439 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
1440 ])
1441
1442 #
1443 # LC_CONFIG_FILES
1444 #
1445 # files that should be generated with AC_OUTPUT
1446 #
1447 AC_DEFUN([LC_CONFIG_FILES],
1448 [AC_CONFIG_FILES([
1449 lustre/Makefile
1450 lustre/autoMakefile
1451 lustre/autoconf/Makefile
1452 lustre/contrib/Makefile
1453 lustre/doc/Makefile
1454 lustre/include/Makefile
1455 lustre/include/lustre_ver.h
1456 lustre/include/linux/Makefile
1457 lustre/include/lustre/Makefile
1458 lustre/kernel_patches/targets/2.6-suse.target
1459 lustre/kernel_patches/targets/2.6-vanilla.target
1460 lustre/kernel_patches/targets/2.6-rhel4.target
1461 lustre/kernel_patches/targets/2.6-fc5.target
1462 lustre/kernel_patches/targets/2.6-patchless.target
1463 lustre/kernel_patches/targets/2.6-sles10.target
1464 lustre/ldlm/Makefile
1465 lustre/fid/Makefile
1466 lustre/fid/autoMakefile
1467 lustre/liblustre/Makefile
1468 lustre/liblustre/tests/Makefile
1469 lustre/llite/Makefile
1470 lustre/llite/autoMakefile
1471 lustre/lov/Makefile
1472 lustre/lov/autoMakefile
1473 lustre/lvfs/Makefile
1474 lustre/lvfs/autoMakefile
1475 lustre/mdc/Makefile
1476 lustre/mdc/autoMakefile
1477 lustre/lmv/Makefile
1478 lustre/lmv/autoMakefile
1479 lustre/mds/Makefile
1480 lustre/mds/autoMakefile
1481 lustre/mdt/Makefile
1482 lustre/mdt/autoMakefile
1483 lustre/cmm/Makefile
1484 lustre/cmm/autoMakefile
1485 lustre/mdd/Makefile
1486 lustre/mdd/autoMakefile
1487 lustre/fld/Makefile
1488 lustre/fld/autoMakefile
1489 lustre/obdclass/Makefile
1490 lustre/obdclass/autoMakefile
1491 lustre/obdclass/linux/Makefile
1492 lustre/obdecho/Makefile
1493 lustre/obdecho/autoMakefile
1494 lustre/obdfilter/Makefile
1495 lustre/obdfilter/autoMakefile
1496 lustre/osc/Makefile
1497 lustre/osc/autoMakefile
1498 lustre/ost/Makefile
1499 lustre/ost/autoMakefile
1500 lustre/osd/Makefile
1501 lustre/osd/autoMakefile
1502 lustre/mgc/Makefile
1503 lustre/mgc/autoMakefile
1504 lustre/mgs/Makefile
1505 lustre/mgs/autoMakefile
1506 lustre/ptlrpc/Makefile
1507 lustre/ptlrpc/autoMakefile
1508 lustre/ptlrpc/gss/Makefile
1509 lustre/ptlrpc/gss/autoMakefile
1510 lustre/quota/Makefile
1511 lustre/quota/autoMakefile
1512 lustre/scripts/Makefile
1513 lustre/scripts/version_tag.pl
1514 lustre/tests/Makefile
1515 lustre/utils/Makefile
1516 lustre/utils/gss/Makefile
1517 ])
1518 case $lb_target_os in
1519         darwin)
1520                 AC_CONFIG_FILES([ lustre/obdclass/darwin/Makefile ])
1521                 ;;
1522 esac
1523
1524 ])