home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / aclocal.m4 < prev    next >
Text File  |  2011-03-23  |  71KB  |  2,304 lines

  1. # generated automatically by aclocal 1.7.9 -*- Autoconf -*-
  2.  
  3. # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
  4. # Free Software Foundation, Inc.
  5. # This file is free software; the Free Software Foundation
  6. # gives unlimited permission to copy and/or distribute it,
  7. # with or without modifications, as long as this notice is preserved.
  8.  
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  11. # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  12. # PARTICULAR PURPOSE.
  13.  
  14.  
  15. AC_DEFUN([AX_OPENSSL],
  16. [
  17.     opensslpath=ifelse([$1], ,,$1)
  18.  
  19.     if test "x$1" != "xno"; then
  20.  
  21.         AC_MSG_CHECKING([for openssl library])
  22.     
  23.         if test "x${opensslpath}" != "x"; then
  24.             CFLAGS="${CFLAGS} -I${opensslpath}/include"
  25.             LDFLAGS="$LDFLAGS -L${opensslpath}/lib64 -L${opensslpath}/lib"
  26.             SERVER_LDFLAGS="$SERVER_LDFLAGS -L${opensslpath}/lib64 -L${opensslpath}/lib"
  27.         fi
  28.         LIBS="$LIBS -lcrypto -lssl"
  29.     
  30.         AC_COMPILE_IFELSE(
  31.             [#include "openssl/bio.h"],
  32.             [],
  33.             [AC_MSG_ERROR(Invalid openssl path specified.  No openssl/bio.h found.)])
  34.     
  35.         AC_TRY_LINK(
  36.             [#include "openssl/bio.h"],
  37.             [BIO * b;],
  38.             [AC_MSG_RESULT(yes)],
  39.             [AC_MSG_ERROR(could not find openssl libs)])
  40.     
  41.         AC_DEFINE(WITH_OPENSSL, 1, [Define if openssl exists])
  42.         
  43.     AC_CHECK_HEADERS(openssl/evp.h)
  44.     AC_CHECK_HEADERS(openssl/crypto.h)
  45.     fi
  46. ])
  47.  
  48. AC_DEFUN([AX_OPENSSL_OPTIONAL],
  49. [
  50.     AC_MSG_CHECKING([for openssl library])
  51.     TMPLIBS=${LIBS}
  52.     LIBS="$LIBS -lcrypto -lssl"
  53.  
  54.     AC_COMPILE_IFELSE(
  55.       [#include "openssl/bio.h"],
  56.       [],
  57.       [AC_MSG_WARN(No openssl headers found.)])
  58.  
  59.     AC_TRY_LINK(
  60.       [#include "openssl/bio.h"],
  61.       [BIO * b;],
  62.       [AC_MSG_RESULT(yes)
  63.        AC_DEFINE(WITH_OPENSSL, 1, [Define if openssl exists])
  64.       ],
  65.       [
  66.           AC_MSG_WARN(No openssl headers found.)
  67.     LIBS=${TMPLIBS}
  68.       ])
  69.  
  70.     AC_CHECK_HEADERS(openssl/evp.h)
  71.     AC_CHECK_HEADERS(openssl/crypto.h)
  72.  
  73. ])
  74.  
  75.  
  76. AC_DEFUN([AX_KERNEL_FEATURES],
  77. [
  78.     dnl 
  79.     dnl kernel feature tests.  Set CFLAGS once here and use it for all
  80.     dnl kernel features.  reset to the old value at the end. 
  81.     dnl 
  82.     dnl on some systems, there is a /usr/include/linux/xattr_acl.h , so the
  83.     dnl check for xattr_acl.h down below will always pass, even if it
  84.     dnl should fail.  this hack (-nostdinc -isystem ...) will bring in just
  85.     dnl enough system headers dnl for kernel compilation
  86.  
  87.     dnl -Werror can be overkill, but for these kernel feature tests
  88.     dnl 'implicit function declaration' usually ends up in an undefined
  89.     dnl symbol somewhere.
  90.  
  91.     NOSTDINCFLAGS="-Werror-implicit-function-declaration -nostdinc -isystem `$CC -print-file-name=include`"
  92.  
  93.     CFLAGS="$USR_CFLAGS $NOSTDINCFLAGS -I$lk_src/include -I$lk_src/include/asm/mach-default -DKBUILD_STR(s)=#s -DKBUILD_BASENAME=KBUILD_STR(empty)  -DKBUILD_MODNAME=KBUILD_STR(empty)"
  94.  
  95.     dnl kernels > 2.6.32 now use generated/autoconf.h
  96.     if test -f $lk_src/include/generated/autoconf.h ; then
  97.         CFLAGS="$CFLAGS -imacros $lk_src/include/generated/autoconf.h"
  98.     else
  99.         CFLAGS="$CFLAGS -imacros $lk_src/include/linux/autoconf.h"
  100.     fi
  101.  
  102.         dnl we probably need additional includes if this build is intended
  103.         dnl for a different architecture
  104.     if test -n "${ARCH}" ; then
  105.         CFLAGS="$CFLAGS -I$lk_src/arch/${ARCH}/include -I$lk_src/arch/${ARCH}/include/asm/mach-default"
  106.         else
  107.             SUBARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
  108.             -e s/arm.*/arm/ -e s/sa110/arm/ \
  109.             -e s/s390x/s390/ -e s/parisc64/parisc/ \
  110.             -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
  111.             -e s/sh.*/sh/`
  112.             if test "x$SUBARCH" = "xi386"; then
  113.                 ARCH=x86    
  114.             elif test "x$SUBARCH" = "xx86_64"; then
  115.                 ARCH=x86    
  116.             elif test "x$SUBARCH" = "xsparc64"; then
  117.                 ARCH=sparc    
  118.             else
  119.                 ARCH=$SUBARCH
  120.             fi
  121.  
  122.             CFLAGS="$CFLAGS -I$lk_src/arch/${ARCH}/include -I$lk_src/arch/${ARCH}/include/asm/mach-default"
  123.     fi
  124.  
  125.     AC_MSG_CHECKING(for i_size_write in kernel)
  126.     dnl if this test passes, the kernel does not have it
  127.     dnl if this test fails, the kernel already defined it
  128.     AC_TRY_COMPILE([
  129.         #define __KERNEL__
  130.         #include <linux/fs.h>
  131.         void i_size_write(struct inode *inode,
  132.                 loff_t i_size)
  133.         {
  134.             return;
  135.         }
  136.     ], [],
  137.         AC_MSG_RESULT(no),
  138.         AC_MSG_RESULT(yes)
  139.         AC_DEFINE(HAVE_I_SIZE_WRITE, 1, Define if kernel has i_size_write),
  140.     )
  141.  
  142.     AC_MSG_CHECKING(for i_size_read in kernel)
  143.     dnl if this test passes, the kernel does not have it
  144.     dnl if this test fails, the kernel already defined it
  145.     AC_TRY_COMPILE([
  146.         #define __KERNEL__
  147.         #include <linux/fs.h>
  148.         loff_t i_size_read(struct inode *inode)
  149.         {
  150.             return 0;
  151.         }
  152.     ], [],
  153.         AC_MSG_RESULT(no),
  154.         AC_MSG_RESULT(yes)
  155.         AC_DEFINE(HAVE_I_SIZE_READ, 1, Define if kernel has i_size_read),
  156.     )
  157.  
  158.     AC_MSG_CHECKING(for iget_locked function in kernel)
  159.     dnl if this test passes, the kernel does not have it
  160.     dnl if this test fails, the kernel already defined it
  161.     AC_TRY_COMPILE([
  162.         #define __KERNEL__
  163.         #include <linux/fs.h>
  164.         loff_t iget_locked(struct inode *inode)
  165.         {
  166.             return 0;
  167.         }
  168.     ], [],
  169.         AC_MSG_RESULT(no),
  170.         AC_MSG_RESULT(yes)
  171.         AC_DEFINE(HAVE_IGET_LOCKED, 1, Define if kernel has iget_locked),
  172.     )
  173.  
  174.     AC_MSG_CHECKING(for iget4_locked function in kernel)
  175.     dnl if this test passes, the kernel does not have it
  176.     dnl if this test fails, the kernel already defined it
  177.     AC_TRY_COMPILE([
  178.         #define __KERNEL__
  179.         #include <linux/fs.h>
  180.         loff_t iget4_locked(struct inode *inode)
  181.         {
  182.             return 0;
  183.         }
  184.     ], [],
  185.         AC_MSG_RESULT(no),
  186.         AC_MSG_RESULT(yes)
  187.         AC_DEFINE(HAVE_IGET4_LOCKED, 1, Define if kernel has iget4_locked),
  188.     )
  189.  
  190.     AC_MSG_CHECKING(for iget5_locked function in kernel)
  191.     dnl if this test passes, the kernel does not have it
  192.     dnl if this test fails, the kernel already defined it
  193.     AC_TRY_COMPILE([
  194.         #define __KERNEL__
  195.         #include <linux/fs.h>
  196.         loff_t iget5_locked(struct inode *inode)
  197.         {
  198.             return 0;
  199.         }
  200.     ], [],
  201.         AC_MSG_RESULT(no),
  202.         AC_MSG_RESULT(yes)
  203.         AC_DEFINE(HAVE_IGET5_LOCKED, 1, Define if kernel has iget5_locked),
  204.     )
  205.  
  206.     dnl Check if the kernel defines the xtvec structure.
  207.     dnl This is part of a POSIX extension.
  208.     AC_MSG_CHECKING(for struct xtvec in kernel)
  209.     AC_TRY_COMPILE([
  210.         #define __KERNEL__
  211.         #include <linux/uio.h>
  212.         static struct xtvec xv = { 0, 0 };
  213.     ], [],
  214.         AC_MSG_RESULT(yes)
  215.         AC_DEFINE(HAVE_STRUCT_XTVEC, 1, Define if struct xtvec is defined in the kernel),
  216.         AC_MSG_RESULT(no)
  217.     )
  218.  
  219.     dnl 2.6.20 deprecated kmem_cache_t; some old ones do not have struct
  220.     dnl kmem_cache, but may have kmem_cache_s.  It's a mess.  Just look
  221.     dnl for this, and assume _t if not found.
  222.     dnl This test relies on gcc complaining about declaring a struct
  223.     dnl in a parameter list.  Fragile, but nothing better is available
  224.     dnl to check for the existence of a struct.  We cannot see the
  225.     dnl definition of the struct in the kernel, it's private to the
  226.     dnl slab implementation.  And C lets you declare structs freely as
  227.     dnl long as you don't try to deal with their contents.
  228.         tmp_cflags=$CFLAGS
  229.         CFLAGS="$CFLAGS -Werror"
  230.     AC_MSG_CHECKING(for struct kmem_cache in kernel)
  231.     AC_TRY_COMPILE([
  232.         #define __KERNEL__
  233.         #include <linux/kernel.h>
  234.         #include <linux/slab.h>
  235.  
  236.         int foo(struct kmem_cache *s)
  237.         {
  238.             return (s == NULL) ? 3 : 4;
  239.         }
  240.     ], [],
  241.         AC_MSG_RESULT(yes)
  242.         AC_DEFINE(HAVE_STRUCT_KMEM_CACHE, 1, Define if struct kmem_cache is defined in kernel),
  243.         AC_MSG_RESULT(no)
  244.     )
  245.         CFLAGS=$tmp_cflags
  246.  
  247.     dnl 2.6.20 removed SLAB_KERNEL.  Need to use GFP_KERNEL instead
  248.     AC_MSG_CHECKING(for SLAB_KERNEL flag in kernel)
  249.     AC_TRY_COMPILE([
  250.         #define __KERNEL__
  251.         #include <linux/slab.h>
  252.         static int flags = SLAB_KERNEL;
  253.     ], [],
  254.         AC_MSG_RESULT(yes)
  255.         AC_DEFINE(HAVE_SLAB_KERNEL, 1, Define if SLAB_KERNEL is defined in kernel),
  256.         AC_MSG_RESULT(no)
  257.     )
  258.  
  259.     dnl The name of this field changed from memory_backed to capabilities
  260.     dnl in 2.6.12.
  261.     AC_MSG_CHECKING(for memory_backed in struct backing_dev_info in kernel)
  262.     AC_TRY_COMPILE([
  263.         #define __KERNEL__
  264.         #include <linux/mm.h>
  265.         #include <linux/backing-dev.h>
  266.         static struct backing_dev_info bdi = {
  267.             .memory_backed = 0
  268.         };
  269.     ], [],
  270.         AC_MSG_RESULT(yes)
  271.         AC_DEFINE(HAVE_BDI_MEMORY_BACKED, 1, Define if struct backing_dev_info in kernel has memory_backed),
  272.         AC_MSG_RESULT(no)
  273.     )
  274.  
  275.     dnl checking if we have a sendfile callback 
  276.     if test "x$enable_kernel_sendfile" = "xyes"; then
  277.         AC_MSG_CHECKING(for sendfile callback in struct file_operations in kernel)
  278.         AC_TRY_COMPILE([
  279.             #define __KERNEL__
  280.             #include <linux/fs.h>
  281.             static struct file_operations fop = {
  282.                  .sendfile = NULL,
  283.             };
  284.         ], [],
  285.             AC_MSG_RESULT(yes)
  286.             AC_DEFINE(HAVE_SENDFILE_VFS_SUPPORT, 1, Define if struct file_operations in kernel has sendfile callback),
  287.             AC_MSG_RESULT(no)
  288.         )
  289.     fi
  290.  
  291.     dnl checking if we have a readv callback in super_operations 
  292.     AC_MSG_CHECKING(for readv callback in struct file_operations in kernel)
  293.     AC_TRY_COMPILE([
  294.         #define __KERNEL__
  295.         #include <linux/fs.h>
  296.         static struct file_operations fop = {
  297.             .readv = NULL,
  298.         };
  299.     ], [],
  300.         AC_MSG_RESULT(yes)
  301.         AC_DEFINE(HAVE_READV_FILE_OPERATIONS, 1, Define if struct file_operations in kernel has readv callback),
  302.         AC_MSG_RESULT(no)
  303.     )
  304.     dnl checking if we have a writev callback in super_operations 
  305.     AC_MSG_CHECKING(for writev callback in struct file_operations in kernel)
  306.     AC_TRY_COMPILE([
  307.         #define __KERNEL__
  308.         #include <linux/fs.h>
  309.         static struct file_operations fop = {
  310.             .writev = NULL,
  311.         };
  312.     ], [],
  313.         AC_MSG_RESULT(yes)
  314.         AC_DEFINE(HAVE_WRITEV_FILE_OPERATIONS, 1, Define if struct file_operations in kernel has writev callback),
  315.         AC_MSG_RESULT(no)
  316.     )
  317.  
  318.     dnl checking if we have a find_inode_handle callback in super_operations 
  319.     AC_MSG_CHECKING(for find_inode_handle callback in struct super_operations in kernel)
  320.     AC_TRY_COMPILE([
  321.         #define __KERNEL__
  322.         #include <linux/fs.h>
  323.         static struct super_operations sop = {
  324.             .find_inode_handle = NULL,
  325.         };
  326.     ], [],
  327.         AC_MSG_RESULT(yes)
  328.         AC_DEFINE(HAVE_FIND_INODE_HANDLE_SUPER_OPERATIONS, 1, Define if struct super_operations in kernel has find_inode_handle callback),
  329.         AC_MSG_RESULT(no)
  330.     )
  331.  
  332.     dnl 2.6.18.1 removed this member
  333.     AC_MSG_CHECKING(for i_blksize in struct inode)
  334.     AC_TRY_COMPILE([
  335.         #define __KERNEL__
  336.         #include <linux/fs.h>
  337.         static struct inode i = {
  338.             .i_blksize = 0,
  339.             };
  340.         ], [],
  341.             AC_MSG_RESULT(yes)
  342.             AC_DEFINE(HAVE_I_BLKSIZE_IN_STRUCT_INODE, 1, Define if struct inode in kernel has i_blksize member),
  343.             AC_MSG_RESULT(no)
  344.     )
  345.  
  346.     dnl 2.6.16 removed this member
  347.     AC_MSG_CHECKING(for i_sem in struct inode)
  348.     AC_TRY_COMPILE([
  349.         #define __KERNEL__
  350.         #include <linux/fs.h>
  351.         static struct inode i = {
  352.             .i_sem = {0},
  353.             };
  354.         ], [],
  355.             AC_MSG_RESULT(yes)
  356.             AC_DEFINE(HAVE_I_SEM_IN_STRUCT_INODE, 1, Define if struct inode in kernel has i_sem member),
  357.             AC_MSG_RESULT(no)
  358.     )
  359.  
  360.     dnl checking if we have a statfs_lite callback in super_operations 
  361.     AC_MSG_CHECKING(for statfs_lite callback in struct super_operations in kernel)
  362.     AC_TRY_COMPILE([
  363.         #define __KERNEL__
  364.         #include <linux/fs.h>
  365.         static struct super_operations sop = {
  366.             .statfs_lite = NULL,
  367.         };
  368.     ], [],
  369.         AC_MSG_RESULT(yes)
  370.         AC_DEFINE(HAVE_STATFS_LITE_SUPER_OPERATIONS, 1, Define if struct super_operations in kernel has statfs_lite callback),
  371.         AC_MSG_RESULT(no)
  372.     )
  373.  
  374.     dnl checking if we have a fill_handle callback in inode_operations 
  375.     AC_MSG_CHECKING(for fill_handle callback in struct inode_operations in kernel)
  376.     AC_TRY_COMPILE([
  377.         #define __KERNEL__
  378.         #include <linux/fs.h>
  379.         static struct inode_operations iop = {
  380.             .fill_handle = NULL,
  381.         };
  382.     ], [],
  383.         AC_MSG_RESULT(yes)
  384.         AC_DEFINE(HAVE_FILL_HANDLE_INODE_OPERATIONS, 1, Define if struct inode_operations in kernel has fill_handle callback),
  385.         AC_MSG_RESULT(no)
  386.     )
  387.  
  388.     dnl checking if we have a getattr_lite callback in inode_operations 
  389.     AC_MSG_CHECKING(for getattr_lite callback in struct inode_operations in kernel)
  390.     AC_TRY_COMPILE([
  391.         #define __KERNEL__
  392.         #include <linux/fs.h>
  393.         static struct inode_operations iop = {
  394.             .getattr_lite = NULL,
  395.         };
  396.     ], [],
  397.         AC_MSG_RESULT(yes)
  398.         AC_DEFINE(HAVE_GETATTR_LITE_INODE_OPERATIONS, 1, Define if struct inode_operations in kernel has getattr_lite callback),
  399.         AC_MSG_RESULT(no)
  400.     )
  401.  
  402.     dnl checking if we have a get_fs_key callback in super_operations 
  403.     AC_MSG_CHECKING(for get_fs_key callback in struct super_operations in kernel)
  404.     AC_TRY_COMPILE([
  405.         #define __KERNEL__
  406.         #include <linux/fs.h>
  407.         static struct super_operations sop = {
  408.             .get_fs_key = NULL,
  409.         };
  410.     ], [],
  411.         AC_MSG_RESULT(yes)
  412.         AC_DEFINE(HAVE_GET_FS_KEY_SUPER_OPERATIONS, 1, Define if struct super_operations in kernel has get_fs_key callback),
  413.         AC_MSG_RESULT(no)
  414.     )
  415.     
  416.     dnl checking if we have a readdirplus callback in file_operations
  417.     AC_MSG_CHECKING(for readdirplus member in file_operations structure)
  418.     AC_TRY_COMPILE([
  419.         #define __KERNEL__
  420.         #include <linux/fs.h>
  421.          ], [
  422.          struct file_operations filop = {
  423.                 .readdirplus = NULL
  424.          };
  425.         ],
  426.         AC_MSG_RESULT(yes)
  427.          AC_DEFINE(HAVE_READDIRPLUS_FILE_OPERATIONS, 1, Define if struct file_operations in kernel has readdirplus callback),
  428.         AC_MSG_RESULT(no)
  429.         )
  430.  
  431.     dnl checking if we have a readdirplus_lite callback in file_operations
  432.     AC_MSG_CHECKING(for readdirplus_lite member in file_operations structure)
  433.     AC_TRY_COMPILE([
  434.         #define __KERNEL__
  435.         #include <linux/fs.h>
  436.          ], [
  437.          struct file_operations filop = {
  438.                 .readdirplus_lite = NULL
  439.          };
  440.         ],
  441.         AC_MSG_RESULT(yes)
  442.          AC_DEFINE(HAVE_READDIRPLUSLITE_FILE_OPERATIONS, 1, Define if struct file_operations in kernel has readdirplus_lite callback),
  443.         AC_MSG_RESULT(no)
  444.         )
  445.  
  446.  
  447.     dnl checking if we have a readx callback in file_operations
  448.     AC_MSG_CHECKING(for readx member in file_operations structure)
  449.     AC_TRY_COMPILE([
  450.         #define __KERNEL__
  451.         #include <linux/fs.h>
  452.          ], [
  453.          struct file_operations filop = {
  454.                 .readx = NULL
  455.          };
  456.         ],
  457.         AC_MSG_RESULT(yes)
  458.          AC_DEFINE(HAVE_READX_FILE_OPERATIONS, 1, Define if struct file_operations in kernel has readx callback),
  459.         AC_MSG_RESULT(no)
  460.         )
  461.  
  462.     dnl checking if we have a writex callback in file_operations
  463.     AC_MSG_CHECKING(for writex member in file_operations structure)
  464.     AC_TRY_COMPILE([
  465.         #define __KERNEL__
  466.         #include <linux/fs.h>
  467.          ], [
  468.          struct file_operations filop = {
  469.                 .writex = NULL
  470.          };
  471.         ],
  472.         AC_MSG_RESULT(yes)
  473.          AC_DEFINE(HAVE_WRITEX_FILE_OPERATIONS, 1, Define if struct file_operations in kernel has writex callback),
  474.         AC_MSG_RESULT(no)
  475.         )
  476.  
  477.     AC_MSG_CHECKING(for aio support in kernel)
  478.     dnl if this test passes, the kernel has it
  479.     dnl if this test fails, the kernel does not have it
  480.     AC_TRY_COMPILE([
  481.         #define __KERNEL__
  482.         #include <linux/wait.h>
  483.         #include <linux/aio.h>
  484.           static struct kiocb iocb;
  485.         ], [],
  486.         AC_MSG_RESULT(yes)
  487.         AC_DEFINE(HAVE_AIO, 1, Define if kernel has aio support)
  488.         have_aio=yes,
  489.         AC_MSG_RESULT(no)
  490.         have_aio=no
  491.     )
  492.  
  493.     if test "x$have_aio" = "xyes" -a "x$enable_kernel_aio" = "xyes"; then
  494.         AC_MSG_CHECKING(for ki_dtor in kiocb structure of kernel)
  495.         dnl if this test passes, the kernel does have it and we enable
  496.         dnl support for AIO.   if this test fails, the kernel does not
  497.         dnl have this member and we disable support for AIO
  498.         AC_TRY_COMPILE([
  499.             #define __KERNEL__
  500.             #include <linux/wait.h>
  501.             #include <linux/aio.h>
  502.             static struct kiocb io_cb = {
  503.                       .ki_dtor = NULL,
  504.             };
  505.         ], [],
  506.             AC_MSG_RESULT(yes)
  507.             AC_DEFINE(HAVE_AIO_VFS_SUPPORT, 1, Define if we are enabling VFS AIO support in kernel),
  508.             AC_MSG_RESULT(no)
  509.         )
  510.  
  511.         tmp_cflags=$CFLAGS
  512.         dnl if this test passes, the signature of aio_read has changed to the new one 
  513.         CFLAGS="$CFLAGS -Werror"
  514.         AC_MSG_CHECKING(for new prototype of aio_read callback of file_operations structure)
  515.         AC_TRY_COMPILE([
  516.             #define __KERNEL__
  517.             #include <linux/fs.h>
  518.             extern ssize_t my_aio_read(struct kiocb *, const struct iovec *, unsigned long, loff_t);
  519.             static struct file_operations fop = {
  520.                       .aio_read = my_aio_read,
  521.             };
  522.         ], [],
  523.             AC_MSG_RESULT(yes)
  524.             AC_DEFINE(HAVE_AIO_NEW_AIO_SIGNATURE, 1, Define if VFS AIO support in kernel has a new prototype),
  525.             AC_MSG_RESULT(no)
  526.         )
  527.         CFLAGS=$tmp_cflags
  528.  
  529.     fi
  530.  
  531.     AC_MSG_CHECKING(for dentry argument in kernel super_operations statfs)
  532.     dnl Rely on the fact that there is an external vfs_statfs that is
  533.     dnl of the same type as the .statfs in struct super_operations to
  534.     dnl verify the signature of that function pointer.  There is a single
  535.     dnl commit in the git history where both changed at the same time
  536.     dnl from super_block to dentry.
  537.     dnl
  538.     dnl The alternative approach of trying to define a s_op.statfs is not
  539.     dnl as nice because that only throws a warning, requiring -Werror to
  540.     dnl catch it.  This is a problem if the compiler happens to spit out
  541.     dnl other spurious warnings that have nothing to do with the test.
  542.     dnl
  543.     dnl If this test passes, the kernel uses a struct dentry argument.
  544.     dnl If this test fails, the kernel uses something else (old struct
  545.     dnl super_block perhaps).
  546.     AC_TRY_COMPILE([
  547.         #define __KERNEL__
  548.         #include <linux/fs.h>
  549.         int vfs_statfs(struct dentry *de, struct kstatfs *kfs)
  550.         {
  551.             return 0;
  552.         }
  553.         ], [],
  554.         AC_MSG_RESULT(yes)
  555.         AC_DEFINE(HAVE_DENTRY_STATFS_SOP, 1, Define if super_operations statfs has dentry argument),
  556.         AC_MSG_RESULT(no)
  557.     )
  558.  
  559.     AC_MSG_CHECKING(for vfsmount argument in kernel file_system_type get_sb)
  560.     dnl Same trick as above.  A single commit changed mayn things at once:
  561.     dnl type and signature of file_system_type.get_sb, and signature of
  562.     dnl get_sb_bdev.  This test is a bit more tenuous, as get_sb_bdev
  563.     dnl isn't used directly in a file_system_type, but is a popular helper
  564.     dnl for many FSes.  And it has not exactly the same signature.
  565.     dnl
  566.     dnl If this test passes, the kernel has the most modern known form,
  567.     dnl which includes a stfuct vfsmount argument.
  568.     dnl If this test fails, the kernel uses something else.
  569.     AC_TRY_COMPILE([
  570.         #define __KERNEL__
  571.         #include <linux/fs.h>
  572.         int get_sb_bdev(struct file_system_type *fs_type, int flags,
  573.                 const char *dev_name, void *data,
  574.                 int (*fill_super)(struct super_block *, void *,
  575.                           int),
  576.                 struct vfsmount *vfsm)
  577.         {
  578.             return 0;
  579.         }
  580.         ], [],
  581.         AC_MSG_RESULT(yes)
  582.         AC_DEFINE(HAVE_VFSMOUNT_GETSB, 1, Define if file_system_type get_sb has vfsmount argument),
  583.         AC_MSG_RESULT(no)
  584.     )
  585.  
  586.     AC_MSG_CHECKING(for xattr support in kernel)
  587.     dnl if this test passes, the kernel has it
  588.     dnl if this test fails, the kernel does not have it
  589.     AC_TRY_COMPILE([
  590.         #define __KERNEL__
  591.         #include <linux/fs.h>
  592.               static struct inode_operations in_op = {
  593.                   .getxattr = NULL
  594.               };
  595.         ], [],
  596.         AC_MSG_RESULT(yes)
  597.         AC_DEFINE(HAVE_XATTR, 1, Define if kernel has xattr support)
  598.         have_xattr=yes,
  599.         AC_MSG_RESULT(no)
  600.         have_xattr=no
  601.     )
  602.  
  603.     if test "x$have_xattr" = "xyes"; then
  604.        dnl Test to check if setxattr function has a const void * argument
  605.        AC_MSG_CHECKING(for const argument to setxattr function)
  606.        dnl if this test passes, there is a const void* argument
  607.        AC_TRY_COMPILE([
  608.         #define __KERNEL__
  609.         #include <linux/fs.h>
  610.         ], 
  611.         [
  612.             struct inode_operations inode_ops;
  613.             int ret;
  614.             struct dentry * dent = NULL;
  615.             const char * name = NULL;
  616.             const void * val = NULL;
  617.             size_t size = 0;
  618.             int flags = 0;
  619.  
  620.             ret = inode_ops.setxattr(dent, name, val, size, flags);
  621.         ],
  622.         AC_MSG_RESULT(yes)
  623.         AC_DEFINE(HAVE_SETXATTR_CONST_ARG, 1, Define if kernel setxattr has const void* argument),
  624.         AC_MSG_RESULT(no)
  625.         )
  626.     fi
  627.  
  628.         dnl the proc handler functions have changed over the years.
  629.         dnl pre-2.6.8: proc_handler(ctl_table       *ctl,
  630.         dnl                         int             write,
  631.         dnl                         struct file     *filp,
  632.         dnl                         void            *buffer,
  633.         dnl                         size_t          *lenp)
  634.         dnl
  635.         dnl 2.6.8-2.6.31: proc_handler(ctl_table       *ctl,
  636.         dnl                            int             write,
  637.         dnl                            struct file     *filp,
  638.         dnl                            void            *buffer,
  639.         dnl                            size_t          *lenp,
  640.         dnl                            loff_t          *ppos)
  641.         dnl > 2.6.31: proc_handler(ctl_table       *ctl,
  642.         dnl                        int             write,
  643.         dnl                        void            *buffer,
  644.         dnl                        size_t          *lenp,
  645.         dnl                        loff_t          *ppos)
  646.  
  647.     dnl Test to see if sysctl proc handlers have a file argument
  648.     AC_MSG_CHECKING(for file argument to sysctl proc handlers)
  649.     AC_TRY_COMPILE([
  650.         #define __KERNEL__
  651.         #include <linux/fs.h>
  652.         #include <linux/sysctl.h>
  653.         ], [
  654.                 struct ctl_table * ctl = NULL;
  655.                 int write = 0;
  656.                 struct file * filp = NULL;
  657.                 void __user * buffer = NULL;
  658.                 size_t * lenp = NULL;
  659.                 loff_t * ppos = NULL;
  660.  
  661.                 proc_dointvec_minmax(ctl, write, filp, buffer, lenp, ppos);
  662.         ],
  663.         AC_MSG_RESULT(yes)
  664.         AC_DEFINE(HAVE_PROC_HANDLER_FILE_ARG, 1, Define if sysctl proc handlers have 6th argument),
  665.         AC_MSG_RESULT(no)
  666.         )
  667.  
  668.     AC_MSG_CHECKING(for ppos argument to sysctl proc handlers)
  669.     dnl if this test passes, there is a ppos argument
  670.     AC_TRY_COMPILE([
  671.         #define __KERNEL__
  672.         #include <linux/fs.h>
  673.         #include <linux/sysctl.h>
  674.         ], [
  675.                 struct ctl_table * ctl = NULL;
  676.                 int write = 0;
  677.                 void __user * buffer = NULL;
  678.                 size_t * lenp = NULL;
  679.                 loff_t * ppos = NULL;
  680.  
  681.                 proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
  682.         ],
  683.         AC_MSG_RESULT(yes)
  684.         AC_DEFINE(HAVE_PROC_HANDLER_PPOS_ARG, 1, Define if sysctl proc handlers have ppos argument),
  685.         AC_MSG_RESULT(no)
  686.         )
  687.  
  688.     AC_CHECK_HEADERS([linux/posix_acl.h], [], [], 
  689.         [#define __KERNEL__
  690.          #include <linux/fs.h>
  691.          #ifdef HAVE_XATTR 
  692.          #include <linux/xattr.h> 
  693.          #endif
  694.          ] )
  695.  
  696.     AC_CHECK_HEADERS([linux/posix_acl_xattr.h], [], [], 
  697.         [#define __KERNEL__
  698.          #include <linux/fs.h>
  699.          #ifdef HAVE_XATTR 
  700.          #include <linux/xattr.h> 
  701.          #endif
  702.          ] )
  703.  
  704.     dnl linux-2.6.11 had xattr_acl.h, but 2.6.12 did not!
  705.     AC_CHECK_HEADERS([linux/xattr_acl.h], [], [], 
  706.         [#define __KERNEL__
  707.          #include <linux/fs.h>
  708.          #ifdef HAVE_XATTR
  709.          #include <linux/xattr.h>
  710.          #endif
  711.          ] )
  712.  
  713.     AC_CHECK_HEADERS([linux/mount.h], [], [], 
  714.         [#define __KERNEL__
  715.          #include <linux/mount.h>
  716.          ] )
  717.     AC_CHECK_HEADERS([linux/ioctl32.h], [], [], 
  718.         [#define __KERNEL__
  719.          #include <linux/ioctl32.h>
  720.          ] )
  721.     AC_CHECK_HEADERS([linux/compat.h], [], [], 
  722.         [#define __KERNEL__
  723.          #include <linux/compat.h>
  724.          ] )
  725.     AC_CHECK_HEADERS([linux/syscalls.h], [], [], 
  726.         [#define __KERNEL__
  727.          #include <linux/syscalls.h>
  728.          ] )
  729.     AC_CHECK_HEADERS([asm/ioctl32.h], [], [], 
  730.         [#define __KERNEL__
  731.          #include <asm/ioctl32.h>
  732.          ] )
  733.     AC_CHECK_HEADERS([linux/exportfs.h], [],[],
  734.         [#define __KERNEL__
  735.          #include <linux/exportfs.h>
  736.         ])
  737.  
  738.     AC_MSG_CHECKING(for generic_file_readv api in kernel)
  739.     dnl if this test passes, the kernel does not have it
  740.     dnl if this test fails, the kernel has it defined with a different
  741.     dnl signature!  deliberately, the signature for this method has been
  742.     dnl changed for it to give a compiler error.
  743.  
  744.     AC_TRY_COMPILE([
  745.         #define __KERNEL__
  746.         #include <linux/fs.h>
  747.         int generic_file_readv(struct inode *inode)
  748.         {
  749.             return 0;
  750.         }
  751.     ], [],
  752.         AC_MSG_RESULT(no),
  753.         AC_MSG_RESULT(yes)
  754.         AC_DEFINE(HAVE_GENERIC_FILE_READV, 1, Define if kernel has generic_file_readv),
  755.     )
  756.  
  757.     AC_MSG_CHECKING(for generic_permission api in kernel)
  758.     dnl if this test passes, the kernel does not have it
  759.     dnl if this test fails, the kernel has it defined with a different
  760.     dnl signature!  deliberately, the signature for this method has been
  761.     dnl changed for it to give a compiler error.
  762.  
  763.     AC_TRY_COMPILE([
  764.         #define __KERNEL__
  765.         #include <linux/fs.h>
  766.         int generic_permission(struct inode *inode)
  767.         {
  768.             return 0;
  769.         }
  770.     ], [],
  771.         AC_MSG_RESULT(no),
  772.         AC_MSG_RESULT(yes)
  773.         AC_DEFINE(HAVE_GENERIC_PERMISSION, 1, Define if kernel has generic_permission),
  774.     )
  775.  
  776.     AC_MSG_CHECKING(for generic_getxattr api in kernel)
  777.     dnl if this test passes, the kernel does not have it
  778.     dnl if this test fails, the kernel has it defined
  779.     AC_TRY_COMPILE([
  780.         #define __KERNEL__
  781.         #include <linux/fs.h>
  782.                 #include <linux/xattr.h>
  783.         int generic_getxattr(struct inode *inode)
  784.         {
  785.             return 0;
  786.         }
  787.     ], [],
  788.         AC_MSG_RESULT(no),
  789.         AC_MSG_RESULT(yes)
  790.         AC_DEFINE(HAVE_GENERIC_GETXATTR, 1, Define if kernel has generic_getxattr),
  791.     )
  792.  
  793.     AC_MSG_CHECKING(for arg member in read_descriptor_t in kernel)
  794.     AC_TRY_COMPILE([
  795.         #define __KERNEL__
  796.         #include <linux/fs.h>
  797.         ], [
  798.         read_descriptor_t x;
  799.         x.arg.data = NULL;
  800.         ],
  801.         AC_MSG_RESULT(yes)
  802.         AC_DEFINE(HAVE_ARG_IN_READ_DESCRIPTOR_T, 1, Define if read_descriptor_t has an arg member),
  803.         AC_MSG_RESULT(no)
  804.     )
  805.  
  806.         AC_MSG_CHECKING(for fh_to_dentry member in export_operations in kernel)
  807.     AC_TRY_COMPILE([
  808.         #define __KERNEL__
  809.         #include <linux/exportfs.h>
  810.         ], [
  811.         struct export_operations x;
  812.         x.fh_to_dentry = NULL;
  813.         ],
  814.         AC_MSG_RESULT(yes)
  815.         AC_DEFINE(HAVE_FHTODENTRY_EXPORT_OPERATIONS, 1, Define if export_operations has an fh_to_dentry member),
  816.         AC_MSG_RESULT(no)
  817.     )
  818.  
  819.         AC_MSG_CHECKING(for encode_fh member in export_operations in kernel)
  820.     AC_TRY_COMPILE([
  821.         #define __KERNEL__
  822.         #include <linux/exportfs.h>
  823.         ], [
  824.         struct export_operations x;
  825.         x.encode_fh = NULL;
  826.         ],
  827.         AC_MSG_RESULT(yes)
  828.         AC_DEFINE(HAVE_ENCODEFH_EXPORT_OPERATIONS, 1, Define if export_operations has an encode_fh member),
  829.         AC_MSG_RESULT(no)
  830.     )
  831.  
  832.     dnl Using -Werror is not an option, because some arches throw lots of
  833.     dnl warnings that would trigger false negatives.  We know that the
  834.     dnl change to the releasepage() function signature was accompanied by
  835.     dnl a similar change to the exported function try_to_release_page(),
  836.     dnl and that one we can check without using -Werror.  The test fails
  837.     dnl unless the previous declaration was identical to the one we suggest
  838.     dnl below.  New kernels use gfp_t, not int.
  839.     AC_MSG_CHECKING(for second arg type int in address_space_operations releasepage)
  840.     AC_TRY_COMPILE([
  841.         #define __KERNEL__
  842.         #include <linux/buffer_head.h>
  843.         extern int try_to_release_page(struct page *page, int gfp_mask);
  844.         ], [],
  845.         AC_MSG_RESULT(yes)
  846.         AC_DEFINE(HAVE_INT_ARG2_ADDRESS_SPACE_OPERATIONS_RELEASEPAGE, 1, Define if sceond argument to releasepage in address_space_operations is type int),
  847.         AC_MSG_RESULT(no)
  848.     )
  849.  
  850.     dnl Similar logic for the follow_link member in inode_operations.  New
  851.     dnl kernels return a void *, not int.
  852.     AC_MSG_CHECKING(for int return in inode_operations follow_link)
  853.     AC_TRY_COMPILE([
  854.         #define __KERNEL__
  855.         #include <linux/fs.h>
  856.         extern int page_follow_link_light(struct dentry *,
  857.                                           struct nameidata *);
  858.         ], [],
  859.         AC_MSG_RESULT(yes)
  860.         AC_DEFINE(HAVE_INT_RETURN_INODE_OPERATIONS_FOLLOW_LINK, 1, Define if return value from follow_link in inode_operations is type int),
  861.         AC_MSG_RESULT(no)
  862.     )
  863.  
  864.     dnl kmem_cache_destroy function may return int only on pre 2.6.19 kernels
  865.     dnl else it returns a void.
  866.     AC_MSG_CHECKING(for int return in kmem_cache_destroy)
  867.     AC_TRY_COMPILE([
  868.         #define __KERNEL__
  869.         #include <linux/slab.h>
  870.         extern int kmem_cache_destroy(kmem_cache_t *);
  871.         ], [],
  872.         AC_MSG_RESULT(yes)
  873.         AC_DEFINE(HAVE_INT_RETURN_KMEM_CACHE_DESTROY, 1, Define if return value from kmem_cache_destroy is type int),
  874.         AC_MSG_RESULT(no)
  875.     )
  876.  
  877.     dnl more 2.6 api changes.  return type for the invalidatepage
  878.     dnl address_space_operation is 'void' in new kernels but 'int' in old
  879.     dnl I had to turn on -Werror for this test because i'm not sure how
  880.     dnl else to make dnl "initialization from incompatible pointer type"
  881.     dnl fail.  
  882.     AC_MSG_CHECKING(for older int return in invalidatepage)
  883.     AC_TRY_COMPILE([
  884.         #define __KERNEL__
  885.         #include <linux/fs.h>
  886.         ], 
  887.                 [
  888.             struct address_space_operations aso;
  889.  
  890.             int ret;
  891.             struct page * page = NULL;
  892.             unsigned long offset;
  893.  
  894.             ret = aso.invalidatepage(page, offset);
  895.         ],
  896.         AC_MSG_RESULT(yes)
  897.         AC_DEFINE(HAVE_INT_RETURN_ADDRESS_SPACE_OPERATIONS_INVALIDATEPAGE, 1, Define if return type of invalidatepage should be int),
  898.         AC_MSG_RESULT(NO)
  899.         )
  900.  
  901.     dnl In 2.6.18.1 and newer, including <linux/config.h> will throw off a
  902.     dnl warning 
  903.     tmp_cflags=${CFLAGS}
  904.     CFLAGS="${CFLAGS} -Werror"
  905.     AC_MSG_CHECKING(for warnings when including linux/config.h)
  906.     AC_TRY_COMPILE([
  907.         #define __KERNEL__
  908.         #include <linux/config.h>
  909.         ], [], 
  910.         AC_MSG_RESULT(no)
  911.         AC_DEFINE(HAVE_NOWARNINGS_WHEN_INCLUDING_LINUX_CONFIG_H, 1, Define if including linux/config.h gives no warnings),
  912.         AC_MSG_RESULT(yes)
  913.     )
  914.     CFLAGS=$tmp_cflags
  915.  
  916.     AC_MSG_CHECKING(for compat_ioctl member in file_operations structure)
  917.     AC_TRY_COMPILE([
  918.         #define __KERNEL__
  919.         #include <linux/fs.h>
  920.          ], [
  921.          struct file_operations filop = {
  922.                 .compat_ioctl = NULL
  923.          };
  924.         ],
  925.         AC_MSG_RESULT(yes)
  926.          AC_DEFINE(HAVE_COMPAT_IOCTL_HANDLER, 1, Define if there exists a compat_ioctl member in file_operations),
  927.         AC_MSG_RESULT(no)
  928.         )
  929.  
  930.     dnl Gives wrong answer if header is missing; don't try then.
  931.     if test x$ac_cv_header_linux_ioctl32_h = xyes ; then
  932.     AC_MSG_CHECKING(for register_ioctl32_conversion kernel exports)
  933.     dnl if this test passes, the kernel does not have it
  934.     dnl if this test fails, the kernel has it defined
  935.     AC_TRY_COMPILE([
  936.         #define __KERNEL__
  937.         #include <linux/kernel.h>
  938.         #include <linux/ioctl32.h>
  939.         int register_ioctl32_conversion(void)
  940.         {
  941.             return 0;
  942.         }
  943.     ], [],
  944.         AC_MSG_RESULT(no),
  945.         AC_MSG_RESULT(yes)
  946.         AC_DEFINE(HAVE_REGISTER_IOCTL32_CONVERSION, 1, Define if kernel has register_ioctl32_conversion),
  947.     )
  948.     fi
  949.  
  950.     AC_MSG_CHECKING(for int return value of kmem_cache_destroy)
  951.     AC_TRY_COMPILE([
  952.         #define __KERNEL__
  953.         #include <linux/slab.h>
  954.         ], [
  955.         int i = kmem_cache_destroy(NULL);
  956.         ],
  957.         AC_MSG_RESULT(yes)
  958.         AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT_RETURN, 1, Define if kmem_cache_destroy returns int),
  959.         AC_MSG_RESULT(no)
  960.     )
  961.  
  962.     dnl As of 2.6.19, combined readv/writev into aio_read and aio_write
  963.     dnl functions.  Detect this by not finding a readv member.
  964.     AC_MSG_CHECKING(for combined file_operations readv and aio_read)
  965.     AC_TRY_COMPILE([
  966.         #define __KERNEL__
  967.         #include <linux/fs.h>
  968.          ], [
  969.          struct file_operations filop = {
  970.             .readv = NULL
  971.          };
  972.         ],
  973.         AC_MSG_RESULT(no),
  974.         AC_MSG_RESULT(yes)
  975.         AC_DEFINE(HAVE_COMBINED_AIO_AND_VECTOR, 1, Define if struct file_operations has combined aio_read and readv functions),
  976.         )
  977.  
  978.     dnl Check for kzalloc
  979.     AC_MSG_CHECKING(for kzalloc)
  980.     AC_TRY_COMPILE([
  981.         #define __KERNEL__
  982.         #include <linux/slab.h>
  983.     ], [
  984.         void * a;
  985.         a = kzalloc(1024, GFP_KERNEL);
  986.     ],
  987.     AC_MSG_RESULT(yes)
  988.     AC_DEFINE(HAVE_KZALLOC, 1, Define if kzalloc exists),
  989.     AC_MSG_RESULT(no)
  990.     )
  991.  
  992.     dnl Check for two arg register_sysctl_table()
  993.     AC_MSG_CHECKING(for two arguments to register_sysctl_table)
  994.     AC_TRY_COMPILE([
  995.         #define __KERNEL__
  996.         #include <linux/sysctl.h>
  997.         #include <linux/proc_fs.h>
  998.     ], [
  999.         register_sysctl_table(NULL, 0);
  1000.     ],
  1001.     AC_MSG_RESULT(yes)
  1002.     AC_DEFINE(HAVE_TWO_ARG_REGISTER_SYSCTL_TABLE, 1, Define if register_sysctl_table takes two arguments),
  1003.     AC_MSG_RESULT(no)
  1004.     )
  1005.  
  1006.     dnl FS_IOC_GETFLAGS and FS_IOC_SETFLAGS appeared 
  1007.     dnl somewhere around 2.6.20.1 as generic versions of fs-specific flags
  1008.     AC_MSG_CHECKING(for generic FS_IOC ioctl flags)
  1009.     AC_TRY_COMPILE([
  1010.         #define __KERNEL__
  1011.         #include <linux/fs.h>
  1012.     ], [
  1013.         int flags = FS_IOC_GETFLAGS;
  1014.     ],
  1015.     AC_MSG_RESULT(yes),
  1016.     AC_DEFINE(HAVE_NO_FS_IOC_FLAGS, 1, Define if FS_IOC flags missing from fs.h)
  1017.     AC_MSG_RESULT(no)
  1018.     )
  1019.  
  1020.     dnl old linux kernels define struct page with a 'count' member, whereas
  1021.     dnl other kernels (since at least 2.6.20) define struct page with a
  1022.     dnl '_count'
  1023.     AC_MSG_CHECKING(for obsolete struct page count without underscore)
  1024.     AC_TRY_COMPILE([
  1025.         #define __KERNEL__
  1026.         #include <linux/mm.h>
  1027.     ], [
  1028.         struct page *p;
  1029.         int foo;
  1030.         foo = atomic_read(&(p)->count);
  1031.     ],
  1032.     AC_MSG_RESULT(yes)
  1033.     AC_DEFINE(HAVE_OBSOLETE_STRUCT_PAGE_COUNT_NO_UNDERSCORE, 1, Define if struct page defines a count member without leading underscore),
  1034.     AC_MSG_RESULT(no)
  1035.     )
  1036.  
  1037.     dnl old linux kernels do not have class_create and related functions
  1038.         dnl
  1039.         dnl check for class_device_destroy() to weed out RHEL4 kernels that
  1040.         dnl have some class functions but not others
  1041.     AC_MSG_CHECKING(if kernel has device classes)
  1042.     AC_TRY_COMPILE([
  1043.         #define __KERNEL__
  1044.         #include <linux/device.h>
  1045.     ], [
  1046.         class_device_destroy(NULL, "pvfs2")
  1047.     ],
  1048.     AC_MSG_RESULT(yes)
  1049.     AC_DEFINE(HAVE_KERNEL_DEVICE_CLASSES, 1, Define if kernel has device classes),
  1050.     AC_MSG_RESULT(no)
  1051.     )
  1052.  
  1053.     dnl 2.6.23 removed the destructor parameter from kmem_cache_create
  1054.     AC_MSG_CHECKING(for destructor param to kmem_cache_create)
  1055.     AC_TRY_COMPILE([
  1056.         #define __KERNEL__
  1057.         #include <linux/slab.h>
  1058.     ], [
  1059.        kmem_cache_create("config-test", 0, 0, 0, NULL, NULL);
  1060.     ],
  1061.     AC_MSG_RESULT(yes)
  1062.     AC_DEFINE(HAVE_KMEM_CACHE_CREATE_DESTRUCTOR_PARAM, 1, [Define if kernel kmem_cache_create has destructor param]),
  1063.     AC_MSG_RESULT(no)
  1064.     )
  1065.  
  1066.         dnl 2.6.27 changed the constructor parameter signature of
  1067.     dnl kmem_cache_create.  Check for this newer one-param style
  1068.         dnl If they don't match, gcc complains about
  1069.     dnl passing argument ... from incompatible pointer type, hence the
  1070.     dnl need for the -Werror.  Note that the next configure test will
  1071.         dnl determine if we have a two param constructor or not.
  1072.     tmp_cflags=$CFLAGS
  1073.     CFLAGS="$CFLAGS -Werror"
  1074.     AC_MSG_CHECKING(for one-param kmem_cache_create constructor)
  1075.     AC_TRY_COMPILE([
  1076.         #define __KERNEL__
  1077.         #include <linux/kernel.h>
  1078.         #include <linux/slab.h>
  1079.         void ctor(void *req)
  1080.         {
  1081.         }
  1082.     ], [
  1083.         kmem_cache_create("config-test", 0, 0, 0, ctor);
  1084.     ],
  1085.     AC_MSG_RESULT(yes)
  1086.     AC_DEFINE(HAVE_KMEM_CACHE_CREATE_CTOR_ONE_PARAM, 1, [Define if kernel kmem_cache_create constructor has newer-style one-parameter form]),
  1087.     AC_MSG_RESULT(no)
  1088.     )
  1089.     CFLAGS=$tmp_cflags
  1090.  
  1091.         dnl 2.6.27 changed the parameter signature of
  1092.     dnl inode_operations->permission.  Check for this newer two-param style
  1093.         dnl If they don't match, gcc complains about
  1094.     dnl passing argument ... from incompatible pointer type, hence the
  1095.     dnl need for the -Werror and -Wall.
  1096.     tmp_cflags=$CFLAGS
  1097.     CFLAGS="$CFLAGS -Werror -Wall"
  1098.     AC_MSG_CHECKING(for two param permission)
  1099.     AC_TRY_COMPILE([
  1100.         #define __KERNEL__
  1101.         #include <linux/kernel.h>
  1102.         #include <linux/slab.h>
  1103.         #include <linux/fs.h>
  1104.         #include <linux/namei.h>
  1105.         int ctor(struct inode *i, int a)
  1106.         {
  1107.             return 0;
  1108.         }
  1109.         struct inode_operations iop = {
  1110.             .permission = ctor,
  1111.         };
  1112.     ], [
  1113.     ],
  1114.     AC_MSG_RESULT(yes)
  1115.     AC_DEFINE(HAVE_TWO_PARAM_PERMISSION, 1, [Define if kernel's inode_operations has two parameters permission function]),
  1116.     AC_MSG_RESULT(no)
  1117.     )
  1118.     CFLAGS=$tmp_cflags
  1119.  
  1120.  
  1121.         dnl 2.6.24 changed the constructor parameter signature of
  1122.     dnl kmem_cache_create.  Check for this newer two-param style and
  1123.     dnl if not, assume it is old.  Note we can get away with just
  1124.     dnl struct kmem_cache (and not kmem_cache_t) as that change happened
  1125.     dnl in older kernels.  If they don't match, gcc complains about
  1126.     dnl passing argument ... from incompatible pointer type, hence the
  1127.     dnl need for the -Werror.
  1128.     tmp_cflags=$CFLAGS
  1129.     CFLAGS="$CFLAGS -Werror"
  1130.     AC_MSG_CHECKING(for two-param kmem_cache_create constructor)
  1131.     AC_TRY_COMPILE([
  1132.         #define __KERNEL__
  1133.         #include <linux/kernel.h>
  1134.         #include <linux/slab.h>
  1135.         void ctor(struct kmem_cache *cachep, void *req)
  1136.         {
  1137.         }
  1138.     ], [
  1139.         kmem_cache_create("config-test", 0, 0, 0, ctor);
  1140.     ],
  1141.     AC_MSG_RESULT(yes)
  1142.     AC_DEFINE(HAVE_KMEM_CACHE_CREATE_CTOR_TWO_PARAM, 1, [Define if kernel kmem_cache_create constructor has new-style two-parameter form]),
  1143.     AC_MSG_RESULT(no)
  1144.     )
  1145.     CFLAGS=$tmp_cflags
  1146.  
  1147.     AC_MSG_CHECKING(if kernel address_space struct has a spin_lock field named page_lock)
  1148.     AC_TRY_COMPILE([
  1149.         #define __KERNEL__
  1150.         #include <linux/fs.h>
  1151.     ], [
  1152.         struct address_space as;
  1153.         spin_lock(&as.page_lock);
  1154.     ],
  1155.     AC_MSG_RESULT(yes)
  1156.     AC_DEFINE(HAVE_SPIN_LOCK_PAGE_ADDR_SPACE_STRUCT, 1, [Define if kernel address_space struct has a spin_lock member named page_lock instead of rw_lock]),
  1157.     AC_MSG_RESULT(no)
  1158.     )
  1159.  
  1160.         tmp_cflags=$CFLAGS
  1161.         CFLAGS="$CFLAGS -Werror"
  1162.         AC_MSG_CHECKING(if kernel address_space struct has a rwlock_t field named tree_lock)
  1163.     AC_TRY_COMPILE([
  1164.         #define __KERNEL__
  1165.         #include <linux/fs.h>
  1166.     ], [
  1167.         struct address_space as;
  1168.         read_lock(&as.tree_lock);
  1169.     ],
  1170.     AC_MSG_RESULT(yes)
  1171.     AC_DEFINE(HAVE_RW_LOCK_TREE_ADDR_SPACE_STRUCT, 1, [Define if kernel address_space struct has a rw_lock_t member named tree_lock]),
  1172.     AC_MSG_RESULT(no)
  1173.     )
  1174.         CFLAGS=$tmp_cflags
  1175.  
  1176.         tmp_cflags=$CFLAGS
  1177.         CFLAGS="$CFLAGS -Werror"
  1178.         AC_MSG_CHECKING(if kernel address_space struct has a spinlock_t field named tree_lock)
  1179.     AC_TRY_COMPILE([
  1180.         #define __KERNEL__
  1181.         #include <linux/fs.h>
  1182.     ], [
  1183.         struct address_space as;
  1184.         spin_lock(&as.tree_lock);
  1185.     ],
  1186.     AC_MSG_RESULT(yes)
  1187.     AC_DEFINE(HAVE_SPIN_LOCK_TREE_ADDR_SPACE_STRUCT, 1, [Define if kernel address_space struct has a spin_lock_t member named tree_lock]),
  1188.     AC_MSG_RESULT(no)
  1189.     )
  1190.         CFLAGS=$tmp_cflags
  1191.  
  1192.     AC_MSG_CHECKING(if kernel address_space struct has a priv_lock field - from RT linux)
  1193.     AC_TRY_COMPILE([
  1194.         #define __KERNEL__
  1195.         #include <linux/fs.h>
  1196.     ], [
  1197.         struct address_space as;
  1198.         spin_lock(&as.priv_lock);
  1199.     ],
  1200.     AC_MSG_RESULT(yes)
  1201.     AC_DEFINE(HAVE_RT_PRIV_LOCK_ADDR_SPACE_STRUCT, 1, [Define if kernel address_space struct has a spin_lock for private data instead of rw_lock -- used by RT linux]),
  1202.     AC_MSG_RESULT(no)
  1203.     )
  1204.  
  1205.     AC_MSG_CHECKING(if kernel defines mapping_nrpages macro - from RT linux)
  1206.     AC_TRY_COMPILE([
  1207.         #define __KERNEL__
  1208.         #include <linux/fs.h>
  1209.     ], [
  1210.         struct address_space idata;
  1211.         int i = mapping_nrpages(&idata);
  1212.     ],
  1213.     AC_MSG_RESULT(yes)
  1214.     AC_DEFINE(HAVE_MAPPING_NRPAGES_MACRO, 1, [Define if kernel defines mapping_nrpages macro -- defined by RT linux]),
  1215.     AC_MSG_RESULT(no)
  1216.     )
  1217.  
  1218.     dnl Starting with 2.6.25-rc1, .read_inode goes away.
  1219.     AC_MSG_CHECKING(if kernel super_operations contains read_inode field)
  1220.     AC_TRY_COMPILE([
  1221.         #define __KERNEL__
  1222.         #include <linux/fs.h>
  1223.     ], [
  1224.         struct super_operations sops;
  1225.         sops.read_inode(NULL);
  1226.     ],
  1227.     AC_MSG_RESULT(yes)
  1228.     AC_DEFINE(HAVE_READ_INODE, 1, [Define if kernel super_operations contains read_inode field]),
  1229.     AC_MSG_RESULT(no)
  1230.     )
  1231.  
  1232.     dnl Starting with 2.6.26, drop_inode and put_inode go away
  1233.     AC_MSG_CHECKING(if kernel super_operations contains drop_inode field)
  1234.     AC_TRY_COMPILE([
  1235.         #define __KERNEL__
  1236.         #include <linux/fs.h>
  1237.     ], [
  1238.         struct super_operations sops;
  1239.         sops.drop_inode(NULL);
  1240.     ],
  1241.     AC_MSG_RESULT(yes)
  1242.     AC_DEFINE(HAVE_DROP_INODE, 1, [Define if kernel super_operations contains drop_inode field]),
  1243.     AC_MSG_RESULT(no)
  1244.     )
  1245.  
  1246.     dnl Starting with 2.6.26, drop_inode and put_inode go away
  1247.     AC_MSG_CHECKING(if kernel super_operations contains put_inode field)
  1248.     AC_TRY_COMPILE([
  1249.         #define __KERNEL__
  1250.         #include <linux/fs.h>
  1251.     ], [
  1252.         struct super_operations sops;
  1253.         sops.put_inode(NULL);
  1254.     ],
  1255.     AC_MSG_RESULT(yes)
  1256.     AC_DEFINE(HAVE_PUT_INODE, 1, [Define if kernel super_operations contains put_inode field]),
  1257.     AC_MSG_RESULT(no)
  1258.     )
  1259.  
  1260.     dnl older 2.6 kernels don't have MNT_NOATIME
  1261.     AC_MSG_CHECKING(if mount.h defines MNT_NOATIME)
  1262.     AC_TRY_COMPILE([
  1263.         #define __KERNEL__
  1264.         #include <linux/mount.h>
  1265.     ], [
  1266.         int flag = MNT_NOATIME;
  1267.     ],
  1268.     AC_MSG_RESULT(yes)
  1269.     AC_DEFINE(HAVE_MNT_NOATIME, 1, [Define if mount.h contains
  1270.     MNT_NOATIME flags]),
  1271.     AC_MSG_RESULT(no)
  1272.     )
  1273.  
  1274.     dnl older 2.6 kernels don't have MNT_NODIRATIME
  1275.     AC_MSG_CHECKING(if mount.h defines MNT_NODIRATIME)
  1276.     AC_TRY_COMPILE([
  1277.         #define __KERNEL__
  1278.         #include <linux/mount.h>
  1279.     ], [
  1280.         int flag = MNT_NODIRATIME;
  1281.     ],
  1282.     AC_MSG_RESULT(yes)
  1283.     AC_DEFINE(HAVE_MNT_NODIRATIME, 1, [Define if mount.h contains
  1284.     MNT_NODIRATIME flags]),
  1285.     AC_MSG_RESULT(no)
  1286.     )
  1287.  
  1288.         dnl newer 2.6 kernels (2.6.28) use d_obtain_alias instead of d_alloc_anon
  1289.         AC_MSG_CHECKING(for d_alloc_anon)
  1290.         AC_TRY_COMPILE([
  1291.                 #define __KERNEL__
  1292.                 #include <linux/dcache.h>
  1293.         ], [
  1294.                 struct inode *i;
  1295.                 d_alloc_anon(i);
  1296.         ],
  1297.         AC_MSG_RESULT(yes)
  1298.         AC_DEFINE(HAVE_D_ALLOC_ANON, 1, [Define if dcache.h contains 
  1299.                   d_alloc_annon]),
  1300.         AC_MSG_RESULT(no)
  1301.         )
  1302.  
  1303.         AC_MSG_CHECKING(for s_dirty in struct super_block)
  1304.         AC_TRY_COMPILE([
  1305.                 #define __KERNEL__
  1306.                 #include <linux/fs.h>
  1307.         ], [
  1308.                 struct super_block *s;
  1309.                 list_empty(&s->s_dirty);
  1310.         ],
  1311.         AC_MSG_RESULT(yes)
  1312.         AC_DEFINE(HAVE_SB_DIRTY_LIST, 1, [Define if struct super_block has s_dirty list]),
  1313.         AC_MSG_RESULT(no)
  1314.         )
  1315.  
  1316.         dnl newer 2.6 kernels (2.6.29-ish) use current_fsuid() macro instead
  1317.         dnl of accessing task struct fields directly
  1318.         tmp_cflags=$CFLAGS
  1319.         CFLAGS="$CFLAGS -Werror"
  1320.         AC_MSG_CHECKING(for current_fsuid)
  1321.         AC_TRY_COMPILE([
  1322.                 #define __KERNEL__
  1323.                 #include <linux/sched.h>
  1324.                 #include <linux/cred.h>
  1325.         ], [
  1326.                 int uid = current_fsuid();
  1327.         ],
  1328.         AC_MSG_RESULT(yes)
  1329.         AC_DEFINE(HAVE_CURRENT_FSUID, 1, [Define if cred.h contains current_fsuid]),
  1330.         AC_MSG_RESULT(no)
  1331.         )
  1332.         CFLAGS=$tmp_cflags
  1333.  
  1334.         dnl 2.6.32 added a mandatory name field to the bdi structure
  1335.         AC_MSG_CHECKING(if kernel backing_dev_info struct has a name field)
  1336.     AC_TRY_COMPILE([
  1337.         #define __KERNEL__
  1338.         #include <linux/fs.h>
  1339.         #include <linux/backing-dev.h>
  1340.     ], [
  1341.                 struct backing_dev_info foo = 
  1342.                 {
  1343.                     .name = "foo"
  1344.                 };
  1345.     ],
  1346.     AC_MSG_RESULT(yes)
  1347.     AC_DEFINE(HAVE_BACKING_DEV_INFO_NAME, 1, [Define if kernel backing_dev_info struct has a name field]),
  1348.     AC_MSG_RESULT(no)
  1349.     )
  1350.  
  1351.         dnl some 2.6 kernels have functions to explicitly initialize bdi structs
  1352.         tmp_cflags=$CFLAGS
  1353.         CFLAGS="$CFLAGS -Werror"
  1354.         AC_MSG_CHECKING(for bdi_init)
  1355.         AC_TRY_COMPILE([
  1356.                 #define __KERNEL__
  1357.         #include <linux/fs.h>
  1358.         #include <linux/backing-dev.h>
  1359.         ], [
  1360.                 int ret = bdi_init(NULL);
  1361.         ],
  1362.         AC_MSG_RESULT(yes)
  1363.         AC_DEFINE(HAVE_BDI_INIT, 1, [Define if bdi_init function is present]),
  1364.         AC_MSG_RESULT(no)
  1365.         )
  1366.         CFLAGS=$tmp_cflags
  1367.  
  1368.  
  1369.     dnl 2.6.33 API change,
  1370.     dnl Removed .ctl_name from struct ctl_table.
  1371.         tmp_cflags=$CFLAGS
  1372.         CFLAGS="$CFLAGS -Werror"
  1373.     AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
  1374.     AC_TRY_COMPILE([
  1375.         #define __KERNEL__
  1376.         #include <linux/sysctl.h>
  1377.                 static struct ctl_table c = { .ctl_name = 0, };
  1378.     ],[ ],
  1379.     AC_MSG_RESULT(yes)
  1380.     AC_DEFINE(HAVE_CTL_NAME, 1, Define if struct ctl_table has ctl_name member),
  1381.     AC_MSG_RESULT(no)
  1382.     )
  1383.  
  1384.     dnl Removed .strategy from struct ctl_table.
  1385.     AC_MSG_CHECKING([whether struct ctl_table has strategy])
  1386.     AC_TRY_COMPILE([
  1387.         #define __KERNEL__
  1388.         #include <linux/sysctl.h>
  1389.                 static struct ctl_table c = { .strategy = 0, };
  1390.     ], [ ],
  1391.     AC_MSG_RESULT(yes)
  1392.     AC_DEFINE(HAVE_STRATEGY_NAME, 1, Define if struct ctl_table has strategy member),
  1393.     AC_MSG_RESULT(no)
  1394.     )
  1395.         CFLAGS=$tmp_cflags
  1396.  
  1397.     dnl 2.6.33 changed the parameter signature of xattr_handler get 
  1398.     dnl member functions to have a fifth argument and changed the first
  1399.     dnl parameter from struct inode to struct dentry. if the test fails
  1400.     dnl assume the old 4 param with struct inode
  1401.     tmp_cflags=$CFLAGS
  1402.     CFLAGS="$CFLAGS -Werror"
  1403.     AC_MSG_CHECKING(for five-param xattr_handler.get)
  1404.     AC_TRY_COMPILE([
  1405.         #define __KERNEL__
  1406.         #include <linux/dcache.h>
  1407.         #include <linux/xattr.h>
  1408.         static struct xattr_handler x;
  1409.         static int get_xattr_h( struct dentry *d, const char *n, 
  1410.                     void *b, size_t s, int h)
  1411.         { return 0; }
  1412.     ], 
  1413.     [ 
  1414.         x.get = get_xattr_h;
  1415.     ],
  1416.     AC_MSG_RESULT(yes)
  1417.     AC_DEFINE(HAVE_XATTR_HANDLER_GET_FIVE_PARAM, 1, [Define if kernel xattr_handle get function has dentry as first parameter and a fifth parameter]),
  1418.     AC_MSG_RESULT(no)
  1419.     )
  1420.  
  1421.     dnl 2.6.33 changed the parameter signature of xattr_handler set 
  1422.     dnl member functions to have a sixth argument and changed the first
  1423.     dnl parameter from struct inode to struct dentry. if the test fails
  1424.     dnl assume the old 5 param with struct inode
  1425.     tmp_cflags=$CFLAGS
  1426.     CFLAGS="$CFLAGS -Werror"
  1427.     AC_MSG_CHECKING(for six-param xattr_handler.set)
  1428.     AC_TRY_COMPILE([
  1429.         #define __KERNEL__
  1430.         #include <linux/dcache.h>
  1431.         #include <linux/xattr.h>
  1432.         static struct xattr_handler x;
  1433.         static int set_xattr_h( struct dentry *d, const char *n, 
  1434.                     const void *b, size_t s, int f, int h)
  1435.         { return 0; }
  1436.     ], 
  1437.     [ 
  1438.         x.set = set_xattr_h;
  1439.     ],
  1440.     AC_MSG_RESULT(yes)
  1441.     AC_DEFINE(HAVE_XATTR_HANDLER_SET_SIX_PARAM, 1, [Define if kernel xattr_handle set function has dentry as first parameter and a sixth parameter]),
  1442.     AC_MSG_RESULT(no)
  1443.     )
  1444.         CFLAGS=$tmp_cflags
  1445.  
  1446.     dnl xattr_handler is also a const
  1447.     tmp_cflags=$CFLAGS
  1448.     CFLAGS="$CFLAGS -Werror"
  1449.     AC_MSG_CHECKING(for const s_xattr member in super_block struct)
  1450.     AC_TRY_COMPILE([
  1451.         #define __KERNEL__
  1452.         #include <linux/fs.h>
  1453.         #include <linux/xattr.h>
  1454.         struct super_block sb;
  1455.                 const struct xattr_handler *x[] = { NULL };
  1456.     ], 
  1457.     [ 
  1458.             sb.s_xattr = x;
  1459.     ],
  1460.     AC_MSG_RESULT(yes)
  1461.     AC_DEFINE(HAVE_CONST_S_XATTR_IN_SUPERBLOCK, 1, [Define if s_xattr member of super_block struct is const]),
  1462.     AC_MSG_RESULT(no)
  1463.     )
  1464.         CFLAGS=$tmp_cflags
  1465.  
  1466.         dnl early 2.6 kernels do not contain true/false enum in stddef.h
  1467.     tmp_cflags=$CFLAGS
  1468.     CFLAGS="$CFLAGS -Werror"
  1469.     AC_MSG_CHECKING(stddef.h true/false enum)
  1470.     AC_TRY_COMPILE([
  1471.         #define __KERNEL__
  1472.         #include <linux/stddef.h>
  1473.                 int f = true;
  1474.     ], 
  1475.     [ ],
  1476.     AC_MSG_RESULT(yes)
  1477.     AC_DEFINE(HAVE_TRUE_FALSE_ENUM, 1, [Define if kernel stddef has true/false enum]),
  1478.     AC_MSG_RESULT(no)
  1479.     )
  1480.         CFLAGS=$tmp_cflags
  1481.  
  1482.  
  1483.     dnl fsync no longer has a dentry second parameter
  1484.     tmp_cflags=$CFLAGS
  1485.     CFLAGS="$CFLAGS -Werror"
  1486.     AC_MSG_CHECKING(for dentry argument in fsync)
  1487.     AC_TRY_COMPILE([
  1488.         #define __KERNEL__
  1489.         #include <linux/fs.h>
  1490.         static struct file_operations f;
  1491.         static int local_fsync(struct file *f, struct dentry *d, int i)
  1492.         { return 0; }
  1493.     ], 
  1494.     [ 
  1495.         f.fsync = local_fsync;
  1496.     ],
  1497.     AC_MSG_RESULT(yes)
  1498.     AC_DEFINE(HAVE_FSYNC_DENTRY_PARAM, 1, [Define if fsync function in file_operations struct wants a dentry pointer as the second parameter]),
  1499.     AC_MSG_RESULT(no)
  1500.     )
  1501.         CFLAGS=$tmp_cflags
  1502.  
  1503.     CFLAGS=$oldcflags
  1504.  
  1505. ])
  1506.  
  1507.  
  1508. AC_DEFUN([AX_BERKELEY_DB],
  1509. [
  1510.     dbpath=ifelse([$1], ,,$1)
  1511.  
  1512.     DB_LDFLAGS=
  1513.     dnl 
  1514.     dnl if the db is specified, try to link with -ldb
  1515.     dnl otherwise try -ldb4, then -ldb3, then -ldb
  1516.     dnl $lib set to notfound on link failure
  1517.     dnl    
  1518.     AC_MSG_CHECKING([for db library])
  1519.     oldlibs=$LIBS
  1520.     lib=notfound
  1521.  
  1522.     if test "x$dbpath" != "x" ; then
  1523.     oldcflags=$CFLAGS
  1524.     for dbheader in db4 db3 notfound; do
  1525.         AC_COMPILE_IFELSE(
  1526.             [#include "$dbpath/include/$dbheader/db.h"],
  1527.             [DB_CFLAGS="-I$dbpath/include/$dbheader/"
  1528.              break])
  1529.     done
  1530.  
  1531.     if test "x$dbheader" = "xnotfound"; then
  1532.         AC_COMPILE_IFELSE(
  1533.             [#include "$dbpath/include/db.h"],
  1534.             [DB_CFLAGS="-I$dbpath/include/"],
  1535.             [AC_MSG_FAILURE(
  1536.                 Invalid libdb path specified. No db.h found.)])
  1537.     fi
  1538.  
  1539.         DB_LDFLAGS="-L${dbpath}/lib"
  1540.     LDFLAGS="$DB_LDFLAGS ${LDFLAGS}"
  1541.  
  1542.     LIBS="${oldlibs} -ldb -lpthread"
  1543.     DB_LIB="-ldb"
  1544.     CFLAGS="$DB_CFLAGS $oldcflags"
  1545.     AC_TRY_LINK(
  1546.         [#include <db.h>],
  1547.         [DB *dbp; db_create(&dbp, NULL, 0);],
  1548.         lib=db)
  1549.     CFLAGS=$oldcflags
  1550.     
  1551.     else
  1552.         for lib in db4  db3  db  notfound; do
  1553.            LIBS="${oldlibs} -l$lib -lpthread"
  1554.            DB_LIB="-l$lib"
  1555.            AC_TRY_LINK(
  1556.                   [#include <db.h>],
  1557.                   [DB *dbp; db_create(&dbp, NULL, 0);],
  1558.                   [break])
  1559.         done
  1560.     fi
  1561.  
  1562.     dnl reset LIBS value and just report through DB_LIB
  1563.     LIBS=$oldlibs 
  1564.     if test "x$lib" = "xnotfound" ; then
  1565.            AC_MSG_ERROR(could not find DB libraries)
  1566.     else
  1567.            AC_MSG_RESULT($lib)
  1568.     fi
  1569.     AC_SUBST(DB_CFLAGS)    
  1570.     AC_SUBST(DB_LIB)
  1571.     
  1572.     dnl See if we have a new enough version of Berkeley DB; needed for
  1573.     dnl    compilation of trove-dbpf component
  1574.     dnl AC_MSG_CHECKING(whether version of Berkeley DB is new enough)
  1575.     dnl       AC_TRY_COMPILE([
  1576.     dnl       #include <db.h>
  1577.     dnl       ], [
  1578.     dnl       #if DB_VERSION_MAJOR < 4
  1579.     dnl              #error "DB_VERSION_MAJOR < 4; need newer Berkeley DB implementation"
  1580.     dnl       #endif
  1581.     dnl       ], AC_MSG_RESULT(yes),
  1582.     dnl       AC_MSG_RESULT(no)
  1583.     dnl              AC_MSG_ERROR(Need newer (4.x.x or later) version of Berkeley DB.
  1584.     dnl try: http://www.sleepycat.com/download/index.shtml
  1585.     dnl or: /parl/pcarns/rpms/db4-4.0.14-1mdk.src.rpm (to build rpm))
  1586.     dnl       )
  1587.     
  1588.     dnl Test to check for DB_ENV variable to error callback fn.  Then
  1589.     dnl test to see if third parameter must be const (related but not 
  1590.     dnl exactly the same).
  1591.     AC_MSG_CHECKING(for dbenv parameter to DB error callback function)
  1592.     oldcflags=$CFLAGS
  1593.     CFLAGS="$USR_CFLAGS $DB_CFLAGS -Werror"
  1594.     AC_TRY_COMPILE([
  1595.     #include <db.h>
  1596.     
  1597.     void error_callback_fn(const DB_ENV *dbenv,
  1598.                            const char *prefix,
  1599.                            const char *message)
  1600.     {
  1601.         return;
  1602.     }
  1603.     ], [
  1604.     DB *db;
  1605.     
  1606.     db->set_errcall(db, error_callback_fn);
  1607.     ], AC_MSG_RESULT(yes)
  1608.     AC_DEFINE(HAVE_DBENV_PARAMETER_TO_DB_ERROR_CALLBACK, 1,
  1609.     Define if DB error callback function takes dbenv parameter)
  1610.     have_dbenv_parameter_to_db_error_callback=yes,
  1611.     AC_MSG_RESULT(no)
  1612.     have_dbenv_parameter_to_db_error_callback=no)
  1613.     
  1614.     if test "x$have_dbenv_parameter_to_db_error_callback" = "xyes" ; then
  1615.         dnl Test if compilation succeeds without const; we expect that it will
  1616.         dnl not.
  1617.         dnl NOTE: still using -Werror!
  1618.         AC_MSG_CHECKING(if third parameter to error callback function is const)
  1619.         AC_TRY_COMPILE([
  1620.         #include <db.h>
  1621.         
  1622.         void error_callback_fn(const DB_ENV *dbenv,
  1623.                                const char *prefix,
  1624.                                char *message)
  1625.         {
  1626.             return;
  1627.         }
  1628.         ], [
  1629.         DB *db;
  1630.         
  1631.         db->set_errcall(db, error_callback_fn);
  1632.         ], AC_MSG_RESULT(no),
  1633.         AC_MSG_RESULT(yes)
  1634.         AC_DEFINE(HAVE_CONST_THIRD_PARAMETER_TO_DB_ERROR_CALLBACK, 1,
  1635.         Define if third param (message) to DB error callback function is const))
  1636.     fi
  1637.     
  1638.     CFLAGS="$USR_CFLAGS $DB_CFLAGS -Werror"    
  1639.     dnl Test to check for unknown third param to DB stat (four params 
  1640.     dnl total).  The unknown parameter is a function ptr so that the
  1641.     dnl the user can pass in a replcaement for malloc.
  1642.     dnl Note: this is a holdover from relatively old DB implementations,
  1643.     dnl while the txnid parameter is new.  So we don't test for the old
  1644.     dnl unknown parameter if we found the new one.
  1645.     AC_MSG_CHECKING(for DB stat with malloc function ptr)
  1646.     AC_TRY_COMPILE([
  1647.       #include <db.h>
  1648.       #include <stdlib.h>
  1649.       ], [
  1650.       int ret = 0;
  1651.       DB *db = db;
  1652.       int dummy = 0;
  1653.       u_int32_t flags = 0;
  1654.         
  1655.       ret = db->stat(db, &dummy, malloc, flags);
  1656.       ], AC_MSG_RESULT(yes)
  1657.     AC_DEFINE(HAVE_UNKNOWN_PARAMETER_TO_DB_STAT, 1,
  1658.     Define if DB stat function takes malloc function ptr)
  1659.     have_db_stat_malloc=yes,
  1660.     AC_MSG_RESULT(no)
  1661.     have_db_stat_malloc=no)
  1662.  
  1663.     dnl Test to check for txnid parameter to DB stat (DB 4.3.xx+)
  1664.     if test "x$have_db_stat_malloc" = "xno" ; then
  1665.     
  1666.        AC_MSG_CHECKING(for txnid parameter to DB stat function)
  1667.        AC_TRY_COMPILE([
  1668.        #include <db.h>
  1669.        ], [
  1670.        int ret = 0;
  1671.        DB *db = db;
  1672.        DB_TXN *txnid = txnid;
  1673.        u_int32_t flags = 0;
  1674.     
  1675.         ret = db->stat(db, txnid, NULL, flags);
  1676.         ], AC_MSG_RESULT(yes)
  1677.         AC_DEFINE(HAVE_TXNID_PARAMETER_TO_DB_STAT, 1, 
  1678.         Define if DB stat function takes txnid parameter)
  1679.         have_txnid_param_to_stat=yes,
  1680.         AC_MSG_RESULT(no)
  1681.         have_txnid_param_to_stat=no)
  1682.     
  1683.     fi
  1684.     
  1685.     dnl Test to check for txnid parameter to DB open (DB4.1+)
  1686.     AC_MSG_CHECKING(for txnid parameter to DB open function)
  1687.     AC_TRY_COMPILE([
  1688.     #include <db.h>
  1689.     ], [
  1690.     int ret = 0;
  1691.     DB *db = NULL;
  1692.     DB_TXN *txnid = NULL;
  1693.     char *file = NULL;
  1694.     char *database = NULL;
  1695.     DBTYPE type = 0;
  1696.     u_int32_t flags = 0;
  1697.     int mode = 0;
  1698.     
  1699.     ret = db->open(db, txnid, file, database, type, flags, mode);
  1700.     ], AC_MSG_RESULT(yes)
  1701.     AC_DEFINE(HAVE_TXNID_PARAMETER_TO_DB_OPEN, 1,
  1702.     Define if DB open function takes a txnid parameter),
  1703.     AC_MSG_RESULT(no))
  1704.     
  1705.     dnl check for DB_DIRTY_READ (it is not in db-3.2.9, for example)
  1706.     AC_MSG_CHECKING(for DB_DIRTY_READ flag)
  1707.     AC_TRY_COMPILE([
  1708.     #include <db.h>
  1709.     ], [
  1710.     u_int32_t flags = DB_DIRTY_READ;
  1711.     ], AC_MSG_RESULT(yes)
  1712.     AC_DEFINE(HAVE_DB_DIRTY_READ, 1, [Define if db library has DB_DIRTY_READ flag]),
  1713.     AC_MSG_RESULT(no))
  1714.  
  1715.     dnl check for DB_BUFFER_SMALL (it is returned by dbp->get in db-4.4 and up)
  1716.     AC_MSG_CHECKING(for DB_BUFFER_SMALL error)
  1717.     AC_TRY_COMPILE([
  1718.     #include <db.h>
  1719.     ], [
  1720.     int res = DB_BUFFER_SMALL;
  1721.     res++;
  1722.     ], AC_MSG_RESULT(yes)
  1723.     AC_DEFINE(HAVE_DB_BUFFER_SMALL, 1, [Define if db library has DB_BUFFER_SMALL error]),
  1724.     AC_MSG_RESULT(no))
  1725.  
  1726.     dnl Test to check for db->get_pagesize
  1727.     AC_MSG_CHECKING(for berkeley db get_pagesize function)
  1728.     AC_TRY_COMPILE([
  1729.     #include <db.h>
  1730.     ], [
  1731.     int ret = 0;
  1732.     DB *db = NULL;
  1733.     int pagesize;
  1734.     
  1735.     ret = db->get_pagesize(db, &pagesize);
  1736.     ], AC_MSG_RESULT(yes)
  1737.     AC_DEFINE(HAVE_DB_GET_PAGESIZE, 1, [Define if DB has get_pagesize function]),
  1738.     AC_MSG_RESULT(no))
  1739.     
  1740.     CFLAGS="$oldcflags"    
  1741. ])
  1742.  
  1743.  
  1744. AC_DEFUN([AX_CHECK_NEEDS_LIBRT],
  1745. [
  1746.  
  1747. AC_MSG_CHECKING([if server lib needs -lrt])
  1748. AC_TRY_LINK(
  1749.     [#include <stdlib.h>
  1750.      #include <unistd.h>
  1751.      #include <aio.h>],
  1752.     [lio_listio(LIO_NOWAIT, NULL, 0, NULL);],
  1753.     [AC_MSG_RESULT(no)],
  1754.     [
  1755.         oldlibs=$LIBS
  1756.         LIBS="$LIBS -lrt"
  1757.         AC_TRY_LINK(
  1758.             [#include <stdlib.h>
  1759.              #include <unistd.h>
  1760.              #include <aio.h>],
  1761.             [lio_listio(LIO_NOWAIT, NULL, 0, NULL);],
  1762.             [NEEDS_LIBRT=1
  1763.              AC_SUBST(NEEDS_LIBRT)
  1764.              AC_MSG_RESULT(yes)],
  1765.             [AC_MSG_ERROR(failed attempting to link lio_listio)])
  1766.         LIBS=$oldlibs
  1767.     ])
  1768. ])
  1769.  
  1770. #
  1771. # Configure rules for GM
  1772. #
  1773. # Copyright (C) 2008 Pete Wyckoff <pw@osc.edu>
  1774. #
  1775. # See COPYING in top-level directory.
  1776. #
  1777. AC_DEFUN([AX_GM],
  1778. [
  1779.     dnl Configure options for GM install path.
  1780.     dnl --with-gm=<dir> is shorthand for
  1781.     dnl    --with-gm-includes=<dir>/include
  1782.     dnl    --with-gm-libs=<dir>/lib  (or lib64 if that exists)
  1783.     gm_home=
  1784.     AC_ARG_WITH(gm,
  1785. [  --with-gm=<dir>         Location of the GM install (default no GM)],
  1786.     if test -z "$withval" -o "$withval" = yes ; then
  1787.         AC_MSG_ERROR([Option --with-gm requires the path to your GM tree.])
  1788.     elif test "$withval" != no ; then
  1789.         gm_home="$withval"
  1790.     fi
  1791.     )
  1792.     AC_ARG_WITH(gm-includes,
  1793. [  --with-gm-includes=<dir>
  1794.                           Location of the GM includes],
  1795.     if test -z "$withval" -o "$withval" = yes ; then
  1796.         AC_MSG_ERROR([Option --with-gm-includes requires path to GM headers.])
  1797.     elif test "$withval" != no ; then
  1798.         GM_INCDIR="$withval"
  1799.     fi
  1800.     )
  1801.     AC_ARG_WITH(gm-libs,
  1802. [  --with-gm-libs=<dir>    Location of the GM libraries],
  1803.     if test -z "$withval" -o "$withval" = yes ; then
  1804.         AC_MSG_ERROR([Option --with-gm-libs requires path to GM libraries.])
  1805.     elif test "$withval" != no ; then
  1806.         GM_LIBDIR="$withval"
  1807.     fi
  1808.     )
  1809.     dnl If supplied the incls and libs explicitly, use them, else populate them
  1810.     dnl using guesses from the --with-gm dir.
  1811.     if test -n "$gm_home" ; then
  1812.     if test -z "$GM_INCDIR"; then
  1813.         GM_INCDIR=$gm_home/include
  1814.     fi
  1815.     if test -z "$GM_LIBDIR"; then
  1816.         GM_LIBDIR=$gm_home/lib64
  1817.         if test ! -d "$GM_LIBDIR" ; then
  1818.         GM_LIBDIR=$gm_home/lib
  1819.         fi
  1820.     fi
  1821.     fi
  1822.     dnl If anything GM-ish was set, go look for header.
  1823.     if test -n "$GM_INCDIR$GM_LIBDIR" ; then
  1824.     save_cppflags="$CPPFLAGS"
  1825.     CPPFLAGS="$CPPFLAGS -I$GM_INCDIR -I$GM_INCDIR/gm"
  1826.     AC_CHECK_HEADER(gm.h,, AC_MSG_ERROR([Header gm.h not found.]))
  1827.     dnl Run test is not possible on a machine that does not have a GM NIC.
  1828.     dnl Link test would work, but just check for existence.
  1829.     if test ! -f $GM_LIBDIR/libgm.so ; then
  1830.         if test ! -f $GM_LIBDIR/libgm.a ; then
  1831.         AC_MSG_ERROR([Neither GM library libgm.so or libgm.a found.])
  1832.         fi
  1833.     fi
  1834.     BUILD_GM=1
  1835.     CPPFLAGS="$save_cppflags"
  1836.     fi
  1837.     AC_SUBST(BUILD_GM)
  1838.     AC_SUBST(GM_INCDIR)
  1839.     AC_SUBST(GM_LIBDIR)
  1840. ])
  1841.  
  1842. dnl vim: set ft=config :
  1843.  
  1844. #
  1845. # Configure rules for MX
  1846. #
  1847. # Copyright (C) 2008 Pete Wyckoff <pw@osc.edu>
  1848. #
  1849. # See COPYING in top-level directory.
  1850. #
  1851. AC_DEFUN([AX_MX],
  1852. [
  1853.     dnl Configure options for MX install path.
  1854.     dnl --with-mx=<dir> is shorthand for
  1855.     dnl    --with-mx-includes=<dir>/include
  1856.     dnl    --with-mx-libs=<dir>/lib  (or lib64 if that exists)
  1857.     mx_home=
  1858.     AC_ARG_WITH(mx,
  1859. [  --with-mx=<dir>         Location of the MX install (default no MX)],
  1860.     if test -z "$withval" -o "$withval" = yes ; then
  1861.         AC_MSG_ERROR([Option --with-mx requires the path to your MX tree.])
  1862.     elif test "$withval" != no ; then
  1863.         mx_home="$withval"
  1864.     fi
  1865.     )
  1866.     AC_ARG_WITH(mx-includes,
  1867. [  --with-mx-includes=<dir>
  1868.                           Location of the MX includes],
  1869.     if test -z "$withval" -o "$withval" = yes ; then
  1870.         AC_MSG_ERROR([Option --with-mx-includes requires path to MX headers.])
  1871.     elif test "$withval" != no ; then
  1872.         MX_INCDIR="$withval"
  1873.     fi
  1874.     )
  1875.     AC_ARG_WITH(mx-libs,
  1876. [  --with-mx-libs=<dir>    Location of the MX libraries],
  1877.     if test -z "$withval" -o "$withval" = yes ; then
  1878.         AC_MSG_ERROR([Option --with-mx-libs requires path to MX libraries.])
  1879.     elif test "$withval" != no ; then
  1880.         MX_LIBDIR="$withval"
  1881.     fi
  1882.     )
  1883.     dnl If supplied the incls and libs explicitly, use them, else populate them
  1884.     dnl using guesses from the --with-mx dir.
  1885.     if test -n "$mx_home" ; then
  1886.     if test -z "$MX_INCDIR"; then
  1887.         MX_INCDIR=$mx_home/include
  1888.     fi
  1889.     if test -z "$MX_LIBDIR"; then
  1890.         MX_LIBDIR=$mx_home/lib64
  1891.         if test ! -d "$MX_LIBDIR" ; then
  1892.         MX_LIBDIR=$mx_home/lib
  1893.         fi
  1894.     fi
  1895.     fi
  1896.     dnl If anything MX-ish was set, go look for header.
  1897.     if test -n "$MX_INCDIR$MX_LIBDIR" ; then
  1898.     save_cppflags="$CPPFLAGS"
  1899.     CPPFLAGS="$CPPFLAGS -I$MX_INCDIR -I$MX_INCDIR/mx"
  1900.     AC_CHECK_HEADER(myriexpress.h,,
  1901.             AC_MSG_ERROR([Header myriexpress.h not found.]))
  1902.     dnl Run test is not possible on a machine that does not have a MX NIC.
  1903.     dnl Link test would work, but just check for existence.
  1904.     if test ! -f $MX_LIBDIR/libmyriexpress.so ; then
  1905.         if test ! -f $MX_LIBDIR/libmyriexpress.a ; then
  1906.         AC_MSG_ERROR([Neither MX library libmyriexpress.so or libmyriexpress.a found.])
  1907.         fi
  1908.     fi
  1909.     BUILD_MX=1
  1910.     CPPFLAGS="$save_cppflags"
  1911.     fi
  1912.     AC_SUBST(BUILD_MX)
  1913.     AC_SUBST(MX_INCDIR)
  1914.     AC_SUBST(MX_LIBDIR)
  1915.  
  1916.     if test -n "$BUILD_MX" ; then
  1917.         dnl Check for existence of mx_decompose_endpoint_addr2
  1918.         save_ldflags="$LDFLAGS"
  1919.         LDFLAGS="-L$MX_LIBDIR $LDFLAGS"
  1920.     save_libs="$LIBS"
  1921.     LIBS="-lmyriexpress -lpthread $LIBS"
  1922.         save_cppflags="$CPPFLAGS"
  1923.         CPPFLAGS="$CPPFLAGS -I$MX_INCDIR"
  1924.  
  1925.         AC_MSG_CHECKING(for mx_decompose_endpoint_addr2)
  1926.         AC_TRY_LINK([
  1927.             #include "mx_extensions.h"
  1928.             #include <stdlib.h>
  1929.         ], [ 
  1930.             mx_endpoint_addr_t epa;
  1931.             mx_decompose_endpoint_addr2(epa, NULL, NULL, NULL);
  1932.         ],
  1933.             AC_MSG_RESULT(yes),
  1934.             AC_MSG_RESULT(no)
  1935.         AC_MSG_ERROR([Function mx_decompose_endpoint_addr2() not found.])
  1936.         )
  1937.  
  1938.         LDFLAGS="$save_ldflags"
  1939.         CPPFLAGS="$save_cppflags"
  1940.         LIBS="$save_libs"
  1941.     fi
  1942. ])
  1943.  
  1944. dnl vim: set ft=config :
  1945.  
  1946. AC_DEFUN([AX_IB],
  1947. [
  1948.     dnl Configure options for IB install path.
  1949.     dnl --with-ib=<dir> is shorthand for
  1950.     dnl    --with-ib-includes=<dir>/include
  1951.     dnl    --with-ib-libs=<dir>/lib  (or lib64 if that exists)
  1952.     ib_home=
  1953.     AC_ARG_WITH(ib,
  1954.     [  --with-ib=<dir>         Location of the IB installation (default no IB)],
  1955.     if test -z "$withval" -o "$withval" = yes ; then
  1956.         AC_MSG_ERROR([Option --with-ib requires the path to your IB tree.])
  1957.     elif test "$withval" != no ; then
  1958.         ib_home="$withval"
  1959.     fi
  1960.     )
  1961.     AC_ARG_WITH(ib-includes,
  1962. [  --with-ib-includes=<dir>
  1963.                           Location of the IB includes],
  1964.     if test -z "$withval" -o "$withval" = yes ; then
  1965.         AC_MSG_ERROR([Option --with-ib-includes requires path to IB headers.])
  1966.     elif test "$withval" != no ; then
  1967.         IB_INCDIR="$withval"
  1968.     fi
  1969.     )
  1970.     AC_ARG_WITH(ib-libs,
  1971. [  --with-ib-libs=<dir>    Location of the IB libraries],
  1972.     if test -z "$withval" -o "$withval" = yes ; then
  1973.         AC_MSG_ERROR([Option --with-ib-libs requires path to IB libraries.])
  1974.     elif test "$withval" != no ; then
  1975.         IB_LIBDIR="$withval"
  1976.     fi
  1977.     )
  1978.     dnl If supplied the incls and libs explicitly, use them, else populate them
  1979.     dnl using guesses from the --with-ib dir.
  1980.     if test -n "$ib_home" ; then
  1981.     if test -z "$IB_INCDIR"; then
  1982.         IB_INCDIR=$ib_home/include
  1983.     fi
  1984.     if test -z "$IB_LIBDIR"; then
  1985.         IB_LIBDIR=$ib_home/lib64
  1986.         if test ! -d "$IB_LIBDIR" ; then
  1987.         IB_LIBDIR=$ib_home/lib
  1988.         fi
  1989.     fi
  1990.     fi
  1991.     dnl If anything IB-ish was set, go look for header.
  1992.     if test -n "$IB_INCDIR$IB_LIBDIR" ; then
  1993.     save_cppflags="$CPPFLAGS"
  1994.     CPPFLAGS="$CPPFLAGS -I$IB_INCDIR"
  1995.     AC_CHECK_HEADER(vapi.h,, AC_MSG_ERROR([Header vapi.h not found.]))
  1996.     dnl Run test is not possible on a machine that does not have an IB NIC,
  1997.     dnl and link test is hard because we need so many little libraries.   Bail
  1998.     dnl and just check for existence; full library list is in Makefile.in.
  1999.     if test ! -f $IB_LIBDIR/libvapi.so ; then
  2000.         if test ! -f $IB_LIBDIR/libvapi.a ; then
  2001.         AC_MSG_ERROR([Infiniband library libvapi.so not found.])
  2002.         fi
  2003.     fi
  2004.     BUILD_IB=1
  2005.     AC_CHECK_HEADER(wrap_common.h,
  2006.         AC_DEFINE(HAVE_IB_WRAP_COMMON_H, 1, Define if IB wrap_common.h exists.),
  2007.         ,
  2008.         [#include <vapi.h>])
  2009.     CPPFLAGS="$save_cppflags"
  2010.     fi
  2011.     AC_SUBST(BUILD_IB)
  2012.     AC_SUBST(IB_INCDIR)
  2013.     AC_SUBST(IB_LIBDIR)
  2014.  
  2015.     dnl Configure options for OpenIB install path.
  2016.     dnl --with-openib=<dir> is shorthand for
  2017.     dnl    --with-openib-includes=<dir>/include
  2018.     dnl    --with-openib-libs=<dir>/lib  (or lib64 if that exists)
  2019.     openib_home=
  2020.     AC_ARG_WITH(openib,
  2021.     [  --with-openib=<dir>     Location of the OpenIB install (default no OpenIB)],
  2022.     if test -z "$withval" -o "$withval" = yes ; then
  2023.         AC_MSG_ERROR([Option --with-openib requires the path to your OpenIB tree.])
  2024.     elif test "$withval" != no ; then
  2025.         openib_home="$withval"
  2026.     fi
  2027.     )
  2028.     AC_ARG_WITH(openib-includes,
  2029. [  --with-openib-includes=<dir>
  2030.                           Location of the OpenIB includes],
  2031.     if test -z "$withval" -o "$withval" = yes ; then
  2032.         AC_MSG_ERROR([Option --with-openib-includes requires path to OpenIB headers.])
  2033.     elif test "$withval" != no ; then
  2034.         OPENIB_INCDIR="$withval"
  2035.     fi
  2036.     )
  2037.     AC_ARG_WITH(openib-libs,
  2038. [  --with-openib-libs=<dir>
  2039.                           Location of the OpenIB libraries],
  2040.     if test -z "$withval" -o "$withval" = yes ; then
  2041.         AC_MSG_ERROR([Option --with-openib-libs requires path to OpenIB libraries.])
  2042.     elif test "$withval" != no ; then
  2043.         OPENIB_LIBDIR="$withval"
  2044.     fi
  2045.     )
  2046.     dnl If supplied the incls and libs explicitly, use them, else populate them
  2047.     dnl using guesses from the --with-openib dir.
  2048.     if test -n "$openib_home" ; then
  2049.     if test -z "$OPENIB_INCDIR"; then
  2050.         OPENIB_INCDIR=$openib_home/include
  2051.     fi
  2052.     if test -z "$OPENIB_LIBDIR"; then
  2053.         OPENIB_LIBDIR=$openib_home/lib64
  2054.         if test ! -d "$OPENIB_LIBDIR" ; then
  2055.         OPENIB_LIBDIR=$openib_home/lib
  2056.         fi
  2057.     fi
  2058.     fi
  2059.     dnl If anything OpenIB-ish was set, go look for header.
  2060.     if test -n "$OPENIB_INCDIR$OPENIB_LIBDIR" ; then
  2061.     save_cppflags="$CPPFLAGS"
  2062.     CPPFLAGS="$CPPFLAGS -I$OPENIB_INCDIR"
  2063.     AC_CHECK_HEADER(infiniband/verbs.h,,
  2064.         AC_MSG_ERROR([Header infiniband/verbs.h not found.]))
  2065.     dnl Run test is not possible on a machine that does not have an IB NIC.
  2066.     dnl Link test would work, but just check for existence.
  2067.     if test ! -f $OPENIB_LIBDIR/libibverbs.so ; then
  2068.         if test ! -f $OPENIB_LIBDIR/libibverbs.a ; then
  2069.         AC_MSG_ERROR([OpenIB library libibverbs.so not found.])
  2070.         fi
  2071.     fi
  2072.     BUILD_OPENIB=1
  2073.     CPPFLAGS="$save_cppflags"
  2074.     fi
  2075.     AC_SUBST(BUILD_OPENIB)
  2076.     AC_SUBST(OPENIB_INCDIR)
  2077.     AC_SUBST(OPENIB_LIBDIR)
  2078.  
  2079.     if test -n "$BUILD_OPENIB" ; then
  2080.     dnl Check for which version of the ibverbs library; device opening is
  2081.     dnl different.  This format is the older one, newer is
  2082.     dnl ibv_get_device_list.
  2083.     save_ldflags="$LDFLAGS"
  2084.     LDFLAGS="-L$OPENIB_LIBDIR -libverbs"
  2085.     save_cppflags="$CPPFLAGS"
  2086.     CPPFLAGS="$CPPFLAGS -I$OPENIB_INCDIR"
  2087.  
  2088.     AC_MSG_CHECKING(for ibv_get_devices)
  2089.     AC_TRY_LINK([], [
  2090.         ibv_get_devices();
  2091.         ],
  2092.         AC_MSG_RESULT(yes)
  2093.         AC_DEFINE(HAVE_IBV_GET_DEVICES, 1,
  2094.               Define if libibverbs has ibv_get_devices),
  2095.         AC_MSG_RESULT(no)
  2096.     )
  2097.  
  2098.     dnl Check for existence of reregister event; it's somewhat new.
  2099.     AC_MSG_CHECKING(for IBV_EVENT_CLIENT_REREGISTER)
  2100.     AC_TRY_COMPILE([
  2101.         #include "infiniband/verbs.h"
  2102.     ], [
  2103.         enum ibv_event_type x = IBV_EVENT_CLIENT_REREGISTER;
  2104.     ],
  2105.         AC_MSG_RESULT(yes)
  2106.         AC_DEFINE(HAVE_IBV_EVENT_CLIENT_REREGISTER, 1,
  2107.               Define if libibverbs has reregister event),
  2108.         AC_MSG_RESULT(no)
  2109.     )
  2110.  
  2111.     LDFLAGS="$save_ldflags"
  2112.     CPPFLAGS="$save_cppflags"
  2113.     fi
  2114. ])
  2115.  
  2116. dnl vim: set ft=config :
  2117.  
  2118. AC_DEFUN([AX_PORTALS],
  2119. [
  2120.     dnl
  2121.     dnl Configure to build Portals BMI method, if requested and available.
  2122.     dnl Use
  2123.     dnl   --with-portals       To find include files and libraries in standard
  2124.     dnl                        system paths.
  2125.     dnl   --with-portals=<dir> To specify a location that has include and lib
  2126.     dnl                        (or lib64) subdirectories with the goods.
  2127.     dnl
  2128.     dnl Or specify the -I an -L and -l flags exactly using, e.g.:
  2129.     dnl
  2130.     dnl   --with-portals-includes="-I<dir>"
  2131.     dnl   --with-portals-libs="-L<dir> -l<name>"
  2132.     dnl
  2133.     dnl The C file uses #include <portals/portals3.h>, so choose your include
  2134.     dnl path accordingly.  If it did not do this, portals/errno.h would sit in
  2135.     dnl front of the system version.
  2136.     dnl
  2137.     use_portals=
  2138.     home=
  2139.     incs=
  2140.     libs=
  2141.     AC_ARG_WITH(portals,
  2142.     [  --with-portals[=<dir>]   Location of the Portals install (default no Portals)],
  2143.     if test -z "$withval" -o "$withval" = yes ; then
  2144.         use_portals=yes
  2145.     elif test "$withval" != no ; then
  2146.         home="$withval"
  2147.     fi
  2148.     )
  2149.     AC_ARG_WITH(portals-includes,
  2150. [  --with-portals-includes=<dir>
  2151.                           Extra CFLAGS to specify Portals includes],
  2152.     if test -z "$withval" -o "$withval" = yes ; then
  2153.         AC_MSG_ERROR([Option --with-portals-includes requires an argument.])
  2154.     elif test "$withval" != no ; then
  2155.         incs="$withval"
  2156.     fi
  2157.     )
  2158.     AC_ARG_WITH(portals-libs,
  2159. [  --with-portals-libs=<dir>
  2160.                           Extra LIBS to link Portals libraries],
  2161.     if test -z "$withval" -o "$withval" = yes ; then
  2162.         AC_MSG_ERROR([Option --with-portals-libs requires an argument.])
  2163.     elif test "$withval" != no ; then
  2164.         libs="$withval"
  2165.     fi
  2166.     )
  2167.     dnl If supplied the incls and libs explicitly, use them, else populate them
  2168.     dnl using guesses from the --with-portals dir.
  2169.     if test -n "$home" ; then
  2170.     if test -z "$incs"; then
  2171.         incs=-I$home/include
  2172.     fi
  2173.     if test -z "$libs"; then
  2174.         libs=-L$home/lib64
  2175.         if test ! -d "$home/lib64" ; then
  2176.         libs=-L$home/lib
  2177.         fi
  2178.     fi
  2179.     fi
  2180.  
  2181.     dnl
  2182.     dnl Look for headers and libs.
  2183.     dnl
  2184.     BUILD_PORTALS=
  2185.     PORTALS_INCS=
  2186.     PORTALS_LIBS=
  2187.     if test "X$use_portals$home$incs$libs" != X ; then
  2188.     # Save stuff
  2189.     save_cppflags="$CPPFLAGS"
  2190.     save_libs="$LIBS"
  2191.  
  2192.     PORTALS_INCS="$incs"
  2193.     CPPFLAGS="$CPPFLAGS $PORTALS_INCS"
  2194.  
  2195.     PORTALS_LIBS="$libs"
  2196.     LIBS="$save_libs $PORTALS_LIBS"
  2197.  
  2198.     AC_MSG_CHECKING([for portals3.h header])
  2199.     ok=no
  2200.     AC_TRY_COMPILE(
  2201.         [#include <portals/portals3.h>],
  2202.         [int m, n; m = PtlInit(&n);],
  2203.         [ok=yes])
  2204.  
  2205.     if test "$ok" = yes ; then
  2206.         AC_MSG_RESULT([yes])
  2207.     else
  2208.         AC_MSG_RESULT([no])
  2209.         AC_MSG_ERROR([Header portals/portals3.h not found.])
  2210.     fi
  2211.  
  2212.     dnl try without first, for Cray, then try TCP version
  2213.     dnl Run test is not always possible, esp when cross-compiling or on
  2214.     dnl a box that does not have the hardware.
  2215.     AC_MSG_CHECKING([for portals libraries])
  2216.     ok=no
  2217.     AC_TRY_LINK(
  2218.         [#include <portals/portals3.h>],
  2219.         [int m, n; m = PtlInit(&n);],
  2220.         [ok=yes])
  2221.  
  2222.     if test "$ok" = no ; then
  2223.         PORTALS_LIBS="$libs -lportals"
  2224.         LIBS="$save_libs $PORTALS_LIBS"
  2225.         AC_TRY_LINK(
  2226.         [#include <portals/portals3.h>],
  2227.         [int m, n; m = PtlInit(&n);],
  2228.         [ok=yes])
  2229.     fi
  2230.  
  2231.     if test "$ok" = no ; then
  2232.         PORTALS_LIBS="$libs -lp3api -lp3lib -lp3utcp -lp3rt -lpthread"
  2233.         LIBS="$save_libs $PORTALS_LIBS"
  2234.         AC_TRY_LINK(
  2235.         [#include <portals/portals3.h>],
  2236.         [int m, n; m = PtlInit(&n);],
  2237.         [ok=yes])
  2238.     fi
  2239.  
  2240.     if test "$ok" = yes ; then
  2241.         AC_MSG_RESULT([yes])
  2242.         BUILD_PORTALS=1
  2243.     else
  2244.         AC_MSG_RESULT([no])
  2245.         AC_MSG_ERROR([Could not link Portals library.])
  2246.     fi
  2247.  
  2248.     #
  2249.     # Check for API variations.
  2250.     #
  2251.     AC_CHECK_FUNCS(PtlErrorStr)
  2252.     AC_CHECK_FUNCS(PtlEventKindStr)
  2253.  
  2254.     AC_TRY_COMPILE(
  2255.         [#include <portals/portals3.h>],
  2256.         [int m; ptl_process_id_t any_pid;
  2257.          m = PtlACEntry(0, 0, any_pid, (ptl_uid_t) -1, (ptl_jid_t) -1, 0);],
  2258.         AC_DEFINE(HAVE_PTLACENTRY_JID, 1,
  2259.               [Define if have PtlACEntry with jid argument.]))
  2260.  
  2261.     # Reset
  2262.     CPPFLAGS="$save_cppflags"
  2263.     LIBS="$save_libs"
  2264.     fi
  2265.     AC_SUBST(BUILD_PORTALS)
  2266.     AC_SUBST(PORTALS_INCS)
  2267.     AC_SUBST(PORTALS_LIBS)
  2268. ])
  2269.  
  2270. dnl vim: set ft=config : 
  2271.  
  2272. #
  2273. # Configure rules for ZOID
  2274. #
  2275. # See COPYING in top-level directory.
  2276. #
  2277. AC_DEFUN([AX_ZOID],
  2278. [
  2279.     dnl Configure options for ZOID install path.
  2280.     dnl --with-zoid=<dir>
  2281.     AC_ARG_WITH(zoid,
  2282. [  --with-zoid=<dir>         Location of the ZOID tree (default no ZOID)],
  2283.     if test -z "$withval" -o "$withval" = yes ; then
  2284.         AC_MSG_ERROR([Option --with-zoid requires the path to your ZOID source tree.])
  2285.     elif test "$withval" != no ; then
  2286.         ZOID_SRCDIR="$withval"
  2287.     fi
  2288.     )
  2289.     if test -n "$ZOID_SRCDIR" ; then
  2290.     save_cppflags="$CPPFLAGS"
  2291.     CPPFLAGS="$CPPFLAGS -Isrc/io/bmi -I$ZOID_SRCDIR/include -I$ZOID_SRCDIR/zbmi -I$ZOID_SRCDIR/zbmi/implementation"
  2292.     AC_CHECK_HEADER(zbmi.h,, AC_MSG_ERROR([Header zbmi.h not found.]))
  2293.     AC_CHECK_HEADER(zoid_api.h,, AC_MSG_ERROR([Header zoid_api.h not found.]))
  2294.     AC_CHECK_HEADER(zbmi_protocol.h,, AC_MSG_ERROR([Header zbmi_protocol.h not found.]))
  2295.     CPPFLAGS="$save_cppflags"
  2296.     BUILD_ZOID=1
  2297.     fi
  2298.     AC_SUBST(BUILD_ZOID)
  2299.     AC_SUBST(ZOID_SRCDIR)
  2300. ])
  2301.  
  2302. dnl vim: set ft=config :
  2303.  
  2304.