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