*** empty log message ***
[findutils.git] / m4 / ls-mntd-fs.m4
blob40a2fb17cff23343c072aede92734b6f02ebeb3e
1 #serial 3
3 dnl From Jim Meyering.
4 dnl
5 dnl This is not pretty.  I've just taken the autoconf code and wrapped
6 dnl it in an AC_DEFUN.
7 dnl
8 dnl CAUTION: This is very fragile.  It relies on several checks that
9 dnl are still in fileutils' configure.in:
10 dnl FIXME: add AC_REQUIRE uses to pull in all definitions required
11 dnl for all uses of $ac_cv_func_* and $ac_cv_header_* variables below.
12 dnl
14 AC_PREREQ(2.14a)
16 # jm_LIST_MOUNTED_FILESYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
17 AC_DEFUN(jm_LIST_MOUNTED_FILESYSTEMS,
18   [
19 # Determine how to get the list of mounted filesystems.
20 ac_list_mounted_fs=
22 # If the getmntent function is available but not in the standard library,
23 # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
24 AC_FUNC_GETMNTENT
26 # This test must precede the ones for getmntent because Unicos-9 is
27 # reported to have the getmntent function, but its support is incompatible
28 # with other getmntent implementations.
30 # NOTE: Normally, I wouldn't use a check for system type as I've done for
31 # `CRAY' below since that goes against the whole autoconf philosophy.  But
32 # I think there is too great a chance that some non-Cray system has a
33 # function named listmntent to risk the false positive.
35 if test -z "$ac_list_mounted_fs"; then
36   # Cray UNICOS 9
37   AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
38   AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
39     [fu_cv_sys_mounted_cray_listmntent=no
40       AC_EGREP_CPP(yes,
41         [#ifdef _CRAY
42 yes
43 #endif
44         ], [test $ac_cv_func_listmntent = yes \
45             && fu_cv_sys_mounted_cray_listmntent=yes]
46       )
47     ]
48   )
49   AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
50   if test $fu_cv_sys_mounted_cray_listmntent = yes; then
51     ac_list_mounted_fs=found
52     AC_DEFINE(MOUNTED_LISTMNTENT, 1,
53       [Define if there is a function named listmntent that can be used to
54    list all mounted filesystems. (UNICOS)])
55   fi
58 if test $ac_cv_func_getmntent = yes; then
60   # This system has the getmntent function.
61   # Determine whether it's the one-argument variant or the two-argument one.
63   if test -z "$ac_list_mounted_fs"; then
64     # 4.3BSD, SunOS, HP-UX, Dynix, Irix
65     AC_MSG_CHECKING([for one-argument getmntent function])
66     AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
67                  [test $ac_cv_header_mntent_h = yes \
68                    && fu_cv_sys_mounted_getmntent1=yes \
69                    || fu_cv_sys_mounted_getmntent1=no])
70     AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
71     if test $fu_cv_sys_mounted_getmntent1 = yes; then
72       ac_list_mounted_fs=found
73       AC_DEFINE(MOUNTED_GETMNTENT1, 1,
74   [Define if there is a function named getmntent for reading the list
75    of mounted filesystems, and that function takes a single argument.
76    (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
77     fi
78   fi
80   if test -z "$ac_list_mounted_fs"; then
81     # SVR4
82     AC_MSG_CHECKING([for two-argument getmntent function])
83     AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
84     [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
85       fu_cv_sys_mounted_getmntent2=yes,
86       fu_cv_sys_mounted_getmntent2=no)])
87     AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
88     if test $fu_cv_sys_mounted_getmntent2 = yes; then
89       ac_list_mounted_fs=found
90       AC_DEFINE(MOUNTED_GETMNTENT2, 1,
91   [Define if there is a function named getmntent for reading the list of
92    mounted filesystems, and that function takes two arguments.  (SVR4)])
93     fi
94   fi
96   if test -z "$ac_list_mounted_fs"; then
97     AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
98   fi
102 if test -z "$ac_list_mounted_fs"; then
103   # DEC Alpha running OSF/1.
104   AC_MSG_CHECKING([for getfsstat function])
105   AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
106   [AC_TRY_LINK([
107 #include <sys/types.h>
108 #include <sys/mount.h>
109 #include <sys/fs_types.h>],
110   [struct statfs *stats;
111   int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
112     fu_cv_sys_mounted_getsstat=yes,
113     fu_cv_sys_mounted_getsstat=no)])
114   AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
115   if test $fu_cv_sys_mounted_getsstat = yes; then
116     ac_list_mounted_fs=found
117     AC_DEFINE(MOUNTED_GETFSSTAT, 1,
118               [Define if there is a function named getfsstat for reading the
119    list of mounted filesystems.  (DEC Alpha running OSF/1)])
120   fi
123 if test -z "$ac_list_mounted_fs"; then
124   # AIX.
125   AC_MSG_CHECKING([for mntctl function and struct vmount])
126   AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
127   [AC_TRY_CPP([#include <fshelp.h>],
128     fu_cv_sys_mounted_vmount=yes,
129     fu_cv_sys_mounted_vmount=no)])
130   AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
131   if test $fu_cv_sys_mounted_vmount = yes; then
132     ac_list_mounted_fs=found
133     AC_DEFINE(MOUNTED_VMOUNT, 1,
134         [Define if there is a function named mntctl that can be used to read
135    the list of mounted filesystems, and there is a system header file
136    that declares `struct vmount.'  (AIX)])
137   fi
140 if test -z "$ac_list_mounted_fs"; then
141   # SVR3
142   AC_MSG_CHECKING([for FIXME existence of three headers])
143   AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
144     [AC_TRY_CPP([
145 #include <sys/statfs.h>
146 #include <sys/fstyp.h>
147 #include <mnttab.h>],
148                 fu_cv_sys_mounted_fread_fstyp=yes,
149                 fu_cv_sys_mounted_fread_fstyp=no)])
150   AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
151   if test $fu_cv_sys_mounted_fread_fstyp = yes; then
152     ac_list_mounted_fs=found
153     AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
154 [Define if (like SVR2) there is no specific function for reading the
155    list of mounted filesystems, and your system has these header files:
156    <sys/fstyp.h> and <sys/statfs.h>.  (SVR3)])
157   fi
160 if test -z "$ac_list_mounted_fs"; then
161   # 4.4BSD and DEC OSF/1.
162   AC_MSG_CHECKING([for getmntinfo function])
163   AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
164     [
165       ok=
166       if test $ac_cv_func_getmntinfo = yes; then
167         AC_EGREP_HEADER(f_type;, sys/mount.h,
168                         ok=yes)
169       fi
170       test -n "$ok" \
171           && fu_cv_sys_mounted_getmntinfo=yes \
172           || fu_cv_sys_mounted_getmntinfo=no
173     ])
174   AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
175   if test $fu_cv_sys_mounted_getmntinfo = yes; then
176     ac_list_mounted_fs=found
177     AC_DEFINE(MOUNTED_GETMNTINFO, 1,
178               [Define if there is a function named getmntinfo for reading the
179    list of mounted filesystems.  (4.4BSD)])
180   fi
183 # FIXME: add a test for netbsd-1.1 here
185 if test -z "$ac_list_mounted_fs"; then
186   # Ultrix
187   AC_MSG_CHECKING([for getmnt function])
188   AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
189     [AC_TRY_CPP([
190 #include <sys/fs_types.h>
191 #include <sys/mount.h>],
192                 fu_cv_sys_mounted_getmnt=yes,
193                 fu_cv_sys_mounted_getmnt=no)])
194   AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
195   if test $fu_cv_sys_mounted_getmnt = yes; then
196     ac_list_mounted_fs=found
197     AC_DEFINE(MOUNTED_GETMNT, 1,
198       [Define if there is a function named getmnt for reading the list of
199    mounted filesystems.  (Ultrix)])
200   fi
203 if test -z "$ac_list_mounted_fs"; then
204   # SVR2
205   AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
206   AC_CACHE_VAL(fu_cv_sys_mounted_fread,
207     [AC_TRY_CPP([#include <mnttab.h>],
208                 fu_cv_sys_mounted_fread=yes,
209                 fu_cv_sys_mounted_fread=no)])
210   AC_MSG_RESULT($fu_cv_sys_mounted_fread)
211   if test $fu_cv_sys_mounted_fread = yes; then
212     ac_list_mounted_fs=found
213     AC_DEFINE(MOUNTED_FREAD, 1,
214               [Define if there is no specific function for reading the list of
215    mounted filesystems.  fread will be used to read /etc/mnttab.  (SVR2) ])
216   fi
219 if test -z "$ac_list_mounted_fs"; then
220   AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
221   # FIXME -- no need to abort building the whole package
222   # Can't build mountlist.c or anything that needs its functions
225 AC_SHELL_IFELSE([test $ac_list_mounted_fs = found], [$1], [$2])dnl
227   ])