3 AC_DEFUN(AM_FUNC_GETLOADAVG,
4 [ac_have_func=no # yes means we've found a way to get the load average.
6 am_cv_saved_LIBS="$LIBS"
8 # Solaris has libkstat which does not require root.
9 AC_CHECK_LIB(kstat, kstat_open)
10 if test $ac_cv_lib_kstat_kstat_open = yes ; then ac_have_func=yes ; fi
12 # Some systems with -lutil have (and need) -lkvm as well, some do not.
13 # On Solaris, -lkvm requires nlist from -lelf, so check that first
14 # to get the right answer into the cache.
15 # For kstat on solaris, we need libelf to force the definition of SVR4 below.
16 AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
17 if test $ac_have_func = no; then
18 AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
19 # Check for the 4.4BSD definition of getloadavg.
20 AC_CHECK_LIB(util, getloadavg,
21 [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
24 if test $ac_have_func = no; then
25 # There is a commonly available library for RS/6000 AIX.
26 # Since it is not a standard part of AIX, it might be installed locally.
28 LIBS="-L/usr/local/lib $LIBS"
29 AC_CHECK_LIB(getloadavg, getloadavg,
30 LIBS="-lgetloadavg $LIBS", LIBS="$ac_save_LIBS")
33 # Make sure it is really in the library, if we think we found it.
34 AC_REPLACE_FUNCS(getloadavg)
36 if test $ac_cv_func_getloadavg = yes; then
37 AC_DEFINE(HAVE_GETLOADAVG)
40 AC_DEFINE(C_GETLOADAVG)
41 # Figure out what our getloadavg.c needs.
43 AC_CHECK_HEADER(sys/dg_sys_info.h,
44 [ac_have_func=yes; AC_DEFINE(DGUX)
45 AC_CHECK_LIB(dgc, dg_sys_info)])
47 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
48 # uses stabs), but it is still SVR4. We cannot check for <elf.h> because
49 # Irix 4.0.5F has the header but not the library.
50 if test $ac_have_func = no && test $ac_cv_lib_elf_elf_begin = yes; then
51 ac_have_func=yes; AC_DEFINE(SVR4)
54 if test $ac_have_func = no; then
55 AC_CHECK_HEADER(inq_stats/cpustats.h,
56 [ac_have_func=yes; AC_DEFINE(UMAX)
60 if test $ac_have_func = no; then
61 AC_CHECK_HEADER(sys/cpustats.h,
62 [ac_have_func=yes; AC_DEFINE(UMAX)])
65 if test $ac_have_func = no; then
66 AC_CHECK_HEADERS(mach/mach.h)
69 AC_CHECK_HEADER(nlist.h,
70 [AC_DEFINE(NLIST_STRUCT)
71 AC_CACHE_CHECK([for n_un in struct nlist], ac_cv_struct_nlist_n_un,
72 [AC_TRY_COMPILE([#include <nlist.h>],
73 [struct nlist n; n.n_un.n_name = 0;],
74 ac_cv_struct_nlist_n_un=yes, ac_cv_struct_nlist_n_un=no)])
75 if test $ac_cv_struct_nlist_n_un = yes; then
76 AC_DEFINE(NLIST_NAME_UNION)
79 fi # Do not have getloadavg in system libraries.
81 # Some definitions of getloadavg require that the program be installed setgid.
82 dnl FIXME Don't hardwire the path of getloadavg.c in the top-level directory.
83 AC_CACHE_CHECK(whether getloadavg requires setgid,
84 ac_cv_func_getloadavg_setgid,
85 [AC_EGREP_CPP([Yowza Am I SETGID yet],
86 [#include "$srcdir/lib/getloadavg.c"
87 #ifdef LDAV_PRIVILEGED
90 ac_cv_func_getloadavg_setgid=yes, ac_cv_func_getloadavg_setgid=no)])
91 if test $ac_cv_func_getloadavg_setgid = yes; then
92 NEED_SETGID=true; AC_DEFINE(GETLOADAVG_PRIVILEGED)
96 AC_SUBST(NEED_SETGID)dnl
98 if test $ac_cv_func_getloadavg_setgid = yes; then
99 AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
100 changequote(<<, >>)dnl
102 # On Solaris, /dev/kmem is a symlink. Get info on the real file.
103 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
104 # If we got an error (system does not support symlinks), try without -L.
105 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
106 ac_cv_group_kmem=`echo $ac_ls_output \
107 | sed -ne 's/[ ][ ]*/ /g;
108 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
113 KMEM_GROUP=$ac_cv_group_kmem
115 AC_SUBST(KMEM_GROUP)dnl
117 if test x = "x$am_cv_saved_LIBS"; then
118 GETLOADAVG_LIBS="$LIBS"
120 GETLOADAVG_LIBS=`echo "$LIBS"|sed "s!$am_cv_saved_LIBS!!"`
122 AC_SUBST(GETLOADAVG_LIBS)dnl
123 LIBS="$am_cv_saved_LIBS"