1 | dnl |
---|
2 | dnl GNOME_FILEUTILS_CHECKS |
---|
3 | dnl |
---|
4 | dnl checks that are needed for the diskusage applet. |
---|
5 | dnl |
---|
6 | |
---|
7 | AC_DEFUN([GNOME_FILEUTILS_CHECKS], |
---|
8 | [ |
---|
9 | AC_CHECK_HEADERS(fcntl.h sys/param.h sys/statfs.h sys/fstyp.h \ |
---|
10 | mnttab.h mntent.h sys/statvfs.h sys/vfs.h sys/mount.h \ |
---|
11 | sys/filsys.h sys/fs_types.h sys/fs/s5param.h) |
---|
12 | |
---|
13 | AC_CHECK_FUNCS(bcopy endgrent endpwent fchdir ftime ftruncate \ |
---|
14 | getcwd getmntinfo gettimeofday isascii lchown \ |
---|
15 | listmntent memcpy mkfifo strchr strerror strrchr vprintf) |
---|
16 | |
---|
17 | dnl Set some defaults when cross-compiling |
---|
18 | |
---|
19 | if 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 |
---|
35 | fi |
---|
36 | |
---|
37 | # Determine how to get the list of mounted filesystems. |
---|
38 | list_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). |
---|
42 | AC_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 | |
---|
53 | if test -z "$list_mounted_fs"; then |
---|
54 | # Cray UNICOS 9 |
---|
55 | AC_MSG_CHECKING([for listmntent of Cray/Unicos-9]) |
---|
56 | AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent, |
---|
57 | [fu_cv_sys_mounted_cray_listmntent=no |
---|
58 | AC_EGREP_CPP(yes, |
---|
59 | [#ifdef _CRAY |
---|
60 | yes |
---|
61 | #endif |
---|
62 | ], [test $ac_cv_func_listmntent = yes \ |
---|
63 | && fu_cv_sys_mounted_cray_listmntent=yes] |
---|
64 | ) |
---|
65 | ] |
---|
66 | ) |
---|
67 | AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent) |
---|
68 | if test $fu_cv_sys_mounted_cray_listmntent = yes; then |
---|
69 | list_mounted_fs=found |
---|
70 | AC_DEFINE(MOUNTED_LISTMNTENT) |
---|
71 | fi |
---|
72 | fi |
---|
73 | |
---|
74 | if 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 | |
---|
79 | if test -z "$list_mounted_fs"; then |
---|
80 | # 4.3BSD, SunOS, HP-UX, Dynix, Irix |
---|
81 | AC_MSG_CHECKING([for one-argument getmntent function]) |
---|
82 | AC_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]) |
---|
86 | AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1) |
---|
87 | if test $fu_cv_sys_mounted_getmntent1 = yes; then |
---|
88 | list_mounted_fs=found |
---|
89 | AC_DEFINE(MOUNTED_GETMNTENT1) |
---|
90 | fi |
---|
91 | fi |
---|
92 | |
---|
93 | if test -z "$list_mounted_fs"; then |
---|
94 | # SVR4 |
---|
95 | AC_MSG_CHECKING([for two-argument getmntent function]) |
---|
96 | AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2, |
---|
97 | [AC_EGREP_HEADER(getmntent, sys/mnttab.h, |
---|
98 | fu_cv_sys_mounted_getmntent2=yes, |
---|
99 | fu_cv_sys_mounted_getmntent2=no)]) |
---|
100 | AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2) |
---|
101 | if test $fu_cv_sys_mounted_getmntent2 = yes; then |
---|
102 | list_mounted_fs=found |
---|
103 | AC_DEFINE(MOUNTED_GETMNTENT2) |
---|
104 | fi |
---|
105 | fi |
---|
106 | |
---|
107 | if test -z "$list_mounted_fs"; then |
---|
108 | AC_MSG_ERROR([could not determine how to read list of mounted filesystems]) |
---|
109 | fi |
---|
110 | |
---|
111 | fi |
---|
112 | |
---|
113 | if test -z "$list_mounted_fs"; then |
---|
114 | # DEC Alpha running OSF/1. |
---|
115 | AC_MSG_CHECKING([for getfsstat function]) |
---|
116 | AC_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; |
---|
122 | int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ], |
---|
123 | fu_cv_sys_mounted_getsstat=yes, |
---|
124 | fu_cv_sys_mounted_getsstat=no)]) |
---|
125 | AC_MSG_RESULT($fu_cv_sys_mounted_getsstat) |
---|
126 | if test $fu_cv_sys_mounted_getsstat = yes; then |
---|
127 | list_mounted_fs=found |
---|
128 | AC_DEFINE(MOUNTED_GETFSSTAT) |
---|
129 | fi |
---|
130 | fi |
---|
131 | |
---|
132 | if test -z "$list_mounted_fs"; then |
---|
133 | # AIX. |
---|
134 | AC_MSG_CHECKING([for mntctl function and struct vmount]) |
---|
135 | AC_CACHE_VAL(fu_cv_sys_mounted_vmount, |
---|
136 | [AC_TRY_CPP([#include <fshelp.h>], |
---|
137 | fu_cv_sys_mounted_vmount=yes, |
---|
138 | fu_cv_sys_mounted_vmount=no)]) |
---|
139 | AC_MSG_RESULT($fu_cv_sys_mounted_vmount) |
---|
140 | if test $fu_cv_sys_mounted_vmount = yes; then |
---|
141 | list_mounted_fs=found |
---|
142 | AC_DEFINE(MOUNTED_VMOUNT) |
---|
143 | fi |
---|
144 | fi |
---|
145 | |
---|
146 | if test -z "$list_mounted_fs"; then |
---|
147 | # SVR3 |
---|
148 | AC_MSG_CHECKING([for FIXME existence of three headers]) |
---|
149 | AC_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>], |
---|
154 | fu_cv_sys_mounted_fread_fstyp=yes, |
---|
155 | fu_cv_sys_mounted_fread_fstyp=no)]) |
---|
156 | AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp) |
---|
157 | if test $fu_cv_sys_mounted_fread_fstyp = yes; then |
---|
158 | list_mounted_fs=found |
---|
159 | AC_DEFINE(MOUNTED_FREAD_FSTYP) |
---|
160 | fi |
---|
161 | fi |
---|
162 | |
---|
163 | if test -z "$list_mounted_fs"; then |
---|
164 | # 4.4BSD and DEC OSF/1. |
---|
165 | AC_MSG_CHECKING([for getmntinfo function]) |
---|
166 | AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo, |
---|
167 | [ |
---|
168 | ok= |
---|
169 | if test $ac_cv_func_getmntinfo = yes; then |
---|
170 | AC_EGREP_HEADER(f_type;, sys/mount.h, |
---|
171 | ok=yes) |
---|
172 | fi |
---|
173 | test -n "$ok" \ |
---|
174 | && fu_cv_sys_mounted_getmntinfo=yes \ |
---|
175 | || fu_cv_sys_mounted_getmntinfo=no |
---|
176 | ]) |
---|
177 | AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo) |
---|
178 | if test $fu_cv_sys_mounted_getmntinfo = yes; then |
---|
179 | list_mounted_fs=found |
---|
180 | AC_DEFINE(MOUNTED_GETMNTINFO) |
---|
181 | fi |
---|
182 | fi |
---|
183 | |
---|
184 | # FIXME: add a test for netbsd-1.1 here |
---|
185 | |
---|
186 | if test -z "$list_mounted_fs"; then |
---|
187 | # Ultrix |
---|
188 | AC_MSG_CHECKING([for getmnt function]) |
---|
189 | AC_CACHE_VAL(fu_cv_sys_mounted_getmnt, |
---|
190 | [AC_TRY_CPP([ |
---|
191 | #include <sys/fs_types.h> |
---|
192 | #include <sys/mount.h>], |
---|
193 | fu_cv_sys_mounted_getmnt=yes, |
---|
194 | fu_cv_sys_mounted_getmnt=no)]) |
---|
195 | AC_MSG_RESULT($fu_cv_sys_mounted_getmnt) |
---|
196 | if test $fu_cv_sys_mounted_getmnt = yes; then |
---|
197 | list_mounted_fs=found |
---|
198 | AC_DEFINE(MOUNTED_GETMNT) |
---|
199 | fi |
---|
200 | fi |
---|
201 | |
---|
202 | if test -z "$list_mounted_fs"; then |
---|
203 | # SVR2 |
---|
204 | AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab]) |
---|
205 | AC_CACHE_VAL(fu_cv_sys_mounted_fread, |
---|
206 | [AC_TRY_CPP([#include <mnttab.h>], |
---|
207 | fu_cv_sys_mounted_fread=yes, |
---|
208 | fu_cv_sys_mounted_fread=no)]) |
---|
209 | AC_MSG_RESULT($fu_cv_sys_mounted_fread) |
---|
210 | if test $fu_cv_sys_mounted_fread = yes; then |
---|
211 | list_mounted_fs=found |
---|
212 | AC_DEFINE(MOUNTED_FREAD) |
---|
213 | fi |
---|
214 | fi |
---|
215 | |
---|
216 | if test -z "$list_mounted_fs"; then |
---|
217 | AC_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 |
---|
220 | fi |
---|
221 | |
---|
222 | AC_CHECKING(how to get filesystem space usage) |
---|
223 | space=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. |
---|
231 | if test $space = no; then |
---|
232 | # SVR4 |
---|
233 | AC_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);], |
---|
237 | fu_cv_sys_stat_statvfs=yes, |
---|
238 | fu_cv_sys_stat_statvfs=no)]) |
---|
239 | if test $fu_cv_sys_stat_statvfs = yes; then |
---|
240 | space=yes |
---|
241 | AC_DEFINE(STAT_STATVFS) |
---|
242 | fi |
---|
243 | fi |
---|
244 | |
---|
245 | if test $space = no; then |
---|
246 | # DEC Alpha running OSF/1 |
---|
247 | AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) |
---|
248 | AC_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> |
---|
253 | int main () |
---|
254 | { |
---|
255 | struct statfs fsd; |
---|
256 | fsd.f_fsize = 0; |
---|
257 | return (statfs (".", &fsd, sizeof (struct statfs))); |
---|
258 | }], |
---|
259 | fu_cv_sys_stat_statfs3_osf1=yes, |
---|
260 | fu_cv_sys_stat_statfs3_osf1=no, |
---|
261 | fu_cv_sys_stat_statfs3_osf1=no)]) |
---|
262 | AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1) |
---|
263 | if test $fu_cv_sys_stat_statfs3_osf1 = yes; then |
---|
264 | space=yes |
---|
265 | AC_DEFINE(STAT_STATFS3_OSF1) |
---|
266 | fi |
---|
267 | fi |
---|
268 | |
---|
269 | if test $space = no; then |
---|
270 | # AIX |
---|
271 | AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl |
---|
272 | member (AIX, 4.3BSD)]) |
---|
273 | AC_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 |
---|
284 | int main () |
---|
285 | { |
---|
286 | struct statfs fsd; |
---|
287 | fsd.f_bsize = 0; |
---|
288 | return (statfs (".", &fsd)); |
---|
289 | }], |
---|
290 | fu_cv_sys_stat_statfs2_bsize=yes, |
---|
291 | fu_cv_sys_stat_statfs2_bsize=no, |
---|
292 | fu_cv_sys_stat_statfs2_bsize=no)]) |
---|
293 | AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize) |
---|
294 | if test $fu_cv_sys_stat_statfs2_bsize = yes; then |
---|
295 | space=yes |
---|
296 | AC_DEFINE(STAT_STATFS2_BSIZE) |
---|
297 | fi |
---|
298 | fi |
---|
299 | |
---|
300 | if test $space = no; then |
---|
301 | # SVR3 |
---|
302 | AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) |
---|
303 | AC_CACHE_VAL(fu_cv_sys_stat_statfs4, |
---|
304 | [AC_TRY_RUN([#include <sys/types.h> |
---|
305 | #include <sys/statfs.h> |
---|
306 | int main () |
---|
307 | { |
---|
308 | struct statfs fsd; |
---|
309 | return (statfs (".", &fsd, sizeof fsd, 0)); |
---|
310 | }], |
---|
311 | fu_cv_sys_stat_statfs4=yes, |
---|
312 | fu_cv_sys_stat_statfs4=no, |
---|
313 | fu_cv_sys_stat_statfs4=no)]) |
---|
314 | AC_MSG_RESULT($fu_cv_sys_stat_statfs4) |
---|
315 | if test $fu_cv_sys_stat_statfs4 = yes; then |
---|
316 | space=yes |
---|
317 | AC_DEFINE(STAT_STATFS4) |
---|
318 | fi |
---|
319 | fi |
---|
320 | |
---|
321 | if test $space = no; then |
---|
322 | # 4.4BSD and NetBSD |
---|
323 | AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl |
---|
324 | member (4.4BSD and NetBSD)]) |
---|
325 | AC_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 |
---|
333 | int main () |
---|
334 | { |
---|
335 | struct statfs fsd; |
---|
336 | fsd.f_fsize = 0; |
---|
337 | return (statfs (".", &fsd)); |
---|
338 | }], |
---|
339 | fu_cv_sys_stat_statfs2_fsize=yes, |
---|
340 | fu_cv_sys_stat_statfs2_fsize=no, |
---|
341 | fu_cv_sys_stat_statfs2_fsize=no)]) |
---|
342 | AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize) |
---|
343 | if test $fu_cv_sys_stat_statfs2_fsize = yes; then |
---|
344 | space=yes |
---|
345 | AC_DEFINE(STAT_STATFS2_FSIZE) |
---|
346 | fi |
---|
347 | fi |
---|
348 | |
---|
349 | if test $space = no; then |
---|
350 | # Ultrix |
---|
351 | AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)]) |
---|
352 | AC_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 |
---|
363 | int main () |
---|
364 | { |
---|
365 | struct fs_data fsd; |
---|
366 | /* Ultrix's statfs returns 1 for success, |
---|
367 | 0 for not mounted, -1 for failure. */ |
---|
368 | return (statfs (".", &fsd) != 1); |
---|
369 | }], |
---|
370 | fu_cv_sys_stat_fs_data=yes, |
---|
371 | fu_cv_sys_stat_fs_data=no, |
---|
372 | fu_cv_sys_stat_fs_data=no)]) |
---|
373 | AC_MSG_RESULT($fu_cv_sys_stat_fs_data) |
---|
374 | if test $fu_cv_sys_stat_fs_data = yes; then |
---|
375 | space=yes |
---|
376 | AC_DEFINE(STAT_STATFS2_FS_DATA) |
---|
377 | fi |
---|
378 | fi |
---|
379 | |
---|
380 | if test $space = no; then |
---|
381 | # SVR2 |
---|
382 | AC_TRY_CPP([#include <sys/filsys.h>], |
---|
383 | AC_DEFINE(STAT_READ_FILSYS) space=yes) |
---|
384 | fi |
---|
385 | |
---|
386 | if test -n "$list_mounted_fs" && test $space != no; then |
---|
387 | DF_PROG="df" |
---|
388 | # LIBOBJS="$LIBOBJS fsusage.o" |
---|
389 | # LIBOBJS="$LIBOBJS mountlist.o" |
---|
390 | fi |
---|
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. |
---|
395 | AC_MSG_CHECKING([for statfs that truncates block counts]) |
---|
396 | AC_CACHE_VAL(fu_cv_sys_truncating_statfs, |
---|
397 | [AC_TRY_COMPILE([ |
---|
398 | #if !defined(sun) && !defined(__sun) |
---|
399 | choke -- 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);], |
---|
404 | fu_cv_sys_truncating_statfs=yes, |
---|
405 | fu_cv_sys_truncating_statfs=no, |
---|
406 | )]) |
---|
407 | if test $fu_cv_sys_truncating_statfs = yes; then |
---|
408 | AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS) |
---|
409 | fi |
---|
410 | AC_MSG_RESULT($fu_cv_sys_truncating_statfs) |
---|
411 | |
---|
412 | AC_CHECKING(for AFS) |
---|
413 | test -d /afs && AC_DEFINE(AFS) |
---|
414 | ]) |
---|