Whamcloud - gitweb
9a347d9059c329538d295192f6236676575ba59c
[fs/lustre-release.git] / lustre / autoconf / lustre-core.m4
1 #
2 # LC_CONFIG_SRCDIR
3 #
4 # Wrapper for AC_CONFIG_SUBDIR
5 #
6 AC_DEFUN([LC_CONFIG_SRCDIR],
7 [AC_CONFIG_SRCDIR([lustre/obdclass/obdo.c])
8 libcfs_is_module=yes
9 ldiskfs_is_ext4=yes
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='$(CROSS_PATH)/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_OBD_BUFFER_SIZE
51 #
52 # the maximum buffer size of lctl ioctls
53 #
54 AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],
55 [AC_MSG_CHECKING([maximum OBD ioctl size])
56 AC_ARG_WITH([obd-buffer-size],
57         AC_HELP_STRING([--with-obd-buffer-size=[size]],
58                         [set lctl ioctl maximum bytes (default=8192)]),
59         [
60                 OBD_BUFFER_SIZE=$with_obd_buffer_size
61         ],[
62                 OBD_BUFFER_SIZE=8192
63         ])
64 AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
65 AC_DEFINE_UNQUOTED(CONFIG_LUSTRE_OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
66 ])
67
68 #
69 # LC_READLINK_SSIZE_T
70 #
71 AC_DEFUN([LC_READLINK_SSIZE_T],
72 [AC_MSG_CHECKING([if readlink returns ssize_t])
73 AC_TRY_COMPILE([
74         #include <unistd.h>
75 ],[
76         ssize_t readlink(const char *, char *, size_t);
77 ],[
78         AC_MSG_RESULT([yes])
79         AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
80 ],[
81         AC_MSG_RESULT([no])
82 ])
83 ])
84
85 AC_DEFUN([LC_GLIBC_SUPPORT_FHANDLES],
86 [AC_MSG_CHECKING([if file handle and related syscalls are supported by glibc])
87 AC_CHECK_FUNCS([name_to_handle_at
88 ],[
89         AC_MSG_RESULT([yes])
90         AC_DEFINE(HAVE_FHANDLE_GLIBC_SUPPORT, 1,
91                 [file handle and related syscalls are supported])
92 ],[
93         AC_MSG_RESULT([no])
94 ])
95 ])
96
97 #
98 # LC_FUNC_DEV_SET_RDONLY
99 #
100 # check whether dev_set_rdonly is exported.  This is needed until we
101 # have another mechanism to fence IO from the underlying device.
102 #
103 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY],
104 [LB_CHECK_SYMBOL_EXPORT([dev_set_rdonly],
105 [block/ll_rw_block.c,block/blk-core.c],[
106         AC_DEFINE(HAVE_DEV_SET_RDONLY, 1, [kernel exports dev_set_rdonly])
107 ],[
108         AC_MSG_WARN([kernel missing dev_set_rdonly patch for testing])
109 ])
110 ])
111
112 #
113 # Ensure stack size big than 8k in Lustre server (all kernels)
114 #
115 AC_DEFUN([LC_STACK_SIZE],
116 [AC_MSG_CHECKING([stack size big than 8k])
117 LB_LINUX_TRY_COMPILE([
118         #include <linux/thread_info.h>
119 ],[
120         #if THREAD_SIZE < 8192
121         #error "stack size < 8192"
122         #endif
123 ],[
124         AC_MSG_RESULT(yes)
125 ],[
126         AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 8KB stack.])
127 ])
128 ])
129
130 #
131 # Allow the user to set the MDS thread upper limit
132 #
133 AC_DEFUN([LC_MDS_MAX_THREADS],
134 [
135         AC_ARG_WITH([mds_max_threads],
136         AC_HELP_STRING([--with-mds-max-threads=count],
137                        [maximum threads available on the MDS: (default=512)]),
138         [
139                 MDS_THREAD_COUNT=$with_mds_max_threads
140                 AC_DEFINE_UNQUOTED(MDS_MAX_THREADS, $MDS_THREAD_COUNT, [maximum number of MDS threads])
141         ])
142 ])
143
144 #
145 # LC_CONFIG_PINGER
146 #
147 # the pinger is temporary, until we have the recovery node in place
148 #
149 AC_DEFUN([LC_CONFIG_PINGER],
150 [AC_MSG_CHECKING([whether to enable pinger support])
151 AC_ARG_ENABLE([pinger],
152         AC_HELP_STRING([--disable-pinger],
153                         [disable recovery pinger support]),
154         [],[enable_pinger='yes'])
155 AC_MSG_RESULT([$enable_pinger])
156 if test x$enable_pinger != xno ; then
157   AC_DEFINE(ENABLE_PINGER, 1, Use the Pinger)
158 fi
159 ])
160
161 #
162 # LC_CONFIG_CHECKSUM
163 #
164 # do checksum of bulk data between client and OST
165 #
166 AC_DEFUN([LC_CONFIG_CHECKSUM],
167 [AC_MSG_CHECKING([whether to enable data checksum support])
168 AC_ARG_ENABLE([checksum],
169        AC_HELP_STRING([--disable-checksum],
170                        [disable data checksum support]),
171        [],[enable_checksum='yes'])
172 AC_MSG_RESULT([$enable_checksum])
173 if test x$enable_checksum != xno ; then
174   AC_DEFINE(ENABLE_CHECKSUM, 1, do data checksums)
175 fi
176 ])
177
178 #
179 # LC_CONFIG_LIBLUSTRE_RECOVERY
180 #
181 AC_DEFUN([LC_CONFIG_LIBLUSTRE_RECOVERY],
182 [AC_MSG_CHECKING([whether to enable liblustre recovery support])
183 AC_ARG_ENABLE([liblustre-recovery],
184         AC_HELP_STRING([--disable-liblustre-recovery],
185                         [disable liblustre recovery support]),
186         [],[enable_liblustre_recovery='yes'])
187 AC_MSG_RESULT([$enable_liblustre_recovery])
188 if test x$enable_liblustre_recovery != xno ; then
189   AC_DEFINE(ENABLE_LIBLUSTRE_RECOVERY, 1, Liblustre Can Recover)
190 fi
191 ])
192
193 #
194 # LC_CONFIG_HEALTH_CHECK_WRITE
195 #
196 # Turn off the actual write to the disk
197 #
198 AC_DEFUN([LC_CONFIG_HEALTH_CHECK_WRITE],
199 [AC_MSG_CHECKING([whether to enable a write with the health check])
200 AC_ARG_ENABLE([health_write],
201         AC_HELP_STRING([--enable-health_write],
202                         [enable disk writes when doing health check]),
203         [],[enable_health_write='no'])
204 AC_MSG_RESULT([$enable_health_write])
205 if test x$enable_health_write != xno ; then
206   AC_DEFINE(USE_HEALTH_CHECK_WRITE, 1, Write when Checking Health)
207 fi
208 ])
209
210 AC_DEFUN([LC_CONFIG_LRU_RESIZE],
211 [AC_MSG_CHECKING([whether to enable lru self-adjusting])
212 AC_ARG_ENABLE([lru_resize],
213         AC_HELP_STRING([--enable-lru-resize],
214                         [enable lru resize support]),
215         [],[enable_lru_resize='yes'])
216 AC_MSG_RESULT([$enable_lru_resize])
217 if test x$enable_lru_resize != xno; then
218    AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])
219 fi
220 ])
221
222 #
223 # Quota support. The kernel must support CONFIG_QUOTA.
224 #
225 AC_DEFUN([LC_QUOTA_CONFIG],
226 [LB_LINUX_CONFIG_IM([QUOTA],[],[
227         AC_MSG_ERROR([Lustre quota requires that CONFIG_QUOTA is enabled in your kernel.])
228         ])
229 ])
230
231 # truncate_complete_page() has never been exported from an upstream kernel
232 # remove_from_page_cache() was exported between 2.6.35 and 2.6.38
233 # delete_from_page_cache() is exported from 2.6.39
234 AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE_PAGE],
235          [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
236                                  [mm/truncate.c],
237                                  [AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
238                                             [kernel export truncate_complete_page])])
239           LB_CHECK_SYMBOL_EXPORT([remove_from_page_cache],
240                                  [mm/filemap.c],
241                                  [AC_DEFINE(HAVE_REMOVE_FROM_PAGE_CACHE, 1,
242                                             [kernel export remove_from_page_cache])])
243           LB_CHECK_SYMBOL_EXPORT([delete_from_page_cache],
244                                  [mm/filemap.c],
245                                  [AC_DEFINE(HAVE_DELETE_FROM_PAGE_CACHE, 1,
246                                             [kernel export delete_from_page_cache])])
247          ])
248
249 #
250 # LC_CAPA_CRYPTO
251 #
252 AC_DEFUN([LC_CAPA_CRYPTO],
253 [LB_LINUX_CONFIG_IM([CRYPTO],[],[
254         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO is enabled in your kernel.])
255 ])
256 LB_LINUX_CONFIG_IM([CRYPTO_HMAC],[],[
257         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_HMAC is enabled in your kernel.])
258 ])
259 LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],[
260         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_SHA1 is enabled in your kernel.])
261 ])
262 ])
263
264 #
265 # LC_CONFIG_RMTCLIENT
266 #
267 dnl FIXME
268 dnl the AES symbol usually tied with arch, e.g. CRYPTO_AES_586
269 dnl FIXME
270 AC_DEFUN([LC_CONFIG_RMTCLIENT],
271 [LB_LINUX_CONFIG_IM([CRYPTO_AES],[],[
272         AC_MSG_WARN([Lustre remote client require that CONFIG_CRYPTO_AES is enabled in your kernel.])
273 ])
274 ])
275
276 #
277 # LC_CONFIG_GSS_KEYRING (default 'auto', tests for dependencies, if found, enables; only called if gss is enabled)
278 #
279 AC_DEFUN([LC_CONFIG_GSS_KEYRING],
280 [AC_MSG_CHECKING([whether to enable gss keyring backend])
281  AC_ARG_ENABLE([gss_keyring],
282                [AC_HELP_STRING([--disable-gss-keyring],
283                                [disable gss keyring backend])],
284                [],[enable_gss_keyring='auto'])
285  AC_MSG_RESULT([$enable_gss_keyring])
286
287  if test x$enable_gss_keyring != xno; then
288         LB_LINUX_CONFIG_IM([KEYS],[],
289                            [gss_keyring_conf_test='fail';
290                             AC_MSG_WARN([GSS keyring backend require that CONFIG_KEYS be enabled in your kernel.])])
291
292         AC_CHECK_LIB([keyutils], [keyctl_search], [],
293                      [gss_keyring_conf_test='fail';
294                       AC_MSG_WARN([libkeyutils is not found, which is required by gss keyring backend])],)
295
296         if test x$gss_keyring_conf_test != xfail; then
297                 AC_DEFINE([HAVE_GSS_KEYRING], [1], [Define this if you enable gss keyring backend])
298                 enable_gss_keyring='yes'
299         else
300                 if test x$enable_gss_keyring == xyes; then
301                         AC_MSG_ERROR([Cannot enable gss_keyring. See above for details.])
302                 else
303                         AC_MSG_WARN([Cannot enable gss keyring.  See above for details.])
304                 fi
305         fi
306  fi
307 ])
308
309 AC_DEFUN([LC_CONFIG_SUNRPC],
310 [LB_LINUX_CONFIG_IM([SUNRPC],[],
311                     [if test x$sunrpc_required == xyes; then
312                          AC_MSG_ERROR([kernel SUNRPC support is required by using GSS.])
313                      fi])
314 ])
315
316 #
317 # LC_CONFIG_GSS (default 'auto' (tests for dependencies, if found, enables))
318 #
319 # Build gss and related tools of Lustre. Currently both kernel and user space
320 # parts are depend on linux platform.
321 #
322 AC_DEFUN([LC_CONFIG_GSS],
323 [AC_MSG_CHECKING([whether to enable gss/krb5 support])
324  AC_ARG_ENABLE([gss],
325                [AC_HELP_STRING([--enable-gss], [enable gss/krb5 support])],
326                [],[enable_gss='auto'])
327  AC_MSG_RESULT([$enable_gss])
328
329  if test x$enable_gss != xno; then
330         LC_CONFIG_GSS_KEYRING
331         sunrpc_required=$enable_gss
332         LC_CONFIG_SUNRPC
333         sunrpc_required=no
334
335         LB_LINUX_CONFIG_IM([CRYPTO_MD5],[],
336                            [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
337         LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],
338                            [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
339         LB_LINUX_CONFIG_IM([CRYPTO_SHA256],[],
340                            [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
341         LB_LINUX_CONFIG_IM([CRYPTO_SHA512],[],
342                            [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
343
344         require_krb5=$enable_gss
345         AC_KERBEROS_V5
346         require_krb5=no
347
348         if test x$KRBDIR != x; then
349                 AC_CHECK_LIB([gssapi], [gss_export_lucid_sec_context],
350                              [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi";
351                               gss_conf_test='success'],
352                              [AC_CHECK_LIB([gssglue], [gss_export_lucid_sec_context],
353                                            [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssglue";
354                                             gss_conf_test='success'],
355                                            [if test x$enable_gss == xyes; then
356                                                 AC_MSG_ERROR([libgssapi or libgssglue is not found, which is required by GSS.])
357                                             else
358                                                 AC_MSG_WARN([libgssapi or libgssglue is not found, which is required by GSS.])
359                                             fi])],)
360                 AC_SUBST(GSSAPI_LIBS)
361         fi
362
363         if test x$gss_conf_test == xsuccess; then
364                 AC_DEFINE([HAVE_GSS], [1], [Define this is if you enable gss])
365                 enable_gss='yes'
366         fi
367
368  fi
369 ])
370
371 # up to v2.6.27 had a 3 arg version (inode, mask, nameidata)
372 # v2.6.27->v2.6.37 had a 2 arg version (inode, mask)
373 # v2.6.37->v3.0 had a 3 arg version (inode, mask, nameidata)
374 # v3.1 onward have a 2 arg version (inode, mask)
375 AC_DEFUN([LC_INODE_PERMISION_2ARGS],
376 [AC_MSG_CHECKING([inode_operations->permission has two args])
377 LB_LINUX_TRY_COMPILE([
378         #include <linux/fs.h>
379 ],[
380         struct inode *inode __attribute__ ((unused));
381
382         inode = NULL;
383         inode->i_op->permission(NULL, 0);
384 ],[
385         AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1,
386                   [inode_operations->permission has two args])
387         AC_MSG_RESULT([yes])
388 ],[
389         AC_MSG_RESULT([no])
390 ])
391 ])
392
393 # 2.6.32 replaces 2 functions blk_queue_max_phys_segments and blk_queue_max_hw_segments by blk_queue_max_segments
394 AC_DEFUN([LC_BLK_QUEUE_MAX_SEGMENTS],
395 [AC_MSG_CHECKING([if blk_queue_max_segments is defined])
396 LB_LINUX_TRY_COMPILE([
397         #include <linux/blkdev.h>
398 ],[
399         blk_queue_max_segments(NULL, 0);
400 ],[
401         AC_MSG_RESULT(yes)
402         AC_DEFINE(HAVE_BLK_QUEUE_MAX_SEGMENTS, 1,
403                   [blk_queue_max_segments is defined])
404 ],[
405         AC_MSG_RESULT(no)
406 ])
407 ])
408
409 # 2.6.34 has quotactl_ops->[sg]et_dqblk that take struct fs_disk_quota
410 AC_DEFUN([LC_HAVE_DQUOT_FS_DISK_QUOTA],
411 tmp_flags="$EXTRA_KCFLAGS"
412 EXTRA_KCFLAGS="-Werror"
413 [AC_MSG_CHECKING([if quotactl_ops.set_dqblk takes struct fs_disk_quota])
414 LB_LINUX_TRY_COMPILE([
415         #include <linux/fs.h>
416         #include <linux/quota.h>
417 ],[
418         ((struct quotactl_ops *)0)->set_dqblk(NULL, 0, 0, (struct fs_disk_quota*)0);
419 ],[
420         AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1, [quotactl_ops.set_dqblk takes struct fs_disk_quota])
421         AC_MSG_RESULT([yes])
422 ],[
423         AC_MSG_RESULT([no])
424         AC_MSG_CHECKING([if quotactl_ops.set_dqblk takes struct kqid & fs_disk_quota])
425         LB_LINUX_TRY_COMPILE([
426                 #include <linux/fs.h>
427                 #include <linux/quota.h>
428         ],[
429                 ((struct quotactl_ops *)0)->set_dqblk((struct super_block*)0, *((struct kqid*)0), (struct fs_disk_quota*)0);
430         ],[
431                 AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1, [quotactl_ops.set_dqblk takes struct fs_disk_quota])
432                 AC_DEFINE(HAVE_DQUOT_KQID, 1, [quotactl_ops.set_dqblk takes struct kqid])
433                 AC_MSG_RESULT([yes])
434         ],[
435                 AC_MSG_RESULT([no])
436                 AC_MSG_CHECKING([if quotactl_ops.set_dqblk takes struct kqid&fs_disk_quota])
437         ])
438 ])
439 EXTRA_KCFLAGS="$tmp_flags"
440 ])
441
442 # 2.6.34 has renamed dquot options to dquot_*, check for dquot_suspend
443 AC_DEFUN([LC_HAVE_DQUOT_SUSPEND],
444 [AC_MSG_CHECKING([if dquot_suspend is defined])
445 LB_LINUX_TRY_COMPILE([
446         #include <linux/quotaops.h>
447 ],[
448         dquot_suspend(NULL, -1);
449 ],[
450         AC_DEFINE(HAVE_DQUOT_SUSPEND, 1, [dquot_suspend is defined])
451         AC_MSG_RESULT([yes])
452 ],[
453         AC_MSG_RESULT([no])
454 ])
455 ])
456
457 #
458 # LC_QUOTA64
459 #
460 # Check if kernel has been patched for 64-bit quota limits support.
461 # The upstream version of this patch in RHEL6 2.6.32 kernels introduces
462 # the constant QFMT_VFS_V1 in include/linux/quota.h, so we can check for
463 # that in the absence of quotaio_v1.h in the kernel headers.
464 #
465 AC_DEFUN([LC_QUOTA64],[
466         AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
467 tmp_flags="$EXTRA_KCFLAGS"
468 EXTRA_KCFLAGS="-I$LINUX/fs"
469         LB_LINUX_TRY_COMPILE([
470                 #include <linux/kernel.h>
471                 #include <linux/fs.h>
472                 #if defined(HAVE_FS_QUOTA_QUOTAIO_H)
473                 # include <quota/quotaio_v2.h>
474                 struct v2r1_disk_dqblk dqblk_r1;
475                 #else
476                 #include <linux/quota.h>
477                 int ver = QFMT_VFS_V1;
478                 #endif
479         ],[],[
480                 AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
481                 AC_MSG_RESULT([yes])
482         ],[
483                 LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
484                         AC_MSG_ERROR([You have got no 64-bit kernel quota support.])
485                 ],[])
486                 AC_MSG_RESULT([no])
487         ])
488 EXTRA_KCFLAGS=$tmp_flags
489 ])
490
491 #
492 # 2.6.36 fs_struct.lock use spinlock instead of rwlock.
493 #
494 AC_DEFUN([LC_FS_STRUCT_RWLOCK],
495 [AC_MSG_CHECKING([if fs_struct.lock use rwlock])
496 LB_LINUX_TRY_COMPILE([
497         #include <asm/atomic.h>
498         #include <linux/spinlock.h>
499         #include <linux/fs_struct.h>
500 ],[
501         ((struct fs_struct *)0)->lock = (rwlock_t){ 0 };
502 ],[
503         AC_DEFINE(HAVE_FS_STRUCT_RWLOCK, 1,
504                   [fs_struct.lock use rwlock])
505         AC_MSG_RESULT([yes])
506 ],[
507         AC_MSG_RESULT([no])
508 ])
509 ])
510
511 #
512 # 2.6.36 super_operations add evict_inode method. it hybird of
513 # delete_inode & clear_inode.
514 #
515 AC_DEFUN([LC_SBOPS_EVICT_INODE],
516 [AC_MSG_CHECKING([if super_operations.evict_inode exist])
517 LB_LINUX_TRY_COMPILE([
518         #include <linux/fs.h>
519 ],[
520         ((struct super_operations *)0)->evict_inode(NULL);
521 ],[
522         AC_DEFINE(HAVE_SBOPS_EVICT_INODE, 1,
523                 [super_operations.evict_inode() is exist in kernel])
524         AC_MSG_RESULT([yes])
525 ],[
526         AC_MSG_RESULT([no])
527 ])
528 ])
529
530 #
531 # 2.6.35 file_operations.fsync taken 2 arguments.
532 # 3.0.0 file_operations.fsync takes 4 arguments.
533 #
534 AC_DEFUN([LC_FILE_FSYNC],
535 [AC_MSG_CHECKING([if file_operations.fsync takes 4 or 2 arguments])
536 LB_LINUX_TRY_COMPILE([
537         #include <linux/fs.h>
538 ],[
539         ((struct file_operations *)0)->fsync(NULL, 0, 0, 0);
540 ],[
541         AC_DEFINE(HAVE_FILE_FSYNC_4ARGS, 1,
542                 [file_operations.fsync takes 4 arguments])
543         AC_MSG_RESULT([yes, 4 args])
544 ],[
545         LB_LINUX_TRY_COMPILE([
546                 #include <linux/fs.h>
547         ],[
548            ((struct file_operations *)0)->fsync(NULL, 0);
549         ],[
550                 AC_DEFINE(HAVE_FILE_FSYNC_2ARGS, 1,
551                         [file_operations.fsync takes 2 arguments])
552                 AC_MSG_RESULT([yes, 2 args])
553         ],[
554                 AC_MSG_RESULT([no])
555         ])
556 ])
557 ])
558
559 #
560 # 2.6.37 remove kernel_locked
561 #
562 AC_DEFUN([LC_KERNEL_LOCKED],
563 [AC_MSG_CHECKING([if kernel_locked is defined])
564 LB_LINUX_TRY_COMPILE([
565         #include <linux/smp_lock.h>
566 ],[
567         kernel_locked();
568 ],[
569         AC_MSG_RESULT([yes])
570         AC_DEFINE(HAVE_KERNEL_LOCKED, 1,
571                 [kernel_locked is defined])
572 ],[
573         AC_MSG_RESULT([no])
574 ])
575 ])
576
577 #
578 # 2.6.38 dentry_operations.d_compare() taken 7 arguments.
579 #
580 AC_DEFUN([LC_D_COMPARE_7ARGS],
581 [AC_MSG_CHECKING([if d_compare taken 7 arguments])
582 LB_LINUX_TRY_COMPILE([
583         #include <linux/dcache.h>
584 ],[
585         ((struct dentry_operations*)0)->d_compare(NULL,NULL,NULL,NULL,0,NULL,NULL);
586 ],[
587         AC_DEFINE(HAVE_D_COMPARE_7ARGS, 1,
588                 [d_compare need 7 arguments])
589         AC_MSG_RESULT([yes])
590 ],[
591         AC_MSG_RESULT([no])
592 ])
593 ])
594
595 #
596 # 2.6.38 dentry_operations.d_delete() defined 'const' for 1st parameter.
597 #
598 AC_DEFUN([LC_D_DELETE_CONST],
599 [AC_MSG_CHECKING([if d_delete has const declare on first parameter])
600 tmp_flags="$EXTRA_KCFLAGS"
601 EXTRA_KCFLAGS="-Werror"
602 LB_LINUX_TRY_COMPILE([
603         #include <linux/dcache.h>
604 ],[
605         const struct dentry *d = NULL;
606         ((struct dentry_operations*)0)->d_delete(d);
607 ],[
608         AC_DEFINE(HAVE_D_DELETE_CONST, const,
609                 [d_delete first parameter declared const])
610         AC_MSG_RESULT([yes])
611 ],[
612         AC_DEFINE(HAVE_D_DELETE_CONST, , [])
613         AC_MSG_RESULT([no])
614 ])
615 EXTRA_KCFLAGS="$tmp_flags"
616 ])
617
618 #
619 # 2.6.38 dcache_lock removed. rcu-walk commited.
620 #
621 AC_DEFUN([LC_DCACHE_LOCK],
622 [AC_MSG_CHECKING([if dcache_lock is exist])
623 LB_LINUX_TRY_COMPILE([
624         #include <linux/dcache.h>
625 ],[
626         spin_lock(&dcache_lock);
627 ],[
628         AC_DEFINE(HAVE_DCACHE_LOCK, 1,
629                 [dcache_lock is exist])
630         AC_MSG_RESULT([yes])
631 ],[
632         AC_MSG_RESULT([no])
633 ])
634 ])
635
636 #
637 # 2.6.38 inode.i_rcu added.
638 #
639 AC_DEFUN([LC_INODE_I_RCU],
640 [AC_MSG_CHECKING([if inode.i_rcu exists])
641 LB_LINUX_TRY_COMPILE([
642         #include <linux/fs.h>
643 ],[
644         struct inode ino;
645         struct rcu_head rcu = {};
646         ino.i_rcu = rcu;
647 ],[
648         AC_DEFINE(HAVE_INODE_I_RCU, 1,
649                 [inode.i_rcu exists])
650         AC_MSG_RESULT([yes])
651 ],[
652         AC_MSG_RESULT([no])
653 ])
654 ])
655
656 #
657 # 2.6.38 export blkdev_get_by_dev
658 #
659 AC_DEFUN([LC_BLKDEV_GET_BY_DEV],
660 [LB_CHECK_SYMBOL_EXPORT([blkdev_get_by_dev],
661 [fs/block_dev.c],[
662 AC_DEFINE(HAVE_BLKDEV_GET_BY_DEV, 1,
663             [blkdev_get_by_dev is exported by the kernel])
664 ],[
665 ])
666 ])
667
668 #
669 # 2.6.38 export simple_setattr
670 #
671 AC_DEFUN([LC_EXPORT_SIMPLE_SETATTR],
672 [LB_CHECK_SYMBOL_EXPORT([simple_setattr],
673 [fs/libfs.c],[
674 AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
675             [simple_setattr is exported by the kernel])
676 ],[
677 ])
678 ])
679
680 #
681 # truncate callback removed since 2.6.39
682 #
683 AC_DEFUN([LC_IOP_TRUNCATE],
684 [AC_MSG_CHECKING([inode_operations has .truncate member function])
685 LB_LINUX_TRY_COMPILE([
686         #include <linux/fs.h>
687 ],[
688         ((struct inode_operations *)0)->truncate(NULL);
689 ],[
690         AC_DEFINE(HAVE_INODEOPS_TRUNCATE, 1,
691                   [inode_operations has .truncate member function])
692         AC_MSG_RESULT([yes])
693 ],[
694         AC_MSG_RESULT([no])
695 ])
696 ])
697
698 #
699 # 2.6.39 remove unplug_fn from request_queue.
700 #
701 AC_DEFUN([LC_REQUEST_QUEUE_UNPLUG_FN],
702 [AC_MSG_CHECKING([if request_queue has unplug_fn field])
703 LB_LINUX_TRY_COMPILE([
704         #include <linux/blkdev.h>
705 ],[
706         do{ }while(sizeof(((struct request_queue *)0)->unplug_fn));
707 ],[
708         AC_DEFINE(HAVE_REQUEST_QUEUE_UNPLUG_FN, 1,
709                   [request_queue has unplug_fn field])
710         AC_MSG_RESULT([yes])
711 ],[
712         AC_MSG_RESULT([no])
713 ])
714 ])
715
716 #
717 # 2.6.39 replace get_sb with mount in struct file_system_type
718 #
719 AC_DEFUN([LC_HAVE_FSTYPE_MOUNT],
720 [AC_MSG_CHECKING([if file_system_type has mount field])
721 LB_LINUX_TRY_COMPILE([
722         #include <linux/fs.h>
723 ],[
724         struct file_system_type fst;
725         void *i = (void *) fst.mount;
726 ],[
727         AC_DEFINE(HAVE_FSTYPE_MOUNT, 1,
728                 [struct file_system_type has mount field])
729         AC_MSG_RESULT([yes])
730 ],[
731         AC_MSG_RESULT([no])
732 ])
733 ])
734
735 #
736 # 2.6.39 The open_by_handle_at() and name_to_handle_at() system calls were
737 # added to Linux kernel 2.6.39.
738 # Check if client supports these functions
739 #
740 AC_DEFUN([LC_HAVE_FHANDLE_SYSCALLS],
741 [LB_LINUX_CONFIG_IM([FHANDLE],[
742         AC_DEFINE(HAVE_FHANDLE_SYSCALLS, 1,
743                 [kernel supports fhandles and related syscalls])
744 ],[])
745 ])
746
747 #
748 # 3.0 dirty_inode() has a flag parameter
749 # see kernel commit aa38572954ade525817fe88c54faebf85e5a61c0
750 #
751 AC_DEFUN([LC_DIRTY_INODE_WITH_FLAG],
752 [AC_MSG_CHECKING([if dirty_inode super_operation takes flag])
753 LB_LINUX_TRY_COMPILE([
754         #include <linux/fs.h>
755 ],[
756         struct inode *inode;
757         inode->i_sb->s_op->dirty_inode(NULL, 0);
758 ],[
759         AC_DEFINE(HAVE_DIRTY_INODE_HAS_FLAG, 1,
760                   [dirty_inode super_operation takes flag])
761         AC_MSG_RESULT([yes])
762 ],[
763         AC_MSG_RESULT([no])
764 ])
765 ])
766
767 #
768 # 2.6.38 generic_permission taken 4 parameters.
769 # in fact, it means rcu-walk aware permission bring.
770 #
771 # 3.1 generic_permission taken 2 parameters.
772 # see kernel commit 2830ba7f34ebb27c4e5b8b6ef408cd6d74860890
773 #
774 AC_DEFUN([LC_GENERIC_PERMISSION],
775 [AC_MSG_CHECKING([if generic_permission take 2 or 4 arguments])
776 LB_LINUX_TRY_COMPILE([
777         #include <linux/fs.h>
778 ],[
779         generic_permission(NULL, 0);
780 ],[
781         AC_DEFINE(HAVE_GENERIC_PERMISSION_2ARGS, 1,
782                   [generic_permission taken 2 arguments])
783         AC_MSG_RESULT([yes, 2 args])
784 ],[
785         LB_LINUX_TRY_COMPILE([
786                 #include <linux/fs.h>
787         ],[
788                 generic_permission(NULL, 0, 0, NULL);
789         ],[
790                 AC_DEFINE(HAVE_GENERIC_PERMISSION_4ARGS, 1,
791                           [generic_permission taken 4 arguments])
792                 AC_MSG_RESULT([yes, 4 args])
793         ],[
794                 AC_MSG_RESULT([no])
795         ])
796 ])
797 ])
798
799 #
800 # 3.1 renames lock-manager ops(lock_manager_operations) from fl_xxx to lm_xxx
801 # see kernel commit 8fb47a4fbf858a164e973b8ea8ef5e83e61f2e50
802 #
803 AC_DEFUN([LC_LM_XXX_LOCK_MANAGER_OPS],
804 [AC_MSG_CHECKING([if lock-manager ops renamed to lm_xxx])
805 LB_LINUX_TRY_COMPILE([
806         #include <linux/fs.h>
807 ],[
808         struct lock_manager_operations lm_ops;
809         lm_ops.lm_compare_owner = NULL;
810 ],[
811         AC_DEFINE(HAVE_LM_XXX_LOCK_MANAGER_OPS, 1,
812                   [lock-manager ops renamed to lm_xxx])
813         AC_MSG_RESULT([yes])
814 ],[
815         AC_MSG_RESULT([no])
816 ])
817 ])
818
819 #
820 # 3.1 kills inode->i_alloc_sem, use i_dio_count and inode_dio_wait/
821 #     inode_dio_done instead.
822 # see kernel commit bd5fe6c5eb9c548d7f07fe8f89a150bb6705e8e3
823 #
824 AC_DEFUN([LC_INODE_DIO_WAIT],
825 [AC_MSG_CHECKING([if inode->i_alloc_sem is killed and use inode_dio_wait/done.])
826 LB_LINUX_TRY_COMPILE([
827         #include <linux/fs.h>
828 ],[
829         inode_dio_wait((struct inode *)0);
830         inode_dio_done((struct inode *)0);
831 ],[
832         AC_DEFINE(HAVE_INODE_DIO_WAIT, 1,
833                   [inode->i_alloc_sem is killed and use inode_dio_wait/done])
834         AC_MSG_RESULT([yes])
835 ],[
836         AC_MSG_RESULT([no])
837 ])
838 ])
839
840 #
841 # 3.1 adds get_acl method to inode_operations to read ACL from disk.
842 # see kernel commit 4e34e719e457f2e031297175410fc0bd4016a085
843 #
844 AC_DEFUN([LC_IOP_GET_ACL],
845 [AC_MSG_CHECKING([inode_operations has .get_acl member function])
846 LB_LINUX_TRY_COMPILE([
847         #include <linux/fs.h>
848 ],[
849         struct inode_operations iop;
850         iop.get_acl = NULL;
851 ],[
852         AC_DEFINE(HAVE_IOP_GET_ACL, 1,
853                   [inode_operations has .get_acl member function])
854         AC_MSG_RESULT([yes])
855 ],[
856         AC_MSG_RESULT([no])
857 ])
858 ])
859
860 #
861 # 3.1 introduced generic_file_llseek_size()
862 #
863 AC_DEFUN([LC_FILE_LLSEEK_SIZE],
864         [LB_CHECK_SYMBOL_EXPORT([generic_file_llseek_size],
865         [fs/read_write.c],
866         [AC_DEFINE(HAVE_FILE_LLSEEK_SIZE, 1,
867                    [generic_file_llseek_size is exported by the kernel])])
868 ])
869
870 #
871 # 3.2 request_queue.make_request_fn defined as function returns with void
872 # see kernel commit 5a7bbad27a410350e64a2d7f5ec18fc73836c14f
873 #
874 AC_DEFUN([LC_HAVE_VOID_MAKE_REQUEST_FN],
875 [AC_MSG_CHECKING([if request_queue.make_request_fn returns void but not int])
876 LB_LINUX_TRY_COMPILE([
877         #include <linux/blkdev.h>
878 ],[
879         int ret;
880         make_request_fn         *mrf;
881         ret = mrf(NULL, NULL);
882 ],[
883         AC_MSG_RESULT([no])
884 ],[
885         AC_DEFINE(HAVE_VOID_MAKE_REQUEST_FN, 1,
886                   [request_queue.make_request_fn returns void but not int])
887         AC_MSG_RESULT([yes])
888 ])
889 ])
890
891 #
892 # 3.2 protects inode->i_nlink from direct modification
893 # see kernel commit a78ef704a8dd430225955f0709b22d4a6ba21deb
894 # at the same time adds set_nlink(), so checks set_nlink() for it.
895 #
896 AC_DEFUN([LC_HAVE_PROTECT_I_NLINK],
897 [AC_MSG_CHECKING([if inode->i_nlink is protected from direct modification])
898 LB_LINUX_TRY_COMPILE([
899         #include <linux/fs.h>
900 ],[
901         struct inode i;
902         set_nlink(&i, 1);
903 ],[
904         AC_DEFINE(HAVE_PROTECT_I_NLINK, 1,
905                   [inode->i_nlink is protected from direct modification])
906         AC_MSG_RESULT([yes])
907 ],[
908         AC_MSG_RESULT([no])
909 ])
910 ])
911
912 #
913 # 3.3 introduces migrate_mode.h and migratepage has 4 args
914 #
915 AC_DEFUN([LC_HAVE_MIGRATE_HEADER],
916 [LB_CHECK_FILE([$LINUX/include/linux/migrate.h],[
917                 AC_DEFINE(HAVE_MIGRATE_H, 1,
918                 [kernel has include/linux/migrate.h])
919 ],[LB_CHECK_FILE([$LINUX/include/linux/migrate_mode.h],[
920                 AC_DEFINE(HAVE_MIGRATE_MODE_H, 1,
921                         [kernel has include/linux/migrate_mode.h])
922 ],[
923         AC_MSG_RESULT([no])
924 ])
925 ])
926 ])
927
928 AC_DEFUN([LC_MIGRATEPAGE_4ARGS],
929 [AC_MSG_CHECKING([if address_space_operations.migratepage has 4 args])
930 LB_LINUX_TRY_COMPILE([
931         #include <linux/fs.h>
932 #ifdef HAVE_MIGRATE_H
933         #include <linux/migrate.h>
934 #elif defined(HAVE_MIGRATE_MODE_H)
935         #include <linux/migrate_mode.h>
936 #endif
937 ],[
938         struct address_space_operations aops;
939
940         aops.migratepage(NULL, NULL, NULL, MIGRATE_ASYNC);
941 ],[
942         AC_DEFINE(HAVE_MIGRATEPAGE_4ARGS, 1,
943                 [address_space_operations.migratepage has 4 args])
944         AC_MSG_RESULT([yes])
945 ],[
946         AC_MSG_RESULT([no])
947 ])
948 ])
949
950 #
951 # 3.3 switchs super_operations to use dentry as parameter (but not vfsmount)
952 # see kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4
953 #
954 AC_DEFUN([LC_SUPEROPS_USE_DENTRY],
955 [AC_MSG_CHECKING([if super_operations use dentry as parameter])
956 tmp_flags="$EXTRA_KCFLAGS"
957 EXTRA_KCFLAGS="-Werror"
958 LB_LINUX_TRY_COMPILE([
959         #include <linux/fs.h>
960         int show_options(struct seq_file *seq, struct dentry *root){
961                 return 0;
962         }
963 ],[
964         struct super_operations ops;
965         ops.show_options = show_options;
966 ],[
967         AC_DEFINE(HAVE_SUPEROPS_USE_DENTRY, 1,
968                   [super_operations use dentry as parameter])
969         AC_MSG_RESULT([yes])
970 ],[
971         AC_MSG_RESULT([no])
972 ])
973 EXTRA_KCFLAGS="$tmp_flags"
974 ])
975
976 #
977 # 3.3 switchs inode_operations to use umode_t as parameter (but not int)
978 # see kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35
979 #
980 AC_DEFUN([LC_INODEOPS_USE_UMODE_T],
981 [AC_MSG_CHECKING([if inode_operations use umode_t as parameter])
982 tmp_flags="$EXTRA_KCFLAGS"
983 EXTRA_KCFLAGS="-Werror"
984 LB_LINUX_TRY_COMPILE([
985         #include <linux/fs.h>
986         #include <linux/types.h>
987         int my_mknod(struct inode *dir, struct dentry *dchild,
988                      umode_t mode, dev_t dev)
989         {
990                 return 0;
991         }
992 ],[
993         struct inode_operations ops;
994         ops.mknod = my_mknod;
995 ],[
996         AC_DEFINE(HAVE_INODEOPS_USE_UMODE_T, 1,
997                   [inode_operations use umode_t as parameter])
998         AC_MSG_RESULT([yes])
999 ],[
1000         AC_MSG_RESULT([no])
1001 ])
1002 EXTRA_KCFLAGS="$tmp_flags"
1003 ])
1004
1005 # 3.4 kmap_atomic removes second argument
1006 # see kernel commit 1ec9c5ddc17aa398f05646abfcbaf315b544e62f
1007 #
1008 AC_DEFUN([LC_KMAP_ATOMIC_HAS_1ARG],
1009 [AC_MSG_CHECKING([if kmap_atomic has only 1 argument])
1010 LB_LINUX_TRY_COMPILE([
1011         #include <linux/highmem.h>
1012 ],[
1013         kmap_atomic(NULL);
1014 ],[
1015         AC_DEFINE(HAVE_KMAP_ATOMIC_HAS_1ARG, 1,
1016                   [have kmap_atomic has only 1 argument])
1017         AC_MSG_RESULT([yes])
1018 ],[
1019         AC_MSG_RESULT([no])
1020 ])
1021 ])
1022
1023 #
1024 # 3.4 converts d_alloc_root to d_make_root
1025 # see kernel commit 32991ab305ace7017c62f8eecbe5eb36dc32e13b
1026 #
1027 AC_DEFUN([LC_HAVE_D_MAKE_ROOT],
1028 [AC_MSG_CHECKING([if have d_make_root])
1029 LB_LINUX_TRY_COMPILE([
1030         #include <linux/fs.h>
1031 ],[
1032         d_make_root((struct inode *)NULL);
1033 ],[
1034         AC_DEFINE(HAVE_D_MAKE_ROOT, 1,
1035                   [have d_make_root])
1036         AC_MSG_RESULT([yes])
1037 ],[
1038         AC_MSG_RESULT([no])
1039 ])
1040 ])
1041
1042 #
1043 # 3.4 cache_register/cache_unregister are removed
1044 # see kernel commit 2c5f846747526e2b83c5f1b8e69016be0e2e87c0
1045 # Note, since 2.6.37 cache_register_net/cache_unregister_net
1046 # are defined, but not exported.
1047 # 3.3 cache_register_net/cache_unregister_net are
1048 # exported and replacing cache_register/cache_unregister in 3.4
1049 #
1050 AC_DEFUN([LC_HAVE_CACHE_REGISTER],
1051 [AC_MSG_CHECKING([if have cache_register])
1052 LB_LINUX_TRY_COMPILE([
1053         #include <linux/sunrpc/cache.h>
1054 ],[
1055         cache_register(NULL);
1056 ],[
1057         AC_DEFINE(HAVE_CACHE_REGISTER, 1,
1058                   [have cache_register])
1059         AC_MSG_RESULT([yes])
1060 ],[
1061         AC_MSG_RESULT([no])
1062 ])
1063 ])
1064
1065 #
1066 # 3.5 renames end_writeback() back to clear_inode()...
1067 # see kernel commit dbd5768f87ff6fb0a4fe09c4d7b6c4a24de99430
1068 #
1069 AC_DEFUN([LC_HAVE_CLEAR_INODE],
1070 [AC_MSG_CHECKING([if have clear_inode])
1071 LB_LINUX_TRY_COMPILE([
1072         #include <linux/fs.h>
1073 ],[
1074         clear_inode((struct inode *)NULL);
1075 ],[
1076         AC_DEFINE(HAVE_CLEAR_INODE, 1,
1077                   [have clear_inode])
1078         AC_MSG_RESULT([yes])
1079 ],[
1080         AC_MSG_RESULT([no])
1081 ])
1082 ])
1083
1084 #
1085 # 3.5 encode_fh has parent inode passed in directly
1086 # see kernel commit b0b0382b
1087 #
1088 AC_DEFUN([LC_HAVE_ENCODE_FH_PARENT],
1089 [AC_MSG_CHECKING([if encode_fh have parent inode as parameter])
1090 tmp_flags="$EXTRA_KCFLAGS"
1091 EXTRA_KCFLAGS="-Werror"
1092 LB_LINUX_TRY_COMPILE([
1093         #include <linux/exportfs.h>
1094         #include <linux/fs.h>
1095         #include <linux/types.h>
1096         int ll_encode_fh(struct inode *i, __u32 *a, int *b, struct inode *p)
1097         {
1098                 return 0;
1099         }
1100 ],[
1101         struct export_operations exp_op;
1102         exp_op.encode_fh = ll_encode_fh;
1103 ],[
1104         AC_DEFINE(HAVE_ENCODE_FH_PARENT, 1,
1105                   [have parent inode as parameter])
1106         AC_MSG_RESULT([yes])
1107 ],[
1108         AC_MSG_RESULT([no])
1109 ])
1110 EXTRA_KCFLAGS="$tmp_flags"
1111 ])
1112
1113 # 3.5 has generic_file_llseek_size with 5 args
1114 AC_DEFUN([LC_FILE_LLSEEK_SIZE_5ARG],
1115 [AC_MSG_CHECKING([if kernel has generic_file_llseek_size with 5 args])
1116 LB_LINUX_TRY_COMPILE([
1117         #include <linux/fs.h>
1118 ],[
1119         generic_file_llseek_size(NULL, 0, 0, 0, 0);
1120 ], [
1121         AC_MSG_RESULT([yes])
1122         AC_DEFINE(HAVE_FILE_LLSEEK_SIZE_5ARGS, 1,
1123                 [kernel has generic_file_llseek_size with 5 args])
1124 ],[
1125         AC_MSG_RESULT([no])
1126 ])
1127 ])
1128
1129 #
1130 # 3.6 switch i_dentry/d_alias from list to hlist
1131 #
1132 AC_DEFUN([LC_HAVE_DENTRY_D_ALIAS_HLIST],
1133 [AC_MSG_CHECKING([if i_dentry/d_alias uses hlist])
1134 tmp_flags="$EXTRA_KCFLAGS"
1135 EXTRA_KCFLAGS="-Werror"
1136 LB_LINUX_TRY_COMPILE([
1137         #include <linux/fs.h>
1138         #include <linux/list.h>
1139 ],[
1140         struct inode inode;
1141         struct dentry dentry;
1142         struct hlist_head head;
1143         struct hlist_node node;
1144         inode.i_dentry = head;
1145         dentry.d_alias = node;
1146 ],[
1147         AC_DEFINE(HAVE_DENTRY_D_ALIAS_HLIST, 1,
1148                   [have i_dentry/d_alias uses hlist])
1149         AC_MSG_RESULT([yes])
1150 ],[
1151         AC_MSG_RESULT([no])
1152 ])
1153 EXTRA_KCFLAGS="$tmp_flags"
1154 ])
1155
1156 #
1157 # 3.6 dentry_open uses struct path as first argument
1158 # see kernel commit 765927b2
1159 #
1160 AC_DEFUN([LC_DENTRY_OPEN_USE_PATH],
1161 [AC_MSG_CHECKING([if dentry_open uses struct path as first argument])
1162 tmp_flags="$EXTRA_KCFLAGS"
1163 EXTRA_KCFLAGS="-Werror"
1164 LB_LINUX_TRY_COMPILE([
1165         #include <linux/fs.h>
1166         #include <linux/path.h>
1167 ],[
1168         struct path path;
1169         dentry_open(&path, 0, NULL);
1170 ],[
1171         AC_DEFINE(HAVE_DENTRY_OPEN_USE_PATH, 1,
1172                   [dentry_open uses struct path as first argument])
1173         AC_MSG_RESULT([yes])
1174 ],[
1175         AC_MSG_RESULT([no])
1176 ])
1177 EXTRA_KCFLAGS="$tmp_flags"
1178 ])
1179
1180 #
1181 # 3.6 vfs adds iop->atomic_open
1182 #
1183 AC_DEFUN([LC_HAVE_IOP_ATOMIC_OPEN],
1184 [AC_MSG_CHECKING([if iop has atomic_open])
1185 LB_LINUX_TRY_COMPILE([
1186         #include <linux/fs.h>
1187 ],[
1188         struct inode_operations iop;
1189         iop.atomic_open = NULL;
1190 ],[
1191         AC_DEFINE(HAVE_IOP_ATOMIC_OPEN, 1,
1192                   [have iop atomic_open])
1193         AC_MSG_RESULT([yes])
1194 ],[
1195         AC_MSG_RESULT([no])
1196 ])
1197 ])
1198
1199 #
1200 # 3.7 posix_acl_{to,from}_xattr take struct user_namespace
1201 #
1202 AC_DEFUN([LC_HAVE_POSIXACL_USER_NS],
1203 [AC_MSG_CHECKING([if posix_acl_to_xattr takes struct user_namespace])
1204 LB_LINUX_TRY_COMPILE([
1205         #include <linux/fs.h>
1206         #include <linux/posix_acl_xattr.h>
1207 ],[
1208         posix_acl_to_xattr((struct user_namespace *)NULL, NULL, NULL, 0);
1209 ],[
1210         AC_DEFINE(HAVE_POSIXACL_USER_NS, 1,
1211                   [posix_acl_to_xattr takes struct user_namespace])
1212         AC_MSG_RESULT([yes])
1213 ],[
1214         AC_MSG_RESULT([no])
1215 ])
1216 ])
1217
1218 #
1219 # 3.8 struct file has new member f_inode
1220 #
1221 AC_DEFUN([LC_HAVE_FILE_F_INODE],
1222 [AC_MSG_CHECKING([if struct file has memeber f_inode])
1223 LB_LINUX_TRY_COMPILE([
1224         #include <linux/fs.h>
1225 ],[
1226         ((struct file *)0)->f_inode = NULL;
1227 ],[
1228         AC_DEFINE(HAVE_FILE_F_INODE, 1,
1229                   [struct file has memeber f_inode])
1230         AC_MSG_RESULT([yes])
1231 ],[
1232         AC_MSG_RESULT([no])
1233 ])
1234 ])
1235
1236 AC_DEFUN([LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS],
1237 [AC_MSG_CHECKING([if sunrpc_cache_pipe_upcall takes 3 args])
1238 LB_LINUX_TRY_COMPILE([
1239         #include <linux/sunrpc/cache.h>
1240 ],[
1241         sunrpc_cache_pipe_upcall(NULL, NULL, NULL);
1242 ],[
1243         AC_DEFINE(HAVE_SUNRPC_UPCALL_HAS_3ARGS, 1,
1244                 [sunrpc_cache_pipe_upcall takes 3 args])
1245         AC_MSG_RESULT([yes])
1246 ],[
1247         AC_MSG_RESULT([no])
1248 ])
1249 ])
1250
1251 #
1252 # 3.9 uses hlist_for_each_entry with 3 args
1253 # b67bfe0d42cac56c512dd5da4b1b347a23f4b70a
1254 #
1255 AC_DEFUN([LC_HAVE_HLIST_FOR_EACH_3ARG],
1256 [AC_MSG_CHECKING([if hlist_for_each_entry has 3 args])
1257 LB_LINUX_TRY_COMPILE([
1258         #include <linux/list.h>
1259         #include <linux/fs.h>
1260 ],[
1261         struct inode *inode;
1262         struct dentry *dentry;
1263         hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) {
1264                 continue;
1265         }
1266 ],[
1267         AC_DEFINE(HAVE_HLIST_FOR_EACH_3ARG, 1, [3 args])
1268         AC_MSG_RESULT([yes])
1269 ],[
1270         AC_MSG_RESULT([no])
1271 ])
1272 ])
1273
1274 #
1275 # 3.10+ only supports procfs seq_files handling
1276 #
1277 AC_DEFUN([LC_HAVE_ONLY_PROCFS_SEQ],
1278 [AC_MSG_CHECKING([if procfs only supports using seq_files])
1279 LB_LINUX_TRY_COMPILE([
1280         #include <linux/proc_fs.h>
1281 ],[
1282         ((struct proc_dir_entry *)0)->write_proc(NULL, NULL, 0, NULL);
1283 ],[
1284         AC_MSG_RESULT([no])
1285 ],[
1286         AC_DEFINE(HAVE_ONLY_PROCFS_SEQ, 1, [only seq_files supported])
1287         AC_MSG_RESULT([yes])
1288 ])
1289 ])
1290
1291 # 3.10 release for block device doesn't return int
1292 AC_DEFUN([LC_BLKDEV_RELEASE_RETURN_INT],
1293 [AC_MSG_CHECKING([if block_device_operations release returns int])
1294 LB_LINUX_TRY_COMPILE([
1295         #include <linux/blkdev.h>
1296 ],[
1297         struct block_device_operations fops;
1298         int i __attribute__ ((unused));
1299
1300         i = fops.release(NULL,0);
1301 ],[
1302         AC_MSG_RESULT([yes])
1303         AC_DEFINE(HAVE_BLKDEV_RELEASE_RETURN_INT, 1,
1304                   [block device release returns int])
1305 ],[
1306         AC_MSG_RESULT([no])
1307 ])
1308 ])
1309
1310 #
1311 # 3.11 invalidatepage requires the length of the range to invalidate
1312 #
1313 AC_DEFUN([LC_INVALIDATE_RANGE],
1314 [AC_MSG_CHECKING([if address_space_operations.invalidatepage requires 3 arguments])
1315 LB_LINUX_TRY_COMPILE([
1316         #include <linux/fs.h>
1317 ],[
1318         struct address_space_operations a_ops;
1319
1320         a_ops.invalidatepage(NULL,0,0);
1321 ],[
1322         AC_DEFINE(HAVE_INVALIDATE_RANGE, 1, [address_space_operations.invalidatepage needs 3 arguments])
1323         AC_MSG_RESULT([yes])
1324 ],[
1325         AC_MSG_RESULT([no])
1326 ])
1327 ])
1328
1329 #
1330 # 3.11 readdir now takes the new struct dir_context
1331 #
1332 AC_DEFUN([LC_HAVE_DIR_CONTEXT],
1333 [AC_MSG_CHECKING([if dir_context exist])
1334 LB_LINUX_TRY_COMPILE([
1335         #include <linux/fs.h>
1336 ],[
1337         struct dir_context ctx;
1338
1339         ctx.pos = 0;
1340 ],[
1341         AC_DEFINE(HAVE_DIR_CONTEXT, 1, [dir_context exist])
1342         AC_MSG_RESULT([yes])
1343 ],[
1344         AC_MSG_RESULT([no])
1345 ])
1346 ])
1347
1348 #
1349 # 3.11 dentry_operations.d_compare() taken 5 arguments.
1350 #
1351 AC_DEFUN([LC_D_COMPARE_5ARGS],
1352 [AC_MSG_CHECKING([if d_compare taken 5 arguments])
1353 LB_LINUX_TRY_COMPILE([
1354         #include <linux/dcache.h>
1355 ],[
1356         ((struct dentry_operations*)0)->d_compare(NULL,NULL,0,NULL,NULL);
1357 ],[
1358         AC_DEFINE(HAVE_D_COMPARE_5ARGS, 1,
1359                 [d_compare need 5 arguments])
1360         AC_MSG_RESULT([yes])
1361 ],[
1362         AC_MSG_RESULT([no])
1363 ])
1364 ])
1365
1366 #
1367 # 3.11 need to access d_count to get dentry reference count
1368 #
1369 AC_DEFUN([LC_HAVE_DCOUNT],
1370 [AC_MSG_CHECKING([if d_count exist])
1371 LB_LINUX_TRY_COMPILE([
1372         #include <linux/dcache.h>
1373 ],[
1374         struct dentry de;
1375
1376         d_count(&de);
1377 ],[
1378         AC_DEFINE(HAVE_D_COUNT, 1, [d_count exist])
1379         AC_MSG_RESULT([yes])
1380 ],[
1381         AC_MSG_RESULT([no])
1382 ])
1383 ])
1384
1385 #
1386 # 3.12 truncate_pagecache without oldsize parameter
1387 #
1388 AC_DEFUN([LC_OLDSIZE_TRUNCATE_PAGECACHE],
1389 [AC_MSG_CHECKING([if truncate_pagecache with old_size parameter])
1390 LB_LINUX_TRY_COMPILE([
1391         #include <linux/mm.h>
1392 ],[
1393         truncate_pagecache(NULL, 0, 0);
1394 ],[
1395         AC_DEFINE(HAVE_OLDSIZE_TRUNCATE_PAGECACHE, 1, [with oldsize])
1396         AC_MSG_RESULT([yes])
1397 ],[
1398         AC_MSG_RESULT([no])
1399 ])
1400 ])
1401
1402 #
1403 # 3.12 ki_left removed from struct kiocb
1404 #
1405 AC_DEFUN([LC_KIOCB_KI_LEFT],
1406 [AC_MSG_CHECKING([if struct kiocb with ki_left member])
1407 LB_LINUX_TRY_COMPILE([
1408         #include <linux/aio.h>
1409 ],[
1410         ((struct kiocb*)0)->ki_left = 0;
1411 ],[
1412         AC_DEFINE(HAVE_KIOCB_KI_LEFT, 1, [ki_left exist])
1413         AC_MSG_RESULT([yes])
1414 ],[
1415         AC_MSG_RESULT([no])
1416 ])
1417 ])
1418
1419 #
1420 # LC_PROG_LINUX
1421 #
1422 # Lustre linux kernel checks
1423 #
1424 AC_DEFUN([LC_PROG_LINUX],
1425          [
1426          LC_CONFIG_PINGER
1427          LC_CONFIG_CHECKSUM
1428          LC_CONFIG_LIBLUSTRE_RECOVERY
1429          LC_CONFIG_HEALTH_CHECK_WRITE
1430          LC_CONFIG_LRU_RESIZE
1431          LC_LLITE_LLOOP_MODULE
1432
1433          LC_GLIBC_SUPPORT_FHANDLES
1434          LC_CAPA_CRYPTO
1435          LC_CONFIG_RMTCLIENT
1436          LC_CONFIG_GSS
1437
1438          # 2.6.32
1439          LC_BLK_QUEUE_MAX_SEGMENTS
1440
1441          # 2.6.34
1442          LC_HAVE_DQUOT_FS_DISK_QUOTA
1443          LC_HAVE_DQUOT_SUSPEND
1444
1445          # 2.6.35, 3.0.0
1446          LC_FILE_FSYNC
1447          LC_EXPORT_SIMPLE_SETATTR
1448          LC_EXPORT_TRUNCATE_COMPLETE_PAGE
1449
1450          # 2.6.36
1451          LC_FS_STRUCT_RWLOCK
1452          LC_SBOPS_EVICT_INODE
1453
1454          # 2.6.37
1455          LC_KERNEL_LOCKED
1456
1457          # 2.6.38
1458          LC_BLKDEV_GET_BY_DEV
1459          LC_GENERIC_PERMISSION
1460          LC_DCACHE_LOCK
1461          LC_INODE_I_RCU
1462          LC_D_COMPARE_7ARGS
1463          LC_D_DELETE_CONST
1464
1465          # 2.6.39
1466          LC_REQUEST_QUEUE_UNPLUG_FN
1467          LC_HAVE_FHANDLE_SYSCALLS
1468          LC_HAVE_FSTYPE_MOUNT
1469          LC_IOP_TRUNCATE
1470
1471          # 3.0
1472          LC_DIRTY_INODE_WITH_FLAG
1473
1474          # 3.1
1475          LC_LM_XXX_LOCK_MANAGER_OPS
1476          LC_INODE_DIO_WAIT
1477          LC_IOP_GET_ACL
1478          LC_FILE_LLSEEK_SIZE
1479          LC_INODE_PERMISION_2ARGS
1480
1481          # 3.2
1482          LC_HAVE_VOID_MAKE_REQUEST_FN
1483          LC_HAVE_PROTECT_I_NLINK
1484
1485          # 3.3
1486          LC_HAVE_MIGRATE_HEADER
1487          LC_MIGRATEPAGE_4ARGS
1488          LC_SUPEROPS_USE_DENTRY
1489          LC_INODEOPS_USE_UMODE_T
1490          LC_HAVE_CACHE_REGISTER
1491
1492          # 3.4
1493          LC_HAVE_D_MAKE_ROOT
1494          LC_KMAP_ATOMIC_HAS_1ARG
1495
1496          # 3.5
1497          LC_HAVE_CLEAR_INODE
1498          LC_HAVE_ENCODE_FH_PARENT
1499          LC_FILE_LLSEEK_SIZE_5ARG
1500
1501          # 3.6
1502          LC_HAVE_DENTRY_D_ALIAS_HLIST
1503          LC_DENTRY_OPEN_USE_PATH
1504          LC_HAVE_IOP_ATOMIC_OPEN
1505
1506          # 3.7
1507          LC_HAVE_POSIXACL_USER_NS
1508
1509          # 3.8
1510          LC_HAVE_FILE_F_INODE
1511          LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
1512
1513          # 3.9
1514          LC_HAVE_HLIST_FOR_EACH_3ARG
1515
1516          # 3.10
1517          LC_HAVE_ONLY_PROCFS_SEQ
1518          LC_BLKDEV_RELEASE_RETURN_INT
1519
1520          # 3.11
1521          LC_INVALIDATE_RANGE
1522          LC_HAVE_DIR_CONTEXT
1523          LC_D_COMPARE_5ARGS
1524          LC_HAVE_DCOUNT
1525
1526          # 3.12
1527          LC_OLDSIZE_TRUNCATE_PAGECACHE
1528          LC_KIOCB_KI_LEFT
1529
1530          #
1531          if test x$enable_server != xno ; then
1532                 LC_FUNC_DEV_SET_RDONLY
1533                 LC_STACK_SIZE
1534                 LC_QUOTA64
1535                 LC_QUOTA_CONFIG
1536          fi
1537 ])
1538
1539 #
1540 # LC_CONFIG_CLIENT
1541 #
1542 # Check whether to build the client side of Lustre
1543 #
1544 AC_DEFUN([LC_CONFIG_CLIENT],
1545 [AC_MSG_CHECKING([whether to build Lustre client support])
1546 AC_ARG_ENABLE([client],
1547         AC_HELP_STRING([--disable-client],
1548                         [disable Lustre client support]),
1549         [],[enable_client='yes'])
1550 AC_MSG_RESULT([$enable_client])
1551 ])
1552
1553 #
1554 # LC_CONFIG_LIBLUSTRE
1555 #
1556 # whether to build liblustre
1557 #
1558 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
1559 [AC_MSG_CHECKING([whether to build Lustre library])
1560 AC_ARG_ENABLE([liblustre],
1561         AC_HELP_STRING([--disable-liblustre],
1562                         [disable building of Lustre library]),
1563         [],[enable_liblustre=$with_sysio])
1564 AC_MSG_RESULT([$enable_liblustre])
1565 # only build sysio if liblustre is built
1566 with_sysio="$enable_liblustre"
1567
1568 AC_MSG_CHECKING([whether to build liblustre tests])
1569 AC_ARG_ENABLE([liblustre-tests],
1570         AC_HELP_STRING([--enable-liblustre-tests],
1571                         [enable liblustre tests, if --disable-tests is used]),
1572         [],[enable_liblustre_tests=$enable_tests])
1573 if test x$enable_liblustre != xyes ; then
1574    enable_liblustre_tests='no'
1575 fi
1576 AC_MSG_RESULT([$enable_liblustre_tests])
1577
1578 AC_MSG_CHECKING([whether to enable liblustre acl])
1579 AC_ARG_ENABLE([liblustre-acl],
1580         AC_HELP_STRING([--disable-liblustre-acl],
1581                         [disable ACL support for liblustre]),
1582         [],[enable_liblustre_acl=yes])
1583 AC_MSG_RESULT([$enable_liblustre_acl])
1584 if test x$enable_liblustre_acl = xyes ; then
1585   AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
1586 fi
1587
1588 #
1589 # --enable-mpitest
1590 #
1591 AC_ARG_ENABLE(mpitests,
1592         AC_HELP_STRING([--enable-mpitests=yes|no|mpicc wrapper],
1593                            [include mpi tests]),
1594         [
1595          enable_mpitests=yes
1596          case $enableval in
1597          yes)
1598                 MPICC_WRAPPER=mpicc
1599                 ;;
1600          no)
1601                 enable_mpitests=no
1602                 ;;
1603          *)
1604                 MPICC_WRAPPER=$enableval
1605                  ;;
1606          esac
1607         ],
1608         [
1609         MPICC_WRAPPER=mpicc
1610         enable_mpitests=yes
1611         ]
1612 )
1613
1614 if test x$enable_mpitests != xno; then
1615         AC_MSG_CHECKING([whether mpitests can be built])
1616         oldcc=$CC
1617         CC=$MPICC_WRAPPER
1618         AC_LINK_IFELSE(
1619             [AC_LANG_PROGRAM([[
1620                     #include <mpi.h>
1621                 ]],[[
1622                     int flag;
1623                     MPI_Initialized(&flag);
1624                 ]])],
1625             [
1626                     AC_MSG_RESULT([yes])
1627             ],[
1628                     AC_MSG_RESULT([no])
1629                     enable_mpitests=no
1630         ])
1631         CC=$oldcc
1632 fi
1633 AC_SUBST(MPICC_WRAPPER)
1634
1635 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
1636 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
1637
1638 LC_CONFIG_PINGER
1639 LC_CONFIG_LIBLUSTRE_RECOVERY
1640 ])
1641
1642 #
1643 # LC_CONFIG_QUOTA
1644 #
1645 # whether to enable quota support global control
1646 #
1647 AC_DEFUN([LC_CONFIG_QUOTA],
1648 [AC_ARG_ENABLE([quota],
1649         AC_HELP_STRING([--enable-quota],
1650                         [enable quota support]),
1651         [],[enable_quota='yes'])
1652 ])
1653
1654 AC_DEFUN([LC_QUOTA],
1655 [#check global
1656 LC_CONFIG_QUOTA
1657 #check for utils
1658 if test x$enable_quota != xno -a x$enable_utils != xno; then
1659 AC_CHECK_HEADER(sys/quota.h,
1660                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1, [Define to 1 if you have <sys/quota.h>.])],
1661                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
1662 fi
1663 ])
1664
1665 #
1666 # LC_CONFIG_SPLIT
1667 #
1668 # whether to enable split support
1669 #
1670 AC_DEFUN([LC_CONFIG_SPLIT],
1671 [AC_MSG_CHECKING([whether to enable split support])
1672 AC_ARG_ENABLE([split],
1673         AC_HELP_STRING([--enable-split],
1674                         [enable split support]),
1675         [],[enable_split='no'])
1676 AC_MSG_RESULT([$enable_split])
1677 if test x$enable_split != xno; then
1678    AC_DEFINE(HAVE_SPLIT_SUPPORT, 1, [enable split support])
1679 fi
1680 ])
1681
1682 #
1683 # LC_CONFIG_NODEMAP_PROC_DEBUG
1684 #
1685 # enable nodemap proc file debugging
1686 #
1687 AC_DEFUN([LC_NODEMAP_PROC_DEBUG],
1688 [AC_MSG_CHECKING([whether to enable nodemap proc debug])
1689 AC_ARG_ENABLE([nodemap_proc_debug],
1690         AC_HELP_STRING([--enable-nodemap-proc-debug],
1691                         [enable nodemap proc debug]),
1692         [],[enable_nodemap_proc_debug='no'])
1693 AC_MSG_RESULT([$enable_nodemap_proc_debug])
1694 if test x$enable_nodemap_proc_debug != xno; then
1695    AC_DEFINE(NODEMAP_PROC_DEBUG, 1, [enable nodemap proc debug support])
1696 fi
1697 ])
1698
1699 #
1700 # LC_LLITE_LLOOP_MODULE
1701 # lloop_llite.ko does not currently work with page sizes
1702 # of 64k or larger.
1703 #
1704 AC_DEFUN([LC_LLITE_LLOOP_MODULE],
1705 [AC_MSG_CHECKING([whether to enable llite_lloop module])
1706 LB_LINUX_TRY_COMPILE([
1707         #include <asm/page.h>
1708 ],[
1709         #if PAGE_SIZE >= 65536
1710         #error "PAGE_SIZE >= 65536"
1711         #endif
1712 ],[
1713         enable_llite_lloop_module='yes'
1714         AC_MSG_RESULT([yes])
1715 ],[
1716         enable_llite_lloop_module='no'
1717         AC_MSG_RESULT([no])
1718 ])
1719 ])
1720
1721 #
1722 # LC_OSD_ADDON
1723 #
1724 # configure support for optional OSD implementation
1725 #
1726 AC_DEFUN([LC_OSD_ADDON],
1727 [AC_MSG_CHECKING([for osd])
1728 AC_ARG_WITH([osd],
1729         AC_HELP_STRING([--with-osd=path],
1730                        [set path to optional osd]),
1731         [
1732                 case $with_osd in
1733                         no)     ENABLEOSDADDON=0
1734                                 ;;
1735                         *)      OSDADDON="${with_osd}"
1736                                 ENABLEOSDADDON=1
1737                                 ;;
1738                 esac
1739         ], [
1740                 ENABLEOSDADDON=0
1741         ])
1742 if test $ENABLEOSDADDON -eq 0; then
1743         AC_MSG_RESULT([no])
1744         OSDADDON=
1745 else
1746         OSDMODNAME=`basename $OSDADDON`
1747         if test -e $LUSTRE/$OSDMODNAME; then
1748                 AC_MSG_RESULT([can't link])
1749                 OSDADDON=
1750         elif ln -s $OSDADDON $LUSTRE/$OSDMODNAME; then
1751                 AC_MSG_RESULT([$OSDMODNAME])
1752                 OSDADDON="subdir-m += $OSDMODNAME"
1753         else
1754                 AC_MSG_RESULT([can't link])
1755                 OSDADDON=
1756         fi
1757 fi
1758 AC_SUBST(OSDADDON)
1759 ])
1760
1761 #
1762 # LC_CONFIGURE
1763 #
1764 # other configure checks
1765 #
1766 AC_DEFUN([LC_CONFIGURE],
1767 [LC_CONFIG_OBD_BUFFER_SIZE
1768
1769 if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
1770         CFLAGS="$CFLAGS -Werror"
1771 fi
1772
1773 # maximum MDS thread count
1774 LC_MDS_MAX_THREADS
1775
1776 # include/liblustre.h
1777 AC_CHECK_HEADERS([sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
1778
1779 # liblustre/llite_lib.h
1780 AC_CHECK_HEADERS([xtio.h file.h])
1781
1782 # liblustre/dir.c
1783 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
1784
1785 # liblustre/lutil.c
1786 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
1787 AC_CHECK_FUNCS([inet_ntoa])
1788
1789 # libsysio/src/readlink.c
1790 LC_READLINK_SSIZE_T
1791
1792 # libcfs prng.c - depends on linux/types.h from liblustre/dir.c
1793 AC_CHECK_HEADERS([linux/random.h], [], [],
1794                  [#ifdef HAVE_LINUX_TYPES_H
1795                   # include <linux/types.h>
1796                   #endif
1797                  ])
1798
1799 # utils/llverfs.c
1800 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
1801
1802 # check for -lz support
1803 ZLIB=""
1804 AC_CHECK_LIB([z],
1805              [adler32],
1806              [AC_CHECK_HEADERS([zlib.h],
1807                                [ZLIB="-lz"
1808                                 AC_DEFINE([HAVE_ADLER], 1,
1809                                           [support alder32 checksum type])],
1810                                [AC_MSG_WARN([No zlib-devel package found,
1811                                              unable to use adler32 checksum])])],
1812              [AC_MSG_WARN([No zlib package found, unable to use adler32 checksum])]
1813 )
1814 AC_SUBST(ZLIB)
1815
1816 SELINUX=""
1817 AC_CHECK_LIB([selinux],
1818                 [is_selinux_enabled],
1819                 [AC_CHECK_HEADERS([selinux.h],
1820                                 [SELINUX="-lselinux"
1821                                 AC_DEFINE([HAVE_SELINUX], 1,
1822                                                 [support for selinux ])],
1823                                 [AC_MSG_WARN([No selinux-devel package found,
1824                                                 unable to build selinux enabled
1825                                                 tools])])],
1826                 [AC_MSG_WARN([No selinux package found, unable to build selinux
1827                                 enabled tools])]
1828 )
1829 AC_SUBST(SELINUX)
1830
1831 # Super safe df
1832 AC_ARG_ENABLE([mindf],
1833       AC_HELP_STRING([--enable-mindf],
1834                       [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
1835       [],[])
1836 if test "$enable_mindf" = "yes" ;  then
1837       AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
1838 fi
1839
1840 AC_ARG_ENABLE([fail_alloc],
1841         AC_HELP_STRING([--disable-fail-alloc],
1842                 [disable randomly alloc failure]),
1843         [],[enable_fail_alloc=yes])
1844 AC_MSG_CHECKING([whether to randomly failing memory alloc])
1845 AC_MSG_RESULT([$enable_fail_alloc])
1846 if test x$enable_fail_alloc != xno ; then
1847         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
1848 fi
1849
1850 AC_ARG_ENABLE([invariants],
1851         AC_HELP_STRING([--enable-invariants],
1852                 [enable invariant checking (cpu intensive)]),
1853         [],[])
1854 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
1855 AC_MSG_RESULT([$enable_invariants])
1856 if test x$enable_invariants = xyes ; then
1857         AC_DEFINE([CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK], 1, [enable invariant checking])
1858 fi
1859
1860 AC_ARG_ENABLE([lu_ref],
1861         AC_HELP_STRING([--enable-lu_ref],
1862                 [enable lu_ref reference tracking code]),
1863         [],[])
1864 AC_MSG_CHECKING([whether to track references with lu_ref])
1865 AC_MSG_RESULT([$enable_lu_ref])
1866 if test x$enable_lu_ref = xyes ; then
1867         AC_DEFINE([USE_LU_REF], 1, [enable lu_ref reference tracking code])
1868 fi
1869
1870 AC_ARG_ENABLE([pgstate-track],
1871               AC_HELP_STRING([--enable-pgstate-track],
1872                              [enable page state tracking]),
1873               [enable_pgstat_track='yes'],[])
1874 AC_MSG_CHECKING([whether to enable page state tracking])
1875 AC_MSG_RESULT([$enable_pgstat_track])
1876 if test x$enable_pgstat_track = xyes ; then
1877         AC_DEFINE([CONFIG_DEBUG_PAGESTATE_TRACKING], 1,
1878                   [enable page state tracking code])
1879 fi
1880 ])
1881
1882 #
1883 # LC_CONDITIONALS
1884 #
1885 # AM_CONDITIONALS for lustre
1886 #
1887 AC_DEFUN([LC_CONDITIONALS],
1888 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
1889 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
1890 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
1891 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
1892 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
1893 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
1894 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
1895 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
1896 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
1897 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
1898 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
1899 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
1900 AM_CONDITIONAL(LLITE_LLOOP, test x$enable_llite_lloop_module = xyes)
1901 ])
1902
1903 #
1904 # LC_CONFIG_FILES
1905 #
1906 # files that should be generated with AC_OUTPUT
1907 #
1908 AC_DEFUN([LC_CONFIG_FILES],
1909 [AC_CONFIG_FILES([
1910 lustre/Makefile
1911 lustre/autoMakefile
1912 lustre/autoconf/Makefile
1913 lustre/conf/Makefile
1914 lustre/contrib/Makefile
1915 lustre/doc/Makefile
1916 lustre/include/Makefile
1917 lustre/include/lustre_ver.h
1918 lustre/include/linux/Makefile
1919 lustre/include/darwin/Makefile
1920 lustre/include/lustre/Makefile
1921 lustre/kernel_patches/targets/2.6-rhel6.target
1922 lustre/kernel_patches/targets/2.6-rhel5.target
1923 lustre/kernel_patches/targets/2.6-sles11.target
1924 lustre/kernel_patches/targets/3.0-sles11.target
1925 lustre/kernel_patches/targets/3.0-sles11sp3.target
1926 lustre/kernel_patches/targets/2.6-fc11.target
1927 lustre/kernel_patches/targets/2.6-fc12.target
1928 lustre/kernel_patches/targets/2.6-fc15.target
1929 lustre/kernel_patches/targets/3.x-fc18.target
1930 lustre/ldlm/Makefile
1931 lustre/fid/Makefile
1932 lustre/fid/autoMakefile
1933 lustre/liblustre/Makefile
1934 lustre/liblustre/tests/Makefile
1935 lustre/liblustre/tests/mpi/Makefile
1936 lustre/llite/Makefile
1937 lustre/llite/autoMakefile
1938 lustre/lclient/Makefile
1939 lustre/lov/Makefile
1940 lustre/lov/autoMakefile
1941 lustre/mdc/Makefile
1942 lustre/mdc/autoMakefile
1943 lustre/lmv/Makefile
1944 lustre/lmv/autoMakefile
1945 lustre/lfsck/Makefile
1946 lustre/lfsck/autoMakefile
1947 lustre/mdt/Makefile
1948 lustre/mdt/autoMakefile
1949 lustre/nodemap/Makefile
1950 lustre/nodemap/autoMakefile
1951 lustre/mdd/Makefile
1952 lustre/mdd/autoMakefile
1953 lustre/fld/Makefile
1954 lustre/fld/autoMakefile
1955 lustre/obdclass/Makefile
1956 lustre/obdclass/autoMakefile
1957 lustre/obdclass/linux/Makefile
1958 lustre/obdecho/Makefile
1959 lustre/obdecho/autoMakefile
1960 lustre/ofd/Makefile
1961 lustre/ofd/autoMakefile
1962 lustre/osc/Makefile
1963 lustre/osc/autoMakefile
1964 lustre/ost/Makefile
1965 lustre/ost/autoMakefile
1966 lustre/osd-ldiskfs/Makefile
1967 lustre/osd-ldiskfs/autoMakefile
1968 lustre/osd-zfs/Makefile
1969 lustre/osd-zfs/autoMakefile
1970 lustre/mgc/Makefile
1971 lustre/mgc/autoMakefile
1972 lustre/mgs/Makefile
1973 lustre/mgs/autoMakefile
1974 lustre/target/Makefile
1975 lustre/ptlrpc/Makefile
1976 lustre/ptlrpc/autoMakefile
1977 lustre/ptlrpc/gss/Makefile
1978 lustre/ptlrpc/gss/autoMakefile
1979 lustre/quota/Makefile
1980 lustre/quota/autoMakefile
1981 lustre/scripts/Makefile
1982 lustre/tests/Makefile
1983 lustre/tests/mpi/Makefile
1984 lustre/utils/Makefile
1985 lustre/utils/gss/Makefile
1986 lustre/osp/Makefile
1987 lustre/osp/autoMakefile
1988 lustre/lod/Makefile
1989 lustre/lod/autoMakefile
1990 lustre/obdclass/darwin/Makefile
1991 ])
1992 ])