source: trunk/third/libgtop/acinclude.m4 @ 18532

Revision 18532, 23.6 KB checked in by ghudson, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18531, which included commits to RCS files with non-trunk default branches.
Line 
1dnl This is just copied m4s from need-declaration.m4 gnome-fileutils.m4
2dnl gnome-supprt-checks.m4 and a little from gnome-libgtop-check.m4
3dnl and finally libgtop-sysdeps.m4
4
5dnl
6dnl LIBGTOP_CHECK_TYPE
7dnl
8dnl Improved version of AC_CHECK_TYPE which takes into account
9dnl that we need to #include some other header files on some
10dnl systems to get some types.
11
12dnl AC_LIBGTOP_CHECK_TYPE(TYPE, DEFAULT)
13AC_DEFUN([AC_LIBGTOP_CHECK_TYPE],
14[AC_REQUIRE([AC_HEADER_STDC])dnl
15AC_MSG_CHECKING(for $1)
16AC_CACHE_VAL(ac_cv_type_$1,
17[AC_EGREP_CPP(dnl
18changequote(<<,>>)dnl
19<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
20changequote([,]), [#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
31AC_MSG_RESULT($ac_cv_type_$1)
32if test $ac_cv_type_$1 = no; then
33  AC_DEFINE($1, $2)
34fi
35])
36
37dnl
38dnl GNOME_LIBGTOP_TYPES
39dnl
40dnl some typechecks for libgtop.
41dnl
42
43AC_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
50dnl See whether we need a declaration for a function.
51dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
52AC_DEFUN([GCC_NEED_DECLARATION],
53[AC_MSG_CHECKING([whether $1 must be declared])
54AC_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],
72eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")])
73if 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)
78else
79  AC_MSG_RESULT(no)
80fi
81])dnl
82
83dnl Check multiple functions to see whether each needs a declaration.
84dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
85AC_DEFUN([GCC_NEED_DECLARATIONS],
86[for ac_func in $1
87do
88GCC_NEED_DECLARATION($ac_func, $2)
89done
90]
91)
92
93dnl
94dnl GNOME_FILEUTILS_CHECKS
95dnl
96dnl checks that are needed for the diskusage applet.
97dnl
98
99AC_DEFUN([GNOME_FILEUTILS_CHECKS],
100[
101AC_CHECK_HEADERS(fcntl.h sys/param.h sys/statfs.h sys/fstyp.h \
102mnttab.h mntent.h sys/statvfs.h sys/vfs.h sys/mount.h \
103sys/filsys.h sys/fs_types.h sys/fs/s5param.h)
104
105AC_CHECK_FUNCS(bcopy endgrent endpwent fchdir ftime ftruncate \
106getcwd getmntinfo gettimeofday isascii lchown \
107listmntent memcpy mkfifo strchr strerror strrchr vprintf)
108
109dnl Set some defaults when cross-compiling
110
111if 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
127fi
128
129# Determine how to get the list of mounted filesystems.
130list_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).
134AC_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
145if test -z "$list_mounted_fs"; then
146# Cray UNICOS 9
147AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
148AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
149[fu_cv_sys_mounted_cray_listmntent=no
150AC_EGREP_CPP(yes,
151[#ifdef _CRAY
152yes
153#endif
154], [test $ac_cv_func_listmntent = yes \
155&& fu_cv_sys_mounted_cray_listmntent=yes]
156)
157]
158)
159AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
160if test $fu_cv_sys_mounted_cray_listmntent = yes; then
161list_mounted_fs=found
162AC_DEFINE(MOUNTED_LISTMNTENT)
163fi
164fi
165
166if 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
171if test -z "$list_mounted_fs"; then
172# 4.3BSD, SunOS, HP-UX, Dynix, Irix
173AC_MSG_CHECKING([for one-argument getmntent function])
174AC_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])
178AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
179if test $fu_cv_sys_mounted_getmntent1 = yes; then
180list_mounted_fs=found
181AC_DEFINE(MOUNTED_GETMNTENT1)
182fi
183fi
184
185if test -z "$list_mounted_fs"; then
186# SVR4
187AC_MSG_CHECKING([for two-argument getmntent function])
188AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
189[AC_EGREP_HEADER(getmntent, sys/mnttab.h,
190fu_cv_sys_mounted_getmntent2=yes,
191fu_cv_sys_mounted_getmntent2=no)])
192AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
193if test $fu_cv_sys_mounted_getmntent2 = yes; then
194list_mounted_fs=found
195AC_DEFINE(MOUNTED_GETMNTENT2)
196fi
197fi
198
199if test -z "$list_mounted_fs"; then
200AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
201fi
202
203fi
204
205if test -z "$list_mounted_fs"; then
206# DEC Alpha running OSF/1.
207AC_MSG_CHECKING([for getfsstat function])
208AC_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;
214int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
215fu_cv_sys_mounted_getsstat=yes,
216fu_cv_sys_mounted_getsstat=no)])
217AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
218if test $fu_cv_sys_mounted_getsstat = yes; then
219list_mounted_fs=found
220AC_DEFINE(MOUNTED_GETFSSTAT)
221fi
222fi
223
224if test -z "$list_mounted_fs"; then
225# AIX.
226AC_MSG_CHECKING([for mntctl function and struct vmount])
227AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
228[AC_TRY_CPP([#include <fshelp.h>],
229fu_cv_sys_mounted_vmount=yes,
230fu_cv_sys_mounted_vmount=no)])
231AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
232if test $fu_cv_sys_mounted_vmount = yes; then
233list_mounted_fs=found
234AC_DEFINE(MOUNTED_VMOUNT)
235fi
236fi
237
238if test -z "$list_mounted_fs"; then
239# SVR3
240AC_MSG_CHECKING([for FIXME existence of three headers])
241AC_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>],
246fu_cv_sys_mounted_fread_fstyp=yes,
247fu_cv_sys_mounted_fread_fstyp=no)])
248AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
249if test $fu_cv_sys_mounted_fread_fstyp = yes; then
250list_mounted_fs=found
251AC_DEFINE(MOUNTED_FREAD_FSTYP)
252fi
253fi
254
255if test -z "$list_mounted_fs"; then
256# 4.4BSD and DEC OSF/1.
257AC_MSG_CHECKING([for getmntinfo function])
258AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
259[
260ok=
261if test $ac_cv_func_getmntinfo = yes; then
262AC_EGREP_HEADER(f_type;, sys/mount.h,
263ok=yes)
264fi
265test -n "$ok" \
266&& fu_cv_sys_mounted_getmntinfo=yes \
267|| fu_cv_sys_mounted_getmntinfo=no
268])
269AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
270if test $fu_cv_sys_mounted_getmntinfo = yes; then
271list_mounted_fs=found
272AC_DEFINE(MOUNTED_GETMNTINFO)
273fi
274fi
275
276# FIXME: add a test for netbsd-1.1 here
277
278if test -z "$list_mounted_fs"; then
279# Ultrix
280AC_MSG_CHECKING([for getmnt function])
281AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
282[AC_TRY_CPP([
283#include <sys/fs_types.h>
284#include <sys/mount.h>],
285fu_cv_sys_mounted_getmnt=yes,
286fu_cv_sys_mounted_getmnt=no)])
287AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
288if test $fu_cv_sys_mounted_getmnt = yes; then
289list_mounted_fs=found
290AC_DEFINE(MOUNTED_GETMNT)
291fi
292fi
293
294if test -z "$list_mounted_fs"; then
295# SVR2
296AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
297AC_CACHE_VAL(fu_cv_sys_mounted_fread,
298[AC_TRY_CPP([#include <mnttab.h>],
299fu_cv_sys_mounted_fread=yes,
300fu_cv_sys_mounted_fread=no)])
301AC_MSG_RESULT($fu_cv_sys_mounted_fread)
302if test $fu_cv_sys_mounted_fread = yes; then
303list_mounted_fs=found
304AC_DEFINE(MOUNTED_FREAD)
305fi
306fi
307
308if test -z "$list_mounted_fs"; then
309AC_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
312fi
313
314AC_CHECKING(how to get filesystem space usage)
315space=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.
323if test $space = no; then
324# SVR4
325AC_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);],
329fu_cv_sys_stat_statvfs=yes,
330fu_cv_sys_stat_statvfs=no)])
331if test $fu_cv_sys_stat_statvfs = yes; then
332space=yes
333AC_DEFINE(STAT_STATVFS)
334fi
335fi
336
337if test $space = no; then
338# DEC Alpha running OSF/1
339AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
340AC_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>
345int main ()
346{
347struct statfs fsd;
348fsd.f_fsize = 0;
349return (statfs (".", &fsd, sizeof (struct statfs)));
350}],
351fu_cv_sys_stat_statfs3_osf1=yes,
352fu_cv_sys_stat_statfs3_osf1=no,
353fu_cv_sys_stat_statfs3_osf1=no)])
354AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
355if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
356space=yes
357AC_DEFINE(STAT_STATFS3_OSF1)
358fi
359fi
360
361if test $space = no; then
362# AIX
363AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
364member (AIX, 4.3BSD)])
365AC_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
376int main ()
377{
378struct statfs fsd;
379fsd.f_bsize = 0;
380return (statfs (".", &fsd));
381}],
382fu_cv_sys_stat_statfs2_bsize=yes,
383fu_cv_sys_stat_statfs2_bsize=no,
384fu_cv_sys_stat_statfs2_bsize=no)])
385AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
386if test $fu_cv_sys_stat_statfs2_bsize = yes; then
387space=yes
388AC_DEFINE(STAT_STATFS2_BSIZE)
389fi
390fi
391
392if test $space = no; then
393# SVR3
394AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
395AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
396[AC_TRY_RUN([#include <sys/types.h>
397#include <sys/statfs.h>
398int main ()
399{
400struct statfs fsd;
401return (statfs (".", &fsd, sizeof fsd, 0));
402}],
403fu_cv_sys_stat_statfs4=yes,
404fu_cv_sys_stat_statfs4=no,
405fu_cv_sys_stat_statfs4=no)])
406AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
407if test $fu_cv_sys_stat_statfs4 = yes; then
408space=yes
409AC_DEFINE(STAT_STATFS4)
410fi
411fi
412
413if test $space = no; then
414# 4.4BSD and NetBSD
415AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
416member (4.4BSD and NetBSD)])
417AC_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
425int main ()
426{
427struct statfs fsd;
428fsd.f_fsize = 0;
429return (statfs (".", &fsd));
430}],
431fu_cv_sys_stat_statfs2_fsize=yes,
432fu_cv_sys_stat_statfs2_fsize=no,
433fu_cv_sys_stat_statfs2_fsize=no)])
434AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
435if test $fu_cv_sys_stat_statfs2_fsize = yes; then
436space=yes
437AC_DEFINE(STAT_STATFS2_FSIZE)
438fi
439fi
440
441if test $space = no; then
442# Ultrix
443AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
444AC_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
455int main ()
456{
457struct fs_data fsd;
458/* Ultrix's statfs returns 1 for success,
4590 for not mounted, -1 for failure.  */
460return (statfs (".", &fsd) != 1);
461}],
462fu_cv_sys_stat_fs_data=yes,
463fu_cv_sys_stat_fs_data=no,
464fu_cv_sys_stat_fs_data=no)])
465AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
466if test $fu_cv_sys_stat_fs_data = yes; then
467space=yes
468AC_DEFINE(STAT_STATFS2_FS_DATA)
469fi
470fi
471
472if test $space = no; then
473# SVR2
474AC_TRY_CPP([#include <sys/filsys.h>],
475AC_DEFINE(STAT_READ_FILSYS) space=yes)
476fi
477
478if test -n "$list_mounted_fs" && test $space != no; then
479DF_PROG="df"
480# LIBOBJS="$LIBOBJS fsusage.o"
481# LIBOBJS="$LIBOBJS mountlist.o"
482fi
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.
487AC_MSG_CHECKING([for statfs that truncates block counts])
488AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
489[AC_TRY_COMPILE([
490#if !defined(sun) && !defined(__sun)
491choke -- 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);],
496fu_cv_sys_truncating_statfs=yes,
497fu_cv_sys_truncating_statfs=no,
498)])
499if test $fu_cv_sys_truncating_statfs = yes; then
500AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS)
501fi
502AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
503
504AC_CHECKING(for AFS)
505test -d /afs && AC_DEFINE(AFS)
506])
507
508dnl GNOME_SUPPORT_CHECKS
509dnl    Check for various support functions needed by the standard
510dnl    Gnome libraries.  Sets LIBOBJS, might define some macros.
511dnl    This should only be used when building the Gnome libs;
512dnl    Gnome clients should not need this macro.
513AC_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
586dnl This file is intended for use both internally in libgtop and in every program
587dnl that wants to use it.
588dnl
589dnl It defines the following variables:
590dnl
591dnl * 'libgtop_sysdeps_dir'    - sysdeps dir for libgtop.
592dnl * 'libgtop_use_machine_h'  - some of system dependend parts of libgtop provide
593dnl                              their own header file. In this case we need to
594dnl                              define 'HAVE_GLIBTOP_MACHINE_H'.
595dnl * 'libgtop_need_server'    - is the server really needed? Defines 'NEED_LIBGTOP'
596dnl                              if true; defines conditional 'NEED_LIBGTOP'.
597
598AC_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
620static inline _syscall3 (int, table, int, type, union table *, tbl, const void *, param);
621
622int
623main (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
645AC_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          aix*)
681            libgtop_smp=yes
682            ;;
683          *)
684            libgtop_smp=no
685            ;;
686          esac
687          AC_MSG_RESULT($libgtop_smp)
688        fi
689
690        if test $libgtop_smp = yes ; then
691          AC_DEFINE(HAVE_LIBGTOP_SMP)
692        fi
693
694        AM_CONDITIONAL(LIBGTOP_SMP, test $libgtop_smp = yes)
695
696        AC_MSG_CHECKING(for libgtop sysdeps directory)
697
698        case "$host_os" in
699        linux*)
700          if test x$linux_table = xyes ; then
701            libgtop_sysdeps_dir=kernel
702            libgtop_use_machine_h=no
703          else
704            libgtop_sysdeps_dir=linux
705            libgtop_use_machine_h=no
706            libgtop_have_sysinfo=yes
707          fi
708          libgtop_need_server=no
709          ;;
710        freebsd*|netbsd*|openbsd*|bsdi*)
711          libgtop_sysdeps_dir=freebsd
712          libgtop_use_machine_h=yes
713          libgtop_need_server=yes
714          libgtop_postinstall='chgrp kmem $(bindir)/libgtop_server && chmod 2755 $(bindir)/libgtop_server'
715          ;;
716        solaris*)
717          libgtop_sysdeps_dir=solaris
718          libgtop_use_machine_h=yes
719          libgtop_need_server=yes
720          libgtop_postinstall='chgrp sys $(bindir)/libgtop_server && chmod 2755 $(bindir)/libgtop_server'
721          ;;
722        aix*)
723          libgtop_sysdeps_dir=aix
724          libgtop_use_machine_h=yes
725          libgtop_need_server=yes
726          libgtop_have_sysinfo=yes
727          libgtop_postinstall='chgrp system $(bindir)/libgtop_server && chmod g+s $(bindir)/libgtop_server2'
728          ;;
729        *)
730          if test x$hacker_mode = xyes ; then
731            case "$host_os" in
732            sunos4*)
733              #Please note that this port is obsolete and not working at
734              #all. It is only useful for people who want to fix it ... :-)
735              libgtop_sysdeps_dir=sun4
736              libgtop_use_machine_h=yes
737              libgtop_need_server=yes
738              ;;
739            osf*)
740              libgtop_sysdeps_dir=osf1
741              libgtop_use_machine_h=yes
742              libgtop_need_server=yes
743              ;;
744            *)
745              libgtop_sysdeps_dir=stub
746              libgtop_use_machine_h=no
747              libgtop_need_server=no
748              ;;
749            esac
750          else
751            libgtop_sysdeps_dir=stub
752            libgtop_use_machine_h=no
753            libgtop_need_server=no
754          fi
755          ;;
756        esac
757
758        test -z "$libgtop_postinstall" && libgtop_postinstall=:
759
760        AC_MSG_RESULT($libgtop_sysdeps_dir)
761
762        AC_SUBST(libgtop_sysdeps_dir)
763        AC_SUBST(libgtop_postinstall)
764        AC_SUBST(libgtop_have_sysinfo)
765
766        case "$host_os" in
767        *bsd*)
768          AC_CHECK_HEADERS(net/if_var.h)
769          AC_MSG_CHECKING([for I4B])
770          AC_TRY_COMPILE([
771#include <sys/types.h>
772#include <sys/socket.h>
773
774#include <net/if.h>
775#include <net/if_types.h>
776
777#ifdef HAVE_NET_IF_VAR_H
778#include <net/if_var.h>
779#endif
780
781#include <net/netisr.h>
782#include <net/route.h>
783
784#if defined(__FreeBSD__) || defined(__NetBSD__)
785#include <net/if_sppp.h>
786#else
787#include <i4b/sppp/if_sppp.h>
788#endif
789],[
790        size_t size = sizeof (struct sppp);
791], have_i4b=yes, have_i4b=no)
792          AC_MSG_RESULT($have_i4b)
793          if test x$have_i4b = xyes; then
794            AC_DEFINE(HAVE_I4B)
795            AC_MSG_CHECKING([for I4B accounting])
796            AC_TRY_COMPILE([
797#include <sys/types.h>
798#include <sys/socket.h>
799
800#include <net/if.h>
801#include <net/if_types.h>
802
803#ifdef HAVE_NET_IF_VAR_H
804#include <net/if_var.h>
805#endif
806
807#include <net/netisr.h>
808#include <net/route.h>
809
810#if defined(__FreeBSD__) || defined(__NetBSD__)
811#include <net/if_sppp.h>
812#else
813#include <i4b/sppp/if_sppp.h>
814#endif
815
816#include <machine/i4b_acct.h>
817],[
818        size_t size = sizeof (struct i4bisppp_softc);
819], have_i4b_acct=yes, have_i4b_acct=no)
820            AC_MSG_RESULT($have_i4b_acct)
821            if test x$have_i4b_acct = xyes ; then
822              AC_DEFINE(HAVE_I4B_ACCT)
823            else
824              AC_WARN([
825*** I4B accounting disabled - you won't get any PPP statistics.
826*** Read "misc/i4b_acct.txt" in the LibGTop source directory
827*** to see how to enable it.])
828            fi
829          fi
830          ;;
831        linux*)
832          os_major_version=`uname -r | sed 's/-pre[[0-9]]*//' | \
833            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
834          os_minor_version=`uname -r | sed 's/-pre[[0-9]]*//' | \
835            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
836          os_micro_version=`uname -r | sed 's/-pre[[0-9]]*//' | \
837            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
838          os_version_expr="$os_major_version 65536 * $os_minor_version 256 * + $os_micro_version + p q"
839
840          AC_CHECK_HEADERS(linux/version.h, have_linux_version_h=yes,
841            have_linux_version_h=no)
842
843          if test x$have_linux_version_h = xyes ; then
844            version_code=`cat /usr/include/linux/version.h | \
845              grep \#define | grep LINUX_VERSION_CODE`
846            os_version_code=`echo $version_code | \
847              sed 's/^.*LINUX_VERSION_CODE[[ \t]]*\([[0-9]]*\).*$/\1/'`
848          else
849            os_version_code=`echo "$os_version_expr" | dc`
850          fi
851
852          AC_MSG_CHECKING(for Linux kernel version code)
853          AC_DEFINE_UNQUOTED(GLIBTOP_LINUX_VERSION_CODE, $os_version_code)
854          AC_MSG_RESULT($os_version_code)
855          ;;
856        solaris*)
857          os_major_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]\)\.*\([[0-9]]*\)/\1/'`
858          os_minor_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]\)\.*\([[0-9]]*\)/\2/'`
859          os_micro_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]\)\.*\([[0-9]]*\)/\3/'`
860          test -z "$os_micro_version" && os_micro_version=0
861          os_version_expr="$os_major_version 100 * $os_minor_version 10 * + $os_micro_version + p q"
862          os_version_code=`echo "$os_version_expr" | dc`
863
864          AC_MSG_CHECKING(for Solaris release code)
865          AC_DEFINE_UNQUOTED(GLIBTOP_SOLARIS_RELEASE, $os_version_code)
866          AC_MSG_RESULT($os_version_code)
867          ;;
868        esac
869
870        AC_MSG_CHECKING(for machine.h in libgtop sysdeps dir)
871        AC_MSG_RESULT($libgtop_use_machine_h)
872
873        AC_MSG_CHECKING(whether we need libgtop)
874        AC_MSG_RESULT($libgtop_need_server)
875
876        if test x$libgtop_need_server = xyes ; then
877          AC_DEFINE(NEED_LIBGTOP)
878        fi
879
880        if test x$libgtop_use_machine_h = xyes ; then
881          AC_DEFINE(HAVE_GLIBTOP_MACHINE_H)
882        fi
883
884        AM_CONDITIONAL(NEED_LIBGTOP, test x$libgtop_need_server = xyes)
885])
886
887 
Note: See TracBrowser for help on using the repository browser.