source: trunk/third/gtkhtml/macros/gnome-fileutils.m4 @ 16767

Revision 16767, 10.7 KB checked in by ghudson, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r16766, which included commits to RCS files with non-trunk default branches.
Line 
1dnl
2dnl GNOME_FILEUTILS_CHECKS
3dnl
4dnl checks that are needed for the diskusage applet.
5dnl
6
7AC_DEFUN([GNOME_FILEUTILS_CHECKS],
8[       
9AC_CHECK_HEADERS(fcntl.h sys/param.h sys/statfs.h sys/fstyp.h \
10mnttab.h mntent.h sys/statvfs.h sys/vfs.h sys/mount.h \
11sys/filsys.h sys/fs_types.h sys/fs/s5param.h)
12
13AC_CHECK_FUNCS(bcopy endgrent endpwent fchdir ftime ftruncate \
14getcwd getmntinfo gettimeofday isascii lchown \
15listmntent memcpy mkfifo strchr strerror strrchr vprintf)
16
17dnl Set some defaults when cross-compiling
18
19if test x$cross_compiling = xyes ; then
20        case "$host_os" in
21        linux*)
22          fu_cv_sys_mounted_getmntent1=yes
23          fu_cv_sys_stat_statfs2_bsize=yes
24          ;;
25        sunos*)
26          fu_cv_sys_stat_statfs4=yes
27          ;;
28        freebsd*)
29          fu_cv_sys_stat_statfs2_bsize=yes
30          ;;
31        osf*)
32          fu_cv_sys_stat_statfs3_osf1=yes
33          ;;
34        esac
35fi
36
37# Determine how to get the list of mounted filesystems.
38list_mounted_fs=
39
40# If the getmntent function is available but not in the standard library,
41# make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
42AC_FUNC_GETMNTENT
43
44# This test must precede the ones for getmntent because Unicos-9 is
45# reported to have the getmntent function, but its support is incompatible
46# with other getmntent implementations.
47
48# NOTE: Normally, I wouldn't use a check for system type as I've done for
49# `CRAY' below since that goes against the whole autoconf philosophy.  But
50# I think there is too great a chance that some non-Cray system has a
51# function named listmntent to risk the false positive.
52
53if test -z "$list_mounted_fs"; then
54# Cray UNICOS 9
55AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
56AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
57[fu_cv_sys_mounted_cray_listmntent=no
58AC_EGREP_CPP(yes,
59[#ifdef _CRAY
60yes
61#endif
62], [test $ac_cv_func_listmntent = yes \
63&& fu_cv_sys_mounted_cray_listmntent=yes]
64)
65]
66)
67AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
68if test $fu_cv_sys_mounted_cray_listmntent = yes; then
69list_mounted_fs=found
70AC_DEFINE(MOUNTED_LISTMNTENT)
71fi
72fi
73
74if test $ac_cv_func_getmntent = yes; then
75
76# This system has the getmntent function.
77# Determine whether it's the one-argument variant or the two-argument one.
78
79if test -z "$list_mounted_fs"; then
80# 4.3BSD, SunOS, HP-UX, Dynix, Irix
81AC_MSG_CHECKING([for one-argument getmntent function])
82AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
83[test $ac_cv_header_mntent_h = yes \
84&& fu_cv_sys_mounted_getmntent1=yes \
85|| fu_cv_sys_mounted_getmntent1=no])
86AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
87if test $fu_cv_sys_mounted_getmntent1 = yes; then
88list_mounted_fs=found
89AC_DEFINE(MOUNTED_GETMNTENT1)
90fi
91fi
92
93if test -z "$list_mounted_fs"; then
94# SVR4
95AC_MSG_CHECKING([for two-argument getmntent function])
96AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
97[AC_EGREP_HEADER(getmntent, sys/mnttab.h,
98fu_cv_sys_mounted_getmntent2=yes,
99fu_cv_sys_mounted_getmntent2=no)])
100AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
101if test $fu_cv_sys_mounted_getmntent2 = yes; then
102list_mounted_fs=found
103AC_DEFINE(MOUNTED_GETMNTENT2)
104fi
105fi
106
107if test -z "$list_mounted_fs"; then
108AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
109fi
110
111fi
112
113if test -z "$list_mounted_fs"; then
114# DEC Alpha running OSF/1.
115AC_MSG_CHECKING([for getfsstat function])
116AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
117[AC_TRY_LINK([
118#include <sys/types.h>
119#include <sys/mount.h>
120#include <sys/fs_types.h>],
121[struct statfs *stats;
122int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
123fu_cv_sys_mounted_getsstat=yes,
124fu_cv_sys_mounted_getsstat=no)])
125AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
126if test $fu_cv_sys_mounted_getsstat = yes; then
127list_mounted_fs=found
128AC_DEFINE(MOUNTED_GETFSSTAT)
129fi
130fi
131
132if test -z "$list_mounted_fs"; then
133# AIX.
134AC_MSG_CHECKING([for mntctl function and struct vmount])
135AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
136[AC_TRY_CPP([#include <fshelp.h>],
137fu_cv_sys_mounted_vmount=yes,
138fu_cv_sys_mounted_vmount=no)])
139AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
140if test $fu_cv_sys_mounted_vmount = yes; then
141list_mounted_fs=found
142AC_DEFINE(MOUNTED_VMOUNT)
143fi
144fi
145
146if test -z "$list_mounted_fs"; then
147# SVR3
148AC_MSG_CHECKING([for FIXME existence of three headers])
149AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
150[AC_TRY_CPP([
151#include <sys/statfs.h>
152#include <sys/fstyp.h>
153#include <mnttab.h>],
154fu_cv_sys_mounted_fread_fstyp=yes,
155fu_cv_sys_mounted_fread_fstyp=no)])
156AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
157if test $fu_cv_sys_mounted_fread_fstyp = yes; then
158list_mounted_fs=found
159AC_DEFINE(MOUNTED_FREAD_FSTYP)
160fi
161fi
162
163if test -z "$list_mounted_fs"; then
164# 4.4BSD and DEC OSF/1.
165AC_MSG_CHECKING([for getmntinfo function])
166AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
167[
168ok=
169if test $ac_cv_func_getmntinfo = yes; then
170AC_EGREP_HEADER(f_type;, sys/mount.h,
171ok=yes)
172fi
173test -n "$ok" \
174&& fu_cv_sys_mounted_getmntinfo=yes \
175|| fu_cv_sys_mounted_getmntinfo=no
176])
177AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
178if test $fu_cv_sys_mounted_getmntinfo = yes; then
179list_mounted_fs=found
180AC_DEFINE(MOUNTED_GETMNTINFO)
181fi
182fi
183
184# FIXME: add a test for netbsd-1.1 here
185
186if test -z "$list_mounted_fs"; then
187# Ultrix
188AC_MSG_CHECKING([for getmnt function])
189AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
190[AC_TRY_CPP([
191#include <sys/fs_types.h>
192#include <sys/mount.h>],
193fu_cv_sys_mounted_getmnt=yes,
194fu_cv_sys_mounted_getmnt=no)])
195AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
196if test $fu_cv_sys_mounted_getmnt = yes; then
197list_mounted_fs=found
198AC_DEFINE(MOUNTED_GETMNT)
199fi
200fi
201
202if test -z "$list_mounted_fs"; then
203# SVR2
204AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
205AC_CACHE_VAL(fu_cv_sys_mounted_fread,
206[AC_TRY_CPP([#include <mnttab.h>],
207fu_cv_sys_mounted_fread=yes,
208fu_cv_sys_mounted_fread=no)])
209AC_MSG_RESULT($fu_cv_sys_mounted_fread)
210if test $fu_cv_sys_mounted_fread = yes; then
211list_mounted_fs=found
212AC_DEFINE(MOUNTED_FREAD)
213fi
214fi
215
216if test -z "$list_mounted_fs"; then
217AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
218# FIXME -- no need to abort building the whole package
219# Cannot build mountlist.c or anything that needs its functions
220fi
221
222AC_CHECKING(how to get filesystem space usage)
223space=no
224
225# Perform only the link test since it seems there are no variants of the
226# statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
227# because that got a false positive on SCO OSR5.  Adding the declaration
228# of a `struct statvfs' causes this test to fail (as it should) on such
229# systems.  That system is reported to work fine with STAT_STATFS4 which
230# is what it gets when this test fails.
231if test $space = no; then
232# SVR4
233AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
234[AC_TRY_LINK([#include <sys/types.h>
235#include <sys/statvfs.h>],
236[struct statvfs fsd; statvfs (0, &fsd);],
237fu_cv_sys_stat_statvfs=yes,
238fu_cv_sys_stat_statvfs=no)])
239if test $fu_cv_sys_stat_statvfs = yes; then
240space=yes
241AC_DEFINE(STAT_STATVFS)
242fi
243fi
244
245if test $space = no; then
246# DEC Alpha running OSF/1
247AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
248AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
249[AC_TRY_RUN([
250#include <sys/param.h>
251#include <sys/types.h>
252#include <sys/mount.h>
253int main ()
254{
255struct statfs fsd;
256fsd.f_fsize = 0;
257return (statfs (".", &fsd, sizeof (struct statfs)));
258}],
259fu_cv_sys_stat_statfs3_osf1=yes,
260fu_cv_sys_stat_statfs3_osf1=no,
261fu_cv_sys_stat_statfs3_osf1=no)])
262AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
263if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
264space=yes
265AC_DEFINE(STAT_STATFS3_OSF1)
266fi
267fi
268
269if test $space = no; then
270# AIX
271AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
272member (AIX, 4.3BSD)])
273AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
274[AC_TRY_RUN([
275#ifdef HAVE_SYS_PARAM_H
276#include <sys/param.h>
277#endif
278#ifdef HAVE_SYS_MOUNT_H
279#include <sys/mount.h>
280#endif
281#ifdef HAVE_SYS_VFS_H
282#include <sys/vfs.h>
283#endif
284int main ()
285{
286struct statfs fsd;
287fsd.f_bsize = 0;
288return (statfs (".", &fsd));
289}],
290fu_cv_sys_stat_statfs2_bsize=yes,
291fu_cv_sys_stat_statfs2_bsize=no,
292fu_cv_sys_stat_statfs2_bsize=no)])
293AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
294if test $fu_cv_sys_stat_statfs2_bsize = yes; then
295space=yes
296AC_DEFINE(STAT_STATFS2_BSIZE)
297fi
298fi
299
300if test $space = no; then
301# SVR3
302AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
303AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
304[AC_TRY_RUN([#include <sys/types.h>
305#include <sys/statfs.h>
306int main ()
307{
308struct statfs fsd;
309return (statfs (".", &fsd, sizeof fsd, 0));
310}],
311fu_cv_sys_stat_statfs4=yes,
312fu_cv_sys_stat_statfs4=no,
313fu_cv_sys_stat_statfs4=no)])
314AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
315if test $fu_cv_sys_stat_statfs4 = yes; then
316space=yes
317AC_DEFINE(STAT_STATFS4)
318fi
319fi
320
321if test $space = no; then
322# 4.4BSD and NetBSD
323AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
324member (4.4BSD and NetBSD)])
325AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
326[AC_TRY_RUN([#include <sys/types.h>
327#ifdef HAVE_SYS_PARAM_H
328#include <sys/param.h>
329#endif
330#ifdef HAVE_SYS_MOUNT_H
331#include <sys/mount.h>
332#endif
333int main ()
334{
335struct statfs fsd;
336fsd.f_fsize = 0;
337return (statfs (".", &fsd));
338}],
339fu_cv_sys_stat_statfs2_fsize=yes,
340fu_cv_sys_stat_statfs2_fsize=no,
341fu_cv_sys_stat_statfs2_fsize=no)])
342AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
343if test $fu_cv_sys_stat_statfs2_fsize = yes; then
344space=yes
345AC_DEFINE(STAT_STATFS2_FSIZE)
346fi
347fi
348
349if test $space = no; then
350# Ultrix
351AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
352AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
353[AC_TRY_RUN([#include <sys/types.h>
354#ifdef HAVE_SYS_PARAM_H
355#include <sys/param.h>
356#endif
357#ifdef HAVE_SYS_MOUNT_H
358#include <sys/mount.h>
359#endif
360#ifdef HAVE_SYS_FS_TYPES_H
361#include <sys/fs_types.h>
362#endif
363int main ()
364{
365struct fs_data fsd;
366/* Ultrix's statfs returns 1 for success,
3670 for not mounted, -1 for failure.  */
368return (statfs (".", &fsd) != 1);
369}],
370fu_cv_sys_stat_fs_data=yes,
371fu_cv_sys_stat_fs_data=no,
372fu_cv_sys_stat_fs_data=no)])
373AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
374if test $fu_cv_sys_stat_fs_data = yes; then
375space=yes
376AC_DEFINE(STAT_STATFS2_FS_DATA)
377fi
378fi
379
380if test $space = no; then
381# SVR2
382AC_TRY_CPP([#include <sys/filsys.h>],
383AC_DEFINE(STAT_READ_FILSYS) space=yes)
384fi
385
386if test -n "$list_mounted_fs" && test $space != no; then
387DF_PROG="df"
388# LIBOBJS="$LIBOBJS fsusage.o"
389# LIBOBJS="$LIBOBJS mountlist.o"
390fi
391
392# Check for SunOS statfs brokenness wrt partitions 2GB and larger.
393# If <sys/vfs.h> exists and struct statfs has a member named f_spare,
394# enable the work-around code in fsusage.c.
395AC_MSG_CHECKING([for statfs that truncates block counts])
396AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
397[AC_TRY_COMPILE([
398#if !defined(sun) && !defined(__sun)
399choke -- this is a workaround for a Sun-specific problem
400#endif
401#include <sys/types.h>
402#include <sys/vfs.h>],
403[struct statfs t; long c = *(t.f_spare);],
404fu_cv_sys_truncating_statfs=yes,
405fu_cv_sys_truncating_statfs=no,
406)])
407if test $fu_cv_sys_truncating_statfs = yes; then
408AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS)
409fi
410AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
411
412AC_CHECKING(for AFS)
413test -d /afs && AC_DEFINE(AFS)
414])
Note: See TracBrowser for help on using the repository browser.