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 # On HPUX9, an unprivileged user can get load averages through this function.
9 AC_CHECK_FUNCS(pstat_getdynamic)
11 # Solaris has libkstat which does not require root.
12 AC_CHECK_LIB(kstat, kstat_open)
13 if test $ac_cv_lib_kstat_kstat_open = yes ; then ac_have_func=yes ; fi
15 # Some systems with -lutil have (and need) -lkvm as well, some do not.
16 # On Solaris, -lkvm requires nlist from -lelf, so check that first
17 # to get the right answer into the cache.
18 # For kstat on solaris, we need libelf to force the definition of SVR4 below.
19 AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
20 if test $ac_have_func = no; then
21 AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
22 # Check for the 4.4BSD definition of getloadavg.
23 AC_CHECK_LIB(util, getloadavg,
24 [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
27 if test $ac_have_func = no; then
28 # There is a commonly available library for RS/6000 AIX.
29 # Since it is not a standard part of AIX, it might be installed locally.
31 LIBS="-L/usr/local/lib $LIBS"
32 AC_CHECK_LIB(getloadavg, getloadavg,
33 LIBS="-lgetloadavg $LIBS", LIBS="$ac_save_LIBS")
36 # Make sure it is really in the library, if we think we found it.
37 AC_REPLACE_FUNCS(getloadavg)
39 if test $ac_cv_func_getloadavg = yes; then
40 AC_DEFINE(HAVE_GETLOADAVG)
43 AC_DEFINE(C_GETLOADAVG)
44 # Figure out what our getloadavg.c needs.
46 AC_CHECK_HEADER(sys/dg_sys_info.h,
47 [ac_have_func=yes; AC_DEFINE(DGUX)
48 AC_CHECK_LIB(dgc, dg_sys_info)])
50 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
51 # uses stabs), but it is still SVR4. We cannot check for <elf.h> because
52 # Irix 4.0.5F has the header but not the library.
53 if test $ac_have_func = no && test $ac_cv_lib_elf_elf_begin = yes; then
54 ac_have_func=yes; AC_DEFINE(SVR4)
57 if test $ac_have_func = no; then
58 AC_CHECK_HEADER(inq_stats/cpustats.h,
59 [ac_have_func=yes; AC_DEFINE(UMAX)
63 if test $ac_have_func = no; then
64 AC_CHECK_HEADER(sys/cpustats.h,
65 [ac_have_func=yes; AC_DEFINE(UMAX)])
68 if test $ac_have_func = no; then
69 AC_CHECK_HEADERS(mach/mach.h)
72 AC_CHECK_HEADER(nlist.h,
73 [AC_DEFINE(NLIST_STRUCT)
74 AC_CACHE_CHECK([for n_un in struct nlist], ac_cv_struct_nlist_n_un,
75 [AC_TRY_COMPILE([#include <nlist.h>],
76 [struct nlist n; n.n_un.n_name = 0;],
77 ac_cv_struct_nlist_n_un=yes, ac_cv_struct_nlist_n_un=no)])
78 if test $ac_cv_struct_nlist_n_un = yes; then
79 AC_DEFINE(NLIST_NAME_UNION)
82 fi # Do not have getloadavg in system libraries.
84 # Some definitions of getloadavg require that the program be installed setgid.
85 dnl FIXME Don't hardwire the path of getloadavg.c in the top-level directory.
86 AC_CACHE_CHECK(whether getloadavg requires setgid,
87 ac_cv_func_getloadavg_setgid,
88 [AC_EGREP_CPP([Yowza Am I SETGID yet],
89 [#include "$srcdir/lib/getloadavg.c"
90 #ifdef LDAV_PRIVILEGED
93 ac_cv_func_getloadavg_setgid=yes, ac_cv_func_getloadavg_setgid=no)])
94 if test $ac_cv_func_getloadavg_setgid = yes; then
95 NEED_SETGID=true; AC_DEFINE(GETLOADAVG_PRIVILEGED)
99 AC_SUBST(NEED_SETGID)dnl
101 if test $ac_cv_func_getloadavg_setgid = yes; then
102 AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
103 changequote(<<, >>)dnl
105 # On Solaris, /dev/kmem is a symlink. Get info on the real file.
106 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
107 # If we got an error (system does not support symlinks), try without -L.
108 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
109 ac_cv_group_kmem=`echo $ac_ls_output \
110 | sed -ne 's/[ ][ ]*/ /g;
111 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
116 KMEM_GROUP=$ac_cv_group_kmem
118 AC_SUBST(KMEM_GROUP)dnl
120 if test x = "x$am_cv_saved_LIBS"; then
121 GETLOADAVG_LIBS="$LIBS"
123 GETLOADAVG_LIBS=`echo "$LIBS"|sed "s!$am_cv_saved_LIBS!!"`
125 AC_SUBST(GETLOADAVG_LIBS)dnl
126 LIBS="$am_cv_saved_LIBS"