manpagez: man pages & more
info autoconf
Home | html | info | man

File: autoconf.info,  Node: Multiple Cases,  Prev: Systemology,  Up: Writing Tests

6.8 Multiple Cases
==================

Some operations are accomplished in several possible ways, depending on
the OS variant.  Checking for them essentially requires a "case
statement".  Autoconf does not directly provide one; however, it is easy
to simulate by using a shell variable to keep track of whether a way to
perform the operation has been found yet.

   Here is an example that uses the shell variable ‘fstype’ to keep
track of whether the remaining cases need to be checked.  Note that
since the value of ‘fstype’ is under our control, we don't have to use
the longer ‘test "x$fstype" = xno’.

     AC_MSG_CHECKING([how to get file system type])
     fstype=no
     # The order of these tests is important.
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include 
                                          #include 
                                        ]])],
       [AC_DEFINE([FSTYPE_STATVFS], [1],
          [Define if statvfs exists.])
        fstype=SVR4])
     AS_IF([test $fstype = no],
       [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include 
                                             #include 
                                           ]])],
          [AC_DEFINE([FSTYPE_USG_STATFS], [1],
             [Define if USG statfs.])
           fstype=SVR3])])
     AS_IF([test $fstype = no],
       [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include 
                                             #include 
                                           ]])],
          [AC_DEFINE([FSTYPE_AIX_STATFS], [1],
             [Define if AIX statfs.])
           fstype=AIX])])
     # (more cases omitted here)
     AC_MSG_RESULT([$fstype])

© manpagez.com 2000-2025
Individual documents may contain additional copyright information.