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