autoconf: Multiple Cases

1 
1 6.8 Multiple Cases
1 ==================
1 
1 Some operations are accomplished in several possible ways, depending on
1 the OS variant.  Checking for them essentially requires a "case
1 statement".  Autoconf does not directly provide one; however, it is
1 easy to simulate by using a shell variable to keep track of whether a
1 way to perform the operation has been found yet.
1 
1    Here is an example that uses the shell variable `fstype' to keep
1 track of whether the remaining cases need to be checked.  Note that
1 since the value of `fstype' is under our control, we don't have to use
1 the longer `test "x$fstype" = xno'.
1 
1      AC_MSG_CHECKING([how to get file system type])
1      fstype=no
1      # The order of these tests is important.
1      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/statvfs.h>
1      #include <sys/fstyp.h>]])],
1                        [AC_DEFINE([FSTYPE_STATVFS], [1],
1                           [Define if statvfs exists.])
1                         fstype=SVR4])
1      if test $fstype = no; then
1        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/statfs.h>
1      #include <sys/fstyp.h>]])],
1                        [AC_DEFINE([FSTYPE_USG_STATFS], [1],
1                           [Define if USG statfs.])
1                         fstype=SVR3])
1      fi
1      if test $fstype = no; then
1        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/statfs.h>
1      #include <sys/vmount.h>]])]),
1                        [AC_DEFINE([FSTYPE_AIX_STATFS], [1],
1                           [Define if AIX statfs.])
1                         fstype=AIX])
1      fi
1      # (more cases omitted here)
1      AC_MSG_RESULT([$fstype])
1