1 | dnl This is just copied m4s from need-declaration.m4 gnome-fileutils.m4 |
---|
2 | dnl gnome-supprt-checks.m4 and a little from gnome-libgtop-check.m4 |
---|
3 | dnl and finally libgtop-sysdeps.m4 |
---|
4 | |
---|
5 | dnl |
---|
6 | dnl LIBGTOP_CHECK_TYPE |
---|
7 | dnl |
---|
8 | dnl Improved version of AC_CHECK_TYPE which takes into account |
---|
9 | dnl that we need to #include some other header files on some |
---|
10 | dnl systems to get some types. |
---|
11 | |
---|
12 | dnl AC_LIBGTOP_CHECK_TYPE(TYPE, DEFAULT) |
---|
13 | AC_DEFUN([AC_LIBGTOP_CHECK_TYPE], |
---|
14 | [AC_REQUIRE([AC_HEADER_STDC])dnl |
---|
15 | AC_MSG_CHECKING(for $1) |
---|
16 | AC_CACHE_VAL(ac_cv_type_$1, |
---|
17 | [AC_EGREP_CPP(dnl |
---|
18 | changequote(<<,>>)dnl |
---|
19 | <<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl |
---|
20 | changequote([,]), [#include <sys/types.h> |
---|
21 | #if STDC_HEADERS |
---|
22 | #include <stdlib.h> |
---|
23 | #include <stddef.h> |
---|
24 | #endif |
---|
25 | |
---|
26 | /* For Tru64 */ |
---|
27 | #ifdef HAVE_SYS_BITYPES_H |
---|
28 | #include <sys/bitypes.h> |
---|
29 | #endif |
---|
30 | ], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl |
---|
31 | AC_MSG_RESULT($ac_cv_type_$1) |
---|
32 | if test $ac_cv_type_$1 = no; then |
---|
33 | AC_DEFINE($1, $2) |
---|
34 | fi |
---|
35 | ]) |
---|
36 | |
---|
37 | dnl |
---|
38 | dnl GNOME_LIBGTOP_TYPES |
---|
39 | dnl |
---|
40 | dnl some typechecks for libgtop. |
---|
41 | dnl |
---|
42 | |
---|
43 | AC_DEFUN([GNOME_LIBGTOP_TYPES], |
---|
44 | [ |
---|
45 | AC_CHECK_HEADERS(sys/bitypes.h) |
---|
46 | AC_LIBGTOP_CHECK_TYPE(u_int64_t, unsigned long long int) |
---|
47 | AC_LIBGTOP_CHECK_TYPE(int64_t, signed long long int) |
---|
48 | ]) |
---|
49 | |
---|
50 | dnl See whether we need a declaration for a function. |
---|
51 | dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES]) |
---|
52 | AC_DEFUN([GCC_NEED_DECLARATION], |
---|
53 | [AC_MSG_CHECKING([whether $1 must be declared]) |
---|
54 | AC_CACHE_VAL(gcc_cv_decl_needed_$1, |
---|
55 | [AC_TRY_COMPILE([ |
---|
56 | #include <stdio.h> |
---|
57 | #ifdef HAVE_STRING_H |
---|
58 | #include <string.h> |
---|
59 | #else |
---|
60 | #ifdef HAVE_STRINGS_H |
---|
61 | #include <strings.h> |
---|
62 | #endif |
---|
63 | #endif |
---|
64 | #ifdef HAVE_STDLIB_H |
---|
65 | #include <stdlib.h> |
---|
66 | #endif |
---|
67 | #ifdef HAVE_UNISTD_H |
---|
68 | #include <unistd.h> |
---|
69 | #endif |
---|
70 | $2], |
---|
71 | [char *(*pfn) = (char *(*)) $1], |
---|
72 | eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")]) |
---|
73 | if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then |
---|
74 | AC_MSG_RESULT(yes) |
---|
75 | gcc_need_declarations="$gcc_need_declarations $1" |
---|
76 | gcc_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` |
---|
77 | AC_DEFINE_UNQUOTED($gcc_tr_decl) |
---|
78 | else |
---|
79 | AC_MSG_RESULT(no) |
---|
80 | fi |
---|
81 | ])dnl |
---|
82 | |
---|
83 | dnl Check multiple functions to see whether each needs a declaration. |
---|
84 | dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES]) |
---|
85 | AC_DEFUN([GCC_NEED_DECLARATIONS], |
---|
86 | [for ac_func in $1 |
---|
87 | do |
---|
88 | GCC_NEED_DECLARATION($ac_func, $2) |
---|
89 | done |
---|
90 | ] |
---|
91 | ) |
---|
92 | |
---|
93 | dnl |
---|
94 | dnl GNOME_FILEUTILS_CHECKS |
---|
95 | dnl |
---|
96 | dnl checks that are needed for the diskusage applet. |
---|
97 | dnl |
---|
98 | |
---|
99 | AC_DEFUN([GNOME_FILEUTILS_CHECKS], |
---|
100 | [ |
---|
101 | AC_CHECK_HEADERS(fcntl.h sys/param.h sys/statfs.h sys/fstyp.h \ |
---|
102 | mnttab.h mntent.h sys/statvfs.h sys/vfs.h sys/mount.h \ |
---|
103 | sys/filsys.h sys/fs_types.h sys/fs/s5param.h) |
---|
104 | |
---|
105 | AC_CHECK_FUNCS(bcopy endgrent endpwent fchdir ftime ftruncate \ |
---|
106 | getcwd getmntinfo gettimeofday isascii lchown \ |
---|
107 | listmntent memcpy mkfifo strchr strerror strrchr vprintf) |
---|
108 | |
---|
109 | dnl Set some defaults when cross-compiling |
---|
110 | |
---|
111 | if test x$cross_compiling = xyes ; then |
---|
112 | case "$host_os" in |
---|
113 | linux*) |
---|
114 | fu_cv_sys_mounted_getmntent1=yes |
---|
115 | fu_cv_sys_stat_statfs2_bsize=yes |
---|
116 | ;; |
---|
117 | sunos*) |
---|
118 | fu_cv_sys_stat_statfs4=yes |
---|
119 | ;; |
---|
120 | freebsd*) |
---|
121 | fu_cv_sys_stat_statfs2_bsize=yes |
---|
122 | ;; |
---|
123 | osf*) |
---|
124 | fu_cv_sys_stat_statfs3_osf1=yes |
---|
125 | ;; |
---|
126 | esac |
---|
127 | fi |
---|
128 | |
---|
129 | # Determine how to get the list of mounted filesystems. |
---|
130 | list_mounted_fs= |
---|
131 | |
---|
132 | # If the getmntent function is available but not in the standard library, |
---|
133 | # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX). |
---|
134 | AC_FUNC_GETMNTENT |
---|
135 | |
---|
136 | # This test must precede the ones for getmntent because Unicos-9 is |
---|
137 | # reported to have the getmntent function, but its support is incompatible |
---|
138 | # with other getmntent implementations. |
---|
139 | |
---|
140 | # NOTE: Normally, I wouldn't use a check for system type as I've done for |
---|
141 | # `CRAY' below since that goes against the whole autoconf philosophy. But |
---|
142 | # I think there is too great a chance that some non-Cray system has a |
---|
143 | # function named listmntent to risk the false positive. |
---|
144 | |
---|
145 | if test -z "$list_mounted_fs"; then |
---|
146 | # Cray UNICOS 9 |
---|
147 | AC_MSG_CHECKING([for listmntent of Cray/Unicos-9]) |
---|
148 | AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent, |
---|
149 | [fu_cv_sys_mounted_cray_listmntent=no |
---|
150 | AC_EGREP_CPP(yes, |
---|
151 | [#ifdef _CRAY |
---|
152 | yes |
---|
153 | #endif |
---|
154 | ], [test $ac_cv_func_listmntent = yes \ |
---|
155 | && fu_cv_sys_mounted_cray_listmntent=yes] |
---|
156 | ) |
---|
157 | ] |
---|
158 | ) |
---|
159 | AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent) |
---|
160 | if test $fu_cv_sys_mounted_cray_listmntent = yes; then |
---|
161 | list_mounted_fs=found |
---|
162 | AC_DEFINE(MOUNTED_LISTMNTENT) |
---|
163 | fi |
---|
164 | fi |
---|
165 | |
---|
166 | if test $ac_cv_func_getmntent = yes; then |
---|
167 | |
---|
168 | # This system has the getmntent function. |
---|
169 | # Determine whether it's the one-argument variant or the two-argument one. |
---|
170 | |
---|
171 | if test -z "$list_mounted_fs"; then |
---|
172 | # 4.3BSD, SunOS, HP-UX, Dynix, Irix |
---|
173 | AC_MSG_CHECKING([for one-argument getmntent function]) |
---|
174 | AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1, |
---|
175 | [test $ac_cv_header_mntent_h = yes \ |
---|
176 | && fu_cv_sys_mounted_getmntent1=yes \ |
---|
177 | || fu_cv_sys_mounted_getmntent1=no]) |
---|
178 | AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1) |
---|
179 | if test $fu_cv_sys_mounted_getmntent1 = yes; then |
---|
180 | list_mounted_fs=found |
---|
181 | AC_DEFINE(MOUNTED_GETMNTENT1) |
---|
182 | fi |
---|
183 | fi |
---|
184 | |
---|
185 | if test -z "$list_mounted_fs"; then |
---|
186 | # SVR4 |
---|
187 | AC_MSG_CHECKING([for two-argument getmntent function]) |
---|
188 | AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2, |
---|
189 | [AC_EGREP_HEADER(getmntent, sys/mnttab.h, |
---|
190 | fu_cv_sys_mounted_getmntent2=yes, |
---|
191 | fu_cv_sys_mounted_getmntent2=no)]) |
---|
192 | AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2) |
---|
193 | if test $fu_cv_sys_mounted_getmntent2 = yes; then |
---|
194 | list_mounted_fs=found |
---|
195 | AC_DEFINE(MOUNTED_GETMNTENT2) |
---|
196 | fi |
---|
197 | fi |
---|
198 | |
---|
199 | if test -z "$list_mounted_fs"; then |
---|
200 | AC_MSG_ERROR([could not determine how to read list of mounted filesystems]) |
---|
201 | fi |
---|
202 | |
---|
203 | fi |
---|
204 | |
---|
205 | if test -z "$list_mounted_fs"; then |
---|
206 | # DEC Alpha running OSF/1. |
---|
207 | AC_MSG_CHECKING([for getfsstat function]) |
---|
208 | AC_CACHE_VAL(fu_cv_sys_mounted_getsstat, |
---|
209 | [AC_TRY_LINK([ |
---|
210 | #include <sys/types.h> |
---|
211 | #include <sys/mount.h> |
---|
212 | #include <sys/fs_types.h>], |
---|
213 | [struct statfs *stats; |
---|
214 | int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ], |
---|
215 | fu_cv_sys_mounted_getsstat=yes, |
---|
216 | fu_cv_sys_mounted_getsstat=no)]) |
---|
217 | AC_MSG_RESULT($fu_cv_sys_mounted_getsstat) |
---|
218 | if test $fu_cv_sys_mounted_getsstat = yes; then |
---|
219 | list_mounted_fs=found |
---|
220 | AC_DEFINE(MOUNTED_GETFSSTAT) |
---|
221 | fi |
---|
222 | fi |
---|
223 | |
---|
224 | if test -z "$list_mounted_fs"; then |
---|
225 | # AIX. |
---|
226 | AC_MSG_CHECKING([for mntctl function and struct vmount]) |
---|
227 | AC_CACHE_VAL(fu_cv_sys_mounted_vmount, |
---|
228 | [AC_TRY_CPP([#include <fshelp.h>], |
---|
229 | fu_cv_sys_mounted_vmount=yes, |
---|
230 | fu_cv_sys_mounted_vmount=no)]) |
---|
231 | AC_MSG_RESULT($fu_cv_sys_mounted_vmount) |
---|
232 | if test $fu_cv_sys_mounted_vmount = yes; then |
---|
233 | list_mounted_fs=found |
---|
234 | AC_DEFINE(MOUNTED_VMOUNT) |
---|
235 | fi |
---|
236 | fi |
---|
237 | |
---|
238 | if test -z "$list_mounted_fs"; then |
---|
239 | # SVR3 |
---|
240 | AC_MSG_CHECKING([for FIXME existence of three headers]) |
---|
241 | AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp, |
---|
242 | [AC_TRY_CPP([ |
---|
243 | #include <sys/statfs.h> |
---|
244 | #include <sys/fstyp.h> |
---|
245 | #include <mnttab.h>], |
---|
246 | fu_cv_sys_mounted_fread_fstyp=yes, |
---|
247 | fu_cv_sys_mounted_fread_fstyp=no)]) |
---|
248 | AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp) |
---|
249 | if test $fu_cv_sys_mounted_fread_fstyp = yes; then |
---|
250 | list_mounted_fs=found |
---|
251 | AC_DEFINE(MOUNTED_FREAD_FSTYP) |
---|
252 | fi |
---|
253 | fi |
---|
254 | |
---|
255 | if test -z "$list_mounted_fs"; then |
---|
256 | # 4.4BSD and DEC OSF/1. |
---|
257 | AC_MSG_CHECKING([for getmntinfo function]) |
---|
258 | AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo, |
---|
259 | [ |
---|
260 | ok= |
---|
261 | if test $ac_cv_func_getmntinfo = yes; then |
---|
262 | AC_EGREP_HEADER(f_type;, sys/mount.h, |
---|
263 | ok=yes) |
---|
264 | fi |
---|
265 | test -n "$ok" \ |
---|
266 | && fu_cv_sys_mounted_getmntinfo=yes \ |
---|
267 | || fu_cv_sys_mounted_getmntinfo=no |
---|
268 | ]) |
---|
269 | AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo) |
---|
270 | if test $fu_cv_sys_mounted_getmntinfo = yes; then |
---|
271 | list_mounted_fs=found |
---|
272 | AC_DEFINE(MOUNTED_GETMNTINFO) |
---|
273 | fi |
---|
274 | fi |
---|
275 | |
---|
276 | # FIXME: add a test for netbsd-1.1 here |
---|
277 | |
---|
278 | if test -z "$list_mounted_fs"; then |
---|
279 | # Ultrix |
---|
280 | AC_MSG_CHECKING([for getmnt function]) |
---|
281 | AC_CACHE_VAL(fu_cv_sys_mounted_getmnt, |
---|
282 | [AC_TRY_CPP([ |
---|
283 | #include <sys/fs_types.h> |
---|
284 | #include <sys/mount.h>], |
---|
285 | fu_cv_sys_mounted_getmnt=yes, |
---|
286 | fu_cv_sys_mounted_getmnt=no)]) |
---|
287 | AC_MSG_RESULT($fu_cv_sys_mounted_getmnt) |
---|
288 | if test $fu_cv_sys_mounted_getmnt = yes; then |
---|
289 | list_mounted_fs=found |
---|
290 | AC_DEFINE(MOUNTED_GETMNT) |
---|
291 | fi |
---|
292 | fi |
---|
293 | |
---|
294 | if test -z "$list_mounted_fs"; then |
---|
295 | # SVR2 |
---|
296 | AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab]) |
---|
297 | AC_CACHE_VAL(fu_cv_sys_mounted_fread, |
---|
298 | [AC_TRY_CPP([#include <mnttab.h>], |
---|
299 | fu_cv_sys_mounted_fread=yes, |
---|
300 | fu_cv_sys_mounted_fread=no)]) |
---|
301 | AC_MSG_RESULT($fu_cv_sys_mounted_fread) |
---|
302 | if test $fu_cv_sys_mounted_fread = yes; then |
---|
303 | list_mounted_fs=found |
---|
304 | AC_DEFINE(MOUNTED_FREAD) |
---|
305 | fi |
---|
306 | fi |
---|
307 | |
---|
308 | if test -z "$list_mounted_fs"; then |
---|
309 | AC_MSG_ERROR([could not determine how to read list of mounted filesystems]) |
---|
310 | # FIXME -- no need to abort building the whole package |
---|
311 | # Cannot build mountlist.c or anything that needs its functions |
---|
312 | fi |
---|
313 | |
---|
314 | AC_CHECKING(how to get filesystem space usage) |
---|
315 | space=no |
---|
316 | |
---|
317 | # Perform only the link test since it seems there are no variants of the |
---|
318 | # statvfs function. This check is more than just AC_CHECK_FUNCS(statvfs) |
---|
319 | # because that got a false positive on SCO OSR5. Adding the declaration |
---|
320 | # of a `struct statvfs' causes this test to fail (as it should) on such |
---|
321 | # systems. That system is reported to work fine with STAT_STATFS4 which |
---|
322 | # is what it gets when this test fails. |
---|
323 | if test $space = no; then |
---|
324 | # SVR4 |
---|
325 | AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs, |
---|
326 | [AC_TRY_LINK([#include <sys/types.h> |
---|
327 | #include <sys/statvfs.h>], |
---|
328 | [struct statvfs fsd; statvfs (0, &fsd);], |
---|
329 | fu_cv_sys_stat_statvfs=yes, |
---|
330 | fu_cv_sys_stat_statvfs=no)]) |
---|
331 | if test $fu_cv_sys_stat_statvfs = yes; then |
---|
332 | space=yes |
---|
333 | AC_DEFINE(STAT_STATVFS) |
---|
334 | fi |
---|
335 | fi |
---|
336 | |
---|
337 | if test $space = no; then |
---|
338 | # DEC Alpha running OSF/1 |
---|
339 | AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) |
---|
340 | AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1, |
---|
341 | [AC_TRY_RUN([ |
---|
342 | #include <sys/param.h> |
---|
343 | #include <sys/types.h> |
---|
344 | #include <sys/mount.h> |
---|
345 | int main () |
---|
346 | { |
---|
347 | struct statfs fsd; |
---|
348 | fsd.f_fsize = 0; |
---|
349 | return (statfs (".", &fsd, sizeof (struct statfs))); |
---|
350 | }], |
---|
351 | fu_cv_sys_stat_statfs3_osf1=yes, |
---|
352 | fu_cv_sys_stat_statfs3_osf1=no, |
---|
353 | fu_cv_sys_stat_statfs3_osf1=no)]) |
---|
354 | AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1) |
---|
355 | if test $fu_cv_sys_stat_statfs3_osf1 = yes; then |
---|
356 | space=yes |
---|
357 | AC_DEFINE(STAT_STATFS3_OSF1) |
---|
358 | fi |
---|
359 | fi |
---|
360 | |
---|
361 | if test $space = no; then |
---|
362 | # AIX |
---|
363 | AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl |
---|
364 | member (AIX, 4.3BSD)]) |
---|
365 | AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize, |
---|
366 | [AC_TRY_RUN([ |
---|
367 | #ifdef HAVE_SYS_PARAM_H |
---|
368 | #include <sys/param.h> |
---|
369 | #endif |
---|
370 | #ifdef HAVE_SYS_MOUNT_H |
---|
371 | #include <sys/mount.h> |
---|
372 | #endif |
---|
373 | #ifdef HAVE_SYS_VFS_H |
---|
374 | #include <sys/vfs.h> |
---|
375 | #endif |
---|
376 | int main () |
---|
377 | { |
---|
378 | struct statfs fsd; |
---|
379 | fsd.f_bsize = 0; |
---|
380 | return (statfs (".", &fsd)); |
---|
381 | }], |
---|
382 | fu_cv_sys_stat_statfs2_bsize=yes, |
---|
383 | fu_cv_sys_stat_statfs2_bsize=no, |
---|
384 | fu_cv_sys_stat_statfs2_bsize=no)]) |
---|
385 | AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize) |
---|
386 | if test $fu_cv_sys_stat_statfs2_bsize = yes; then |
---|
387 | space=yes |
---|
388 | AC_DEFINE(STAT_STATFS2_BSIZE) |
---|
389 | fi |
---|
390 | fi |
---|
391 | |
---|
392 | if test $space = no; then |
---|
393 | # SVR3 |
---|
394 | AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) |
---|
395 | AC_CACHE_VAL(fu_cv_sys_stat_statfs4, |
---|
396 | [AC_TRY_RUN([#include <sys/types.h> |
---|
397 | #include <sys/statfs.h> |
---|
398 | int main () |
---|
399 | { |
---|
400 | struct statfs fsd; |
---|
401 | return (statfs (".", &fsd, sizeof fsd, 0)); |
---|
402 | }], |
---|
403 | fu_cv_sys_stat_statfs4=yes, |
---|
404 | fu_cv_sys_stat_statfs4=no, |
---|
405 | fu_cv_sys_stat_statfs4=no)]) |
---|
406 | AC_MSG_RESULT($fu_cv_sys_stat_statfs4) |
---|
407 | if test $fu_cv_sys_stat_statfs4 = yes; then |
---|
408 | space=yes |
---|
409 | AC_DEFINE(STAT_STATFS4) |
---|
410 | fi |
---|
411 | fi |
---|
412 | |
---|
413 | if test $space = no; then |
---|
414 | # 4.4BSD and NetBSD |
---|
415 | AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl |
---|
416 | member (4.4BSD and NetBSD)]) |
---|
417 | AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize, |
---|
418 | [AC_TRY_RUN([#include <sys/types.h> |
---|
419 | #ifdef HAVE_SYS_PARAM_H |
---|
420 | #include <sys/param.h> |
---|
421 | #endif |
---|
422 | #ifdef HAVE_SYS_MOUNT_H |
---|
423 | #include <sys/mount.h> |
---|
424 | #endif |
---|
425 | int main () |
---|
426 | { |
---|
427 | struct statfs fsd; |
---|
428 | fsd.f_fsize = 0; |
---|
429 | return (statfs (".", &fsd)); |
---|
430 | }], |
---|
431 | fu_cv_sys_stat_statfs2_fsize=yes, |
---|
432 | fu_cv_sys_stat_statfs2_fsize=no, |
---|
433 | fu_cv_sys_stat_statfs2_fsize=no)]) |
---|
434 | AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize) |
---|
435 | if test $fu_cv_sys_stat_statfs2_fsize = yes; then |
---|
436 | space=yes |
---|
437 | AC_DEFINE(STAT_STATFS2_FSIZE) |
---|
438 | fi |
---|
439 | fi |
---|
440 | |
---|
441 | if test $space = no; then |
---|
442 | # Ultrix |
---|
443 | AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)]) |
---|
444 | AC_CACHE_VAL(fu_cv_sys_stat_fs_data, |
---|
445 | [AC_TRY_RUN([#include <sys/types.h> |
---|
446 | #ifdef HAVE_SYS_PARAM_H |
---|
447 | #include <sys/param.h> |
---|
448 | #endif |
---|
449 | #ifdef HAVE_SYS_MOUNT_H |
---|
450 | #include <sys/mount.h> |
---|
451 | #endif |
---|
452 | #ifdef HAVE_SYS_FS_TYPES_H |
---|
453 | #include <sys/fs_types.h> |
---|
454 | #endif |
---|
455 | int main () |
---|
456 | { |
---|
457 | struct fs_data fsd; |
---|
458 | /* Ultrix's statfs returns 1 for success, |
---|
459 | 0 for not mounted, -1 for failure. */ |
---|
460 | return (statfs (".", &fsd) != 1); |
---|
461 | }], |
---|
462 | fu_cv_sys_stat_fs_data=yes, |
---|
463 | fu_cv_sys_stat_fs_data=no, |
---|
464 | fu_cv_sys_stat_fs_data=no)]) |
---|
465 | AC_MSG_RESULT($fu_cv_sys_stat_fs_data) |
---|
466 | if test $fu_cv_sys_stat_fs_data = yes; then |
---|
467 | space=yes |
---|
468 | AC_DEFINE(STAT_STATFS2_FS_DATA) |
---|
469 | fi |
---|
470 | fi |
---|
471 | |
---|
472 | if test $space = no; then |
---|
473 | # SVR2 |
---|
474 | AC_TRY_CPP([#include <sys/filsys.h>], |
---|
475 | AC_DEFINE(STAT_READ_FILSYS) space=yes) |
---|
476 | fi |
---|
477 | |
---|
478 | if test -n "$list_mounted_fs" && test $space != no; then |
---|
479 | DF_PROG="df" |
---|
480 | # LIBOBJS="$LIBOBJS fsusage.o" |
---|
481 | # LIBOBJS="$LIBOBJS mountlist.o" |
---|
482 | fi |
---|
483 | |
---|
484 | # Check for SunOS statfs brokenness wrt partitions 2GB and larger. |
---|
485 | # If <sys/vfs.h> exists and struct statfs has a member named f_spare, |
---|
486 | # enable the work-around code in fsusage.c. |
---|
487 | AC_MSG_CHECKING([for statfs that truncates block counts]) |
---|
488 | AC_CACHE_VAL(fu_cv_sys_truncating_statfs, |
---|
489 | [AC_TRY_COMPILE([ |
---|
490 | #if !defined(sun) && !defined(__sun) |
---|
491 | choke -- this is a workaround for a Sun-specific problem |
---|
492 | #endif |
---|
493 | #include <sys/types.h> |
---|
494 | #include <sys/vfs.h>], |
---|
495 | [struct statfs t; long c = *(t.f_spare);], |
---|
496 | fu_cv_sys_truncating_statfs=yes, |
---|
497 | fu_cv_sys_truncating_statfs=no, |
---|
498 | )]) |
---|
499 | if test $fu_cv_sys_truncating_statfs = yes; then |
---|
500 | AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS) |
---|
501 | fi |
---|
502 | AC_MSG_RESULT($fu_cv_sys_truncating_statfs) |
---|
503 | |
---|
504 | AC_CHECKING(for AFS) |
---|
505 | test -d /afs && AC_DEFINE(AFS) |
---|
506 | ]) |
---|
507 | |
---|
508 | dnl GNOME_SUPPORT_CHECKS |
---|
509 | dnl Check for various support functions needed by the standard |
---|
510 | dnl Gnome libraries. Sets LIBOBJS, might define some macros. |
---|
511 | dnl This should only be used when building the Gnome libs; |
---|
512 | dnl Gnome clients should not need this macro. |
---|
513 | AC_DEFUN([GNOME_SUPPORT_CHECKS],[ |
---|
514 | # we need an `awk' to build `gnomesupport.h' |
---|
515 | AC_REQUIRE([AC_PROG_AWK]) |
---|
516 | |
---|
517 | # this should go away soon |
---|
518 | need_gnome_support=yes |
---|
519 | |
---|
520 | save_LIBOBJS="$LIBOBJS" |
---|
521 | LIBOBJS= |
---|
522 | |
---|
523 | AC_CHECK_FUNCS(getopt_long,,LIBOBJS="$LIBOBJS getopt.o getopt1.o") |
---|
524 | |
---|
525 | # for `scandir' |
---|
526 | AC_HEADER_DIRENT |
---|
527 | |
---|
528 | # copied from `configure.in' of `libiberty' |
---|
529 | vars="program_invocation_short_name program_invocation_name sys_errlist" |
---|
530 | for v in $vars; do |
---|
531 | AC_MSG_CHECKING([for $v]) |
---|
532 | AC_CACHE_VAL(gnome_cv_var_$v, |
---|
533 | [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;], |
---|
534 | [eval "gnome_cv_var_$v=yes"], |
---|
535 | [eval "gnome_cv_var_$v=no"])]) |
---|
536 | if eval "test \"`echo '$gnome_cv_var_'$v`\" = yes"; then |
---|
537 | AC_MSG_RESULT(yes) |
---|
538 | n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` |
---|
539 | AC_DEFINE_UNQUOTED($n) |
---|
540 | else |
---|
541 | AC_MSG_RESULT(no) |
---|
542 | fi |
---|
543 | done |
---|
544 | |
---|
545 | AC_REPLACE_FUNCS(memmove mkstemp scandir strcasecmp strerror strndup strnlen) |
---|
546 | AC_REPLACE_FUNCS(strtok_r strtod strtol strtoul vasprintf vsnprintf) |
---|
547 | |
---|
548 | AC_CHECK_FUNCS(realpath,,LIBOBJS="$LIBOBJS canonicalize.o") |
---|
549 | |
---|
550 | # to include `error.c' error.c has some HAVE_* checks |
---|
551 | AC_CHECK_FUNCS(vprintf doprnt strerror_r) |
---|
552 | # stolen from am_func_error_at_line |
---|
553 | AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line, |
---|
554 | [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");], |
---|
555 | am_cv_lib_error_at_line=yes, |
---|
556 | am_cv_lib_error_at_line=no)]) |
---|
557 | if test $am_cv_lib_error_at_line = no; then |
---|
558 | LIBOBJS="$LIBOBJS error.o" |
---|
559 | fi |
---|
560 | AC_SUBST(LIBOBJS)dnl |
---|
561 | |
---|
562 | # This is required if we declare setreuid () and setregid (). |
---|
563 | AC_TYPE_UID_T |
---|
564 | |
---|
565 | # see if we need to declare some functions. Solaris is notorious for |
---|
566 | # putting functions into the `libc' but not listing them in the headers |
---|
567 | AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h dirent.h) |
---|
568 | GCC_NEED_DECLARATIONS(gethostname setreuid setregid getpagesize) |
---|
569 | GCC_NEED_DECLARATION(scandir,[ |
---|
570 | #ifdef HAVE_DIRENT_H |
---|
571 | #include <dirent.h> |
---|
572 | #endif |
---|
573 | ]) |
---|
574 | |
---|
575 | # Turn our LIBOBJS into libtool objects. This is gross, but it |
---|
576 | # requires changes to autoconf before it goes away. |
---|
577 | LTLIBOBJS=`echo "$LIBOBJS" | sed 's/\.o/.lo/g'` |
---|
578 | AC_SUBST(need_gnome_support) |
---|
579 | AC_SUBST(LTLIBOBJS) |
---|
580 | |
---|
581 | LIBOBJS="$save_LIBOBJS" |
---|
582 | AM_CONDITIONAL(BUILD_GNOME_SUPPORT, test "$need_gnome_support" = yes) |
---|
583 | ]) |
---|
584 | |
---|
585 | |
---|
586 | dnl This file is intended for use both internally in libgtop and in every program |
---|
587 | dnl that wants to use it. |
---|
588 | dnl |
---|
589 | dnl It defines the following variables: |
---|
590 | dnl |
---|
591 | dnl * 'libgtop_sysdeps_dir' - sysdeps dir for libgtop. |
---|
592 | dnl * 'libgtop_use_machine_h' - some of system dependend parts of libgtop provide |
---|
593 | dnl their own header file. In this case we need to |
---|
594 | dnl define 'HAVE_GLIBTOP_MACHINE_H'. |
---|
595 | dnl * 'libgtop_need_server' - is the server really needed? Defines 'NEED_LIBGTOP' |
---|
596 | dnl if true; defines conditional 'NEED_LIBGTOP'. |
---|
597 | |
---|
598 | AC_DEFUN([LIBGTOP_HACKER_TESTS],[ |
---|
599 | AC_REQUIRE([AC_CANONICAL_HOST]) |
---|
600 | |
---|
601 | AC_ARG_WITH(linux-table, |
---|
602 | [ --with-linux-table Use the table () function from Martin Baulig], |
---|
603 | [linux_table="$withval"],[linux_table=auto]) |
---|
604 | case "$host_os" in |
---|
605 | linux*) |
---|
606 | if test $linux_table = yes ; then |
---|
607 | AC_CHECK_HEADER(linux/table.h, linux_table=yes, linux_table=no) |
---|
608 | elif test $linux_table = auto ; then |
---|
609 | AC_MSG_CHECKING(for table function in Linux Kernel) |
---|
610 | AC_TRY_RUN([ |
---|
611 | #include <stdio.h> |
---|
612 | #include <stdlib.h> |
---|
613 | |
---|
614 | #include <unistd.h> |
---|
615 | #include <linux/unistd.h> |
---|
616 | #include <linux/table.h> |
---|
617 | |
---|
618 | #include <syscall.h> |
---|
619 | |
---|
620 | static inline _syscall3 (int, table, int, type, union table *, tbl, const void *, param); |
---|
621 | |
---|
622 | int |
---|
623 | main (void) |
---|
624 | { |
---|
625 | union table tbl; |
---|
626 | int ret; |
---|
627 | |
---|
628 | ret = table (TABLE_VERSION, NULL, NULL); |
---|
629 | |
---|
630 | if (ret == -1) |
---|
631 | exit (-errno); |
---|
632 | |
---|
633 | exit (ret < 1 ? ret : 0); |
---|
634 | } |
---|
635 | ], linux_table=yes, linux_table=no, linux_table=no) |
---|
636 | AC_MSG_RESULT($linux_table) |
---|
637 | fi |
---|
638 | if test $linux_table = yes ; then |
---|
639 | AC_DEFINE(HAVE_LINUX_TABLE) |
---|
640 | fi |
---|
641 | ;; |
---|
642 | esac |
---|
643 | ]) |
---|
644 | |
---|
645 | AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[ |
---|
646 | AC_REQUIRE([AC_CANONICAL_HOST]) |
---|
647 | |
---|
648 | AC_SUBST(libgtop_sysdeps_dir) |
---|
649 | AC_SUBST(libgtop_use_machine_h) |
---|
650 | AC_SUBST(libgtop_need_server) |
---|
651 | |
---|
652 | AC_ARG_WITH(libgtop-examples, |
---|
653 | [ --with-libgtop-examples Build the libgtop examples (default=no)],[ |
---|
654 | build_examples="$withval"], [build_examples=no]) |
---|
655 | |
---|
656 | AM_CONDITIONAL(EXAMPLES, test x"$build_examples" = xyes) |
---|
657 | |
---|
658 | AC_ARG_ENABLE(hacker-mode, |
---|
659 | [ --enable-hacker-mode Enable building of unstable sysdeps], |
---|
660 | [hacker_mode="$enableval"], [hacker_mode=no]) |
---|
661 | |
---|
662 | AM_CONDITIONAL(HACKER_MODE, test x"$hacker_mode" = xyes) |
---|
663 | |
---|
664 | linux_table=auto |
---|
665 | if test x$hacker_mode = xyes ; then |
---|
666 | LIBGTOP_HACKER_TESTS |
---|
667 | fi |
---|
668 | AM_CONDITIONAL(LINUX_TABLE, test $linux_table = yes) |
---|
669 | |
---|
670 | AC_ARG_WITH(libgtop-smp, |
---|
671 | [ --with-libgtop-smp Enable SMP support (default-auto)],[ |
---|
672 | libgtop_smp="$withval"],[libgtop_smp=auto]) |
---|
673 | |
---|
674 | if test $libgtop_smp = auto ; then |
---|
675 | AC_MSG_CHECKING(whether to enable SMP support) |
---|
676 | case "$host_os" in |
---|
677 | linux*) |
---|
678 | libgtop_smp=yes |
---|
679 | ;; |
---|
680 | *) |
---|
681 | libgtop_smp=no |
---|
682 | ;; |
---|
683 | esac |
---|
684 | AC_MSG_RESULT($libgtop_smp) |
---|
685 | fi |
---|
686 | |
---|
687 | if test $libgtop_smp = yes ; then |
---|
688 | AC_DEFINE(HAVE_LIBGTOP_SMP) |
---|
689 | fi |
---|
690 | |
---|
691 | AM_CONDITIONAL(LIBGTOP_SMP, test $libgtop_smp = yes) |
---|
692 | |
---|
693 | AC_MSG_CHECKING(for libgtop sysdeps directory) |
---|
694 | |
---|
695 | case "$host_os" in |
---|
696 | linux*) |
---|
697 | if test x$linux_table = xyes ; then |
---|
698 | libgtop_sysdeps_dir=kernel |
---|
699 | libgtop_use_machine_h=no |
---|
700 | else |
---|
701 | libgtop_sysdeps_dir=linux |
---|
702 | libgtop_use_machine_h=no |
---|
703 | libgtop_have_sysinfo=yes |
---|
704 | fi |
---|
705 | libgtop_need_server=no |
---|
706 | ;; |
---|
707 | freebsd*|netbsd*|openbsd*|bsdi*) |
---|
708 | libgtop_sysdeps_dir=freebsd |
---|
709 | libgtop_use_machine_h=yes |
---|
710 | libgtop_need_server=yes |
---|
711 | libgtop_postinstall='chgrp kmem $(bindir)/libgtop_server && chmod 2755 $(bindir)/libgtop_server' |
---|
712 | ;; |
---|
713 | solaris*) |
---|
714 | libgtop_sysdeps_dir=solaris |
---|
715 | libgtop_use_machine_h=yes |
---|
716 | libgtop_need_server=yes |
---|
717 | libgtop_postinstall='chgrp sys $(bindir)/libgtop_server && chmod 2755 $(bindir)/libgtop_server' |
---|
718 | ;; |
---|
719 | *) |
---|
720 | if test x$hacker_mode = xyes ; then |
---|
721 | case "$host_os" in |
---|
722 | sunos4*) |
---|
723 | #Please note that this port is obsolete and not working at |
---|
724 | #all. It is only useful for people who want to fix it ... :-) |
---|
725 | libgtop_sysdeps_dir=sun4 |
---|
726 | libgtop_use_machine_h=yes |
---|
727 | libgtop_need_server=yes |
---|
728 | ;; |
---|
729 | osf*) |
---|
730 | libgtop_sysdeps_dir=osf1 |
---|
731 | libgtop_use_machine_h=yes |
---|
732 | libgtop_need_server=yes |
---|
733 | ;; |
---|
734 | *) |
---|
735 | libgtop_sysdeps_dir=stub |
---|
736 | libgtop_use_machine_h=no |
---|
737 | libgtop_need_server=no |
---|
738 | ;; |
---|
739 | esac |
---|
740 | else |
---|
741 | libgtop_sysdeps_dir=stub |
---|
742 | libgtop_use_machine_h=no |
---|
743 | libgtop_need_server=no |
---|
744 | fi |
---|
745 | ;; |
---|
746 | esac |
---|
747 | |
---|
748 | test -z "$libgtop_postinstall" && libgtop_postinstall=: |
---|
749 | |
---|
750 | AC_MSG_RESULT($libgtop_sysdeps_dir) |
---|
751 | |
---|
752 | AC_SUBST(libgtop_sysdeps_dir) |
---|
753 | AC_SUBST(libgtop_postinstall) |
---|
754 | AC_SUBST(libgtop_have_sysinfo) |
---|
755 | |
---|
756 | case "$host_os" in |
---|
757 | *bsd*) |
---|
758 | AC_CHECK_HEADERS(net/if_var.h) |
---|
759 | AC_MSG_CHECKING([for I4B]) |
---|
760 | AC_TRY_COMPILE([ |
---|
761 | #include <sys/types.h> |
---|
762 | #include <sys/socket.h> |
---|
763 | |
---|
764 | #include <net/if.h> |
---|
765 | #include <net/if_types.h> |
---|
766 | |
---|
767 | #ifdef HAVE_NET_IF_VAR_H |
---|
768 | #include <net/if_var.h> |
---|
769 | #endif |
---|
770 | |
---|
771 | #include <net/netisr.h> |
---|
772 | #include <net/route.h> |
---|
773 | |
---|
774 | #if defined(__FreeBSD__) || defined(__NetBSD__) |
---|
775 | #include <net/if_sppp.h> |
---|
776 | #else |
---|
777 | #include <i4b/sppp/if_sppp.h> |
---|
778 | #endif |
---|
779 | ],[ |
---|
780 | size_t size = sizeof (struct sppp); |
---|
781 | ], have_i4b=yes, have_i4b=no) |
---|
782 | AC_MSG_RESULT($have_i4b) |
---|
783 | if test x$have_i4b = xyes; then |
---|
784 | AC_DEFINE(HAVE_I4B) |
---|
785 | AC_MSG_CHECKING([for I4B accounting]) |
---|
786 | AC_TRY_COMPILE([ |
---|
787 | #include <sys/types.h> |
---|
788 | #include <sys/socket.h> |
---|
789 | |
---|
790 | #include <net/if.h> |
---|
791 | #include <net/if_types.h> |
---|
792 | |
---|
793 | #ifdef HAVE_NET_IF_VAR_H |
---|
794 | #include <net/if_var.h> |
---|
795 | #endif |
---|
796 | |
---|
797 | #include <net/netisr.h> |
---|
798 | #include <net/route.h> |
---|
799 | |
---|
800 | #if defined(__FreeBSD__) || defined(__NetBSD__) |
---|
801 | #include <net/if_sppp.h> |
---|
802 | #else |
---|
803 | #include <i4b/sppp/if_sppp.h> |
---|
804 | #endif |
---|
805 | |
---|
806 | #include <machine/i4b_acct.h> |
---|
807 | ],[ |
---|
808 | size_t size = sizeof (struct i4bisppp_softc); |
---|
809 | ], have_i4b_acct=yes, have_i4b_acct=no) |
---|
810 | AC_MSG_RESULT($have_i4b_acct) |
---|
811 | if test x$have_i4b_acct = xyes ; then |
---|
812 | AC_DEFINE(HAVE_I4B_ACCT) |
---|
813 | else |
---|
814 | AC_WARN([ |
---|
815 | *** I4B accounting disabled - you won't get any PPP statistics. |
---|
816 | *** Read "misc/i4b_acct.txt" in the LibGTop source directory |
---|
817 | *** to see how to enable it.]) |
---|
818 | fi |
---|
819 | fi |
---|
820 | ;; |
---|
821 | linux*) |
---|
822 | os_major_version=`uname -r | sed 's/-pre[[0-9]]*//' | \ |
---|
823 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
---|
824 | os_minor_version=`uname -r | sed 's/-pre[[0-9]]*//' | \ |
---|
825 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
---|
826 | os_micro_version=`uname -r | sed 's/-pre[[0-9]]*//' | \ |
---|
827 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
---|
828 | os_version_expr="$os_major_version 65536 * $os_minor_version 256 * + $os_micro_version + p q" |
---|
829 | |
---|
830 | AC_CHECK_HEADERS(linux/version.h, have_linux_version_h=yes, |
---|
831 | have_linux_version_h=no) |
---|
832 | |
---|
833 | if test x$have_linux_version_h = xyes ; then |
---|
834 | version_code=`cat /usr/include/linux/version.h | \ |
---|
835 | grep \#define | grep LINUX_VERSION_CODE` |
---|
836 | os_version_code=`echo $version_code | \ |
---|
837 | sed 's/^.*LINUX_VERSION_CODE[[ \t]]*\([[0-9]]*\).*$/\1/'` |
---|
838 | else |
---|
839 | os_version_code=`echo "$os_version_expr" | dc` |
---|
840 | fi |
---|
841 | |
---|
842 | AC_MSG_CHECKING(for Linux kernel version code) |
---|
843 | AC_DEFINE_UNQUOTED(GLIBTOP_LINUX_VERSION_CODE, $os_version_code) |
---|
844 | AC_MSG_RESULT($os_version_code) |
---|
845 | ;; |
---|
846 | solaris*) |
---|
847 | os_major_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]\)\.*\([[0-9]]*\)/\1/'` |
---|
848 | os_minor_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]\)\.*\([[0-9]]*\)/\2/'` |
---|
849 | os_micro_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]\)\.*\([[0-9]]*\)/\3/'` |
---|
850 | test -z "$os_micro_version" && os_micro_version=0 |
---|
851 | os_version_expr="$os_major_version 100 * $os_minor_version 10 * + $os_micro_version + p q" |
---|
852 | os_version_code=`echo "$os_version_expr" | dc` |
---|
853 | |
---|
854 | AC_MSG_CHECKING(for Solaris release code) |
---|
855 | AC_DEFINE_UNQUOTED(GLIBTOP_SOLARIS_RELEASE, $os_version_code) |
---|
856 | AC_MSG_RESULT($os_version_code) |
---|
857 | ;; |
---|
858 | esac |
---|
859 | |
---|
860 | AC_MSG_CHECKING(for machine.h in libgtop sysdeps dir) |
---|
861 | AC_MSG_RESULT($libgtop_use_machine_h) |
---|
862 | |
---|
863 | AC_MSG_CHECKING(whether we need libgtop) |
---|
864 | AC_MSG_RESULT($libgtop_need_server) |
---|
865 | |
---|
866 | if test x$libgtop_need_server = xyes ; then |
---|
867 | AC_DEFINE(NEED_LIBGTOP) |
---|
868 | fi |
---|
869 | |
---|
870 | if test x$libgtop_use_machine_h = xyes ; then |
---|
871 | AC_DEFINE(HAVE_GLIBTOP_MACHINE_H) |
---|
872 | fi |
---|
873 | |
---|
874 | AM_CONDITIONAL(NEED_LIBGTOP, test x$libgtop_need_server = xyes) |
---|
875 | ]) |
---|
876 | |
---|
877 | |
---|