summaryrefslogtreecommitdiffstats
path: root/gl/m4/getloadavg.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/getloadavg.m4')
-rw-r--r--gl/m4/getloadavg.m481
1 files changed, 50 insertions, 31 deletions
diff --git a/gl/m4/getloadavg.m4 b/gl/m4/getloadavg.m4
index c1547c7..015bcac 100644
--- a/gl/m4/getloadavg.m4
+++ b/gl/m4/getloadavg.m4
@@ -1,7 +1,7 @@
1# Check for getloadavg. 1# Check for getloadavg.
2 2
3# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2002, 2003, 3# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2002, 2003,
4# 2006 Free Software Foundation, Inc. 4# 2006, 2008, 2009 Free Software Foundation, Inc.
5 5
6# This file is free software; the Free Software Foundation 6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it, 7# gives unlimited permission to copy and/or distribute it,
@@ -13,7 +13,12 @@
13# gl_GETLOADAVG(LIBOBJDIR) 13# gl_GETLOADAVG(LIBOBJDIR)
14# ------------------------ 14# ------------------------
15AC_DEFUN([gl_GETLOADAVG], 15AC_DEFUN([gl_GETLOADAVG],
16[gl_have_func=no # yes means we've found a way to get the load average. 16[AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
17
18# Persuade glibc <stdlib.h> to declare getloadavg().
19AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
20
21gl_have_func=no # yes means we've found a way to get the load average.
17 22
18# Make sure getloadavg.c is where it belongs, at configure-time. 23# Make sure getloadavg.c is where it belongs, at configure-time.
19test -f "$srcdir/$1/getloadavg.c" || 24test -f "$srcdir/$1/getloadavg.c" ||
@@ -22,17 +27,17 @@ test -f "$srcdir/$1/getloadavg.c" ||
22gl_save_LIBS=$LIBS 27gl_save_LIBS=$LIBS
23 28
24# Check for getloadavg, but be sure not to touch the cache variable. 29# Check for getloadavg, but be sure not to touch the cache variable.
25(AC_CHECK_FUNC(getloadavg, exit 0, exit 1)) && gl_have_func=yes 30(AC_CHECK_FUNC([getloadavg], [exit 0], [exit 1])) && gl_have_func=yes
26 31
27# On HPUX9, an unprivileged user can get load averages through this function. 32# On HPUX9, an unprivileged user can get load averages through this function.
28AC_CHECK_FUNCS(pstat_getdynamic) 33AC_CHECK_FUNCS([pstat_getdynamic])
29 34
30# Solaris has libkstat which does not require root. 35# Solaris has libkstat which does not require root.
31AC_CHECK_LIB(kstat, kstat_open) 36AC_CHECK_LIB([kstat], [kstat_open])
32test $ac_cv_lib_kstat_kstat_open = yes && gl_have_func=yes 37test $ac_cv_lib_kstat_kstat_open = yes && gl_have_func=yes
33 38
34# AIX has libperfstat which does not require root 39# AIX has libperfstat which does not require root
35AC_CHECK_LIB(perfstat, perfstat_cpu_total) 40AC_CHECK_LIB([perfstat], [perfstat_cpu_total])
36test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes 41test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes
37 42
38# Some systems with -lutil have (and need) -lkvm as well, some do not. 43# Some systems with -lutil have (and need) -lkvm as well, some do not.
@@ -40,12 +45,12 @@ test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes
40# to get the right answer into the cache. 45# to get the right answer into the cache.
41# For kstat on solaris, we need libelf to force the definition of SVR4 below. 46# For kstat on solaris, we need libelf to force the definition of SVR4 below.
42if test $gl_have_func = no; then 47if test $gl_have_func = no; then
43 AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS") 48 AC_CHECK_LIB([elf], [elf_begin], [LIBS="-lelf $LIBS"])
44fi 49fi
45if test $gl_have_func = no; then 50if test $gl_have_func = no; then
46 AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS") 51 AC_CHECK_LIB([kvm], [kvm_open], [LIBS="-lkvm $LIBS"])
47 # Check for the 4.4BSD definition of getloadavg. 52 # Check for the 4.4BSD definition of getloadavg.
48 AC_CHECK_LIB(util, getloadavg, 53 AC_CHECK_LIB([util], [getloadavg],
49 [LIBS="-lutil $LIBS" gl_have_func=yes gl_cv_func_getloadavg_setgid=yes]) 54 [LIBS="-lutil $LIBS" gl_have_func=yes gl_cv_func_getloadavg_setgid=yes])
50fi 55fi
51 56
@@ -54,17 +59,17 @@ if test $gl_have_func = no; then
54 # Since it is not a standard part of AIX, it might be installed locally. 59 # Since it is not a standard part of AIX, it might be installed locally.
55 gl_getloadavg_LIBS=$LIBS 60 gl_getloadavg_LIBS=$LIBS
56 LIBS="-L/usr/local/lib $LIBS" 61 LIBS="-L/usr/local/lib $LIBS"
57 AC_CHECK_LIB(getloadavg, getloadavg, 62 AC_CHECK_LIB([getloadavg], [getloadavg],
58 [LIBS="-lgetloadavg $LIBS"], [LIBS=$gl_getloadavg_LIBS]) 63 [LIBS="-lgetloadavg $LIBS"], [LIBS=$gl_getloadavg_LIBS])
59fi 64fi
60 65
61# Make sure it is really in the library, if we think we found it, 66# Make sure it is really in the library, if we think we found it,
62# otherwise set up the replacement function. 67# otherwise set up the replacement function.
63AC_CHECK_FUNCS(getloadavg, [], 68AC_CHECK_FUNCS([getloadavg], [],
64 [gl_PREREQ_GETLOADAVG]) 69 [gl_PREREQ_GETLOADAVG])
65 70
66# Some definitions of getloadavg require that the program be installed setgid. 71# Some definitions of getloadavg require that the program be installed setgid.
67AC_CACHE_CHECK(whether getloadavg requires setgid, 72AC_CACHE_CHECK([whether getloadavg requires setgid],
68 gl_cv_func_getloadavg_setgid, 73 gl_cv_func_getloadavg_setgid,
69[AC_EGREP_CPP([Yowza Am I SETGID yet], 74[AC_EGREP_CPP([Yowza Am I SETGID yet],
70[#define CONFIGURING_GETLOADAVG 75[#define CONFIGURING_GETLOADAVG
@@ -77,16 +82,16 @@ Yowza Am I SETGID yet
77 gl_cv_func_getloadavg_setgid=no)]) 82 gl_cv_func_getloadavg_setgid=no)])
78if test $gl_cv_func_getloadavg_setgid = yes; then 83if test $gl_cv_func_getloadavg_setgid = yes; then
79 NEED_SETGID=true 84 NEED_SETGID=true
80 AC_DEFINE(GETLOADAVG_PRIVILEGED, 1, 85 AC_DEFINE([GETLOADAVG_PRIVILEGED], [1],
81 [Define to 1 if the `getloadavg' function needs to be run setuid 86 [Define to 1 if the `getloadavg' function needs to be run setuid
82 or setgid.]) 87 or setgid.])
83else 88else
84 NEED_SETGID=false 89 NEED_SETGID=false
85fi 90fi
86AC_SUBST(NEED_SETGID)dnl 91AC_SUBST([NEED_SETGID])dnl
87 92
88if test $gl_cv_func_getloadavg_setgid = yes; then 93if test $gl_cv_func_getloadavg_setgid = yes; then
89 AC_CACHE_CHECK(group of /dev/kmem, gl_cv_group_kmem, 94 AC_CACHE_CHECK([group of /dev/kmem], [gl_cv_group_kmem],
90[ # On Solaris, /dev/kmem is a symlink. Get info on the real file. 95[ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
91 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null` 96 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
92 # If we got an error (system does not support symlinks), try without -L. 97 # If we got an error (system does not support symlinks), try without -L.
@@ -96,7 +101,7 @@ if test $gl_cv_func_getloadavg_setgid = yes; then
96 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/ 101 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/
97 / /s/.* //;p']` 102 / /s/.* //;p']`
98]) 103])
99 AC_SUBST(KMEM_GROUP, $gl_cv_group_kmem)dnl 104 AC_SUBST([KMEM_GROUP], [$gl_cv_group_kmem])dnl
100fi 105fi
101if test "x$gl_save_LIBS" = x; then 106if test "x$gl_save_LIBS" = x; then
102 GETLOADAVG_LIBS=$LIBS 107 GETLOADAVG_LIBS=$LIBS
@@ -105,7 +110,21 @@ else
105fi 110fi
106LIBS=$gl_save_LIBS 111LIBS=$gl_save_LIBS
107 112
108AC_SUBST(GETLOADAVG_LIBS)dnl 113AC_SUBST([GETLOADAVG_LIBS])dnl
114
115# Test whether the system declares getloadavg. Solaris has the function
116# but declares it in <sys/loadavg.h>, not <stdlib.h>.
117AC_CHECK_HEADERS([sys/loadavg.h])
118if test $ac_cv_header_sys_loadavg_h = yes; then
119 HAVE_SYS_LOADAVG_H=1
120else
121 HAVE_SYS_LOADAVG_H=0
122fi
123AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0],
124 [#if HAVE_SYS_LOADAVG_H
125 # include <sys/loadavg.h>
126 #endif
127 #include <stdlib.h>])
109])# gl_GETLOADAVG 128])# gl_GETLOADAVG
110 129
111 130
@@ -113,44 +132,44 @@ AC_SUBST(GETLOADAVG_LIBS)dnl
113# -------------------- 132# --------------------
114# Set up the AC_LIBOBJ replacement of `getloadavg'. 133# Set up the AC_LIBOBJ replacement of `getloadavg'.
115AC_DEFUN([gl_PREREQ_GETLOADAVG], 134AC_DEFUN([gl_PREREQ_GETLOADAVG],
116[AC_LIBOBJ(getloadavg) 135[AC_LIBOBJ([getloadavg])
117AC_DEFINE(C_GETLOADAVG, 1, [Define to 1 if using `getloadavg.c'.]) 136AC_DEFINE([C_GETLOADAVG], [1], [Define to 1 if using `getloadavg.c'.])
118# Figure out what our getloadavg.c needs. 137# Figure out what our getloadavg.c needs.
119gl_have_func=no 138gl_have_func=no
120AC_CHECK_HEADER(sys/dg_sys_info.h, 139AC_CHECK_HEADER([sys/dg_sys_info.h],
121[gl_have_func=yes 140[gl_have_func=yes
122 AC_DEFINE(DGUX, 1, [Define to 1 for DGUX with <sys/dg_sys_info.h>.]) 141 AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
123 AC_CHECK_LIB(dgc, dg_sys_info)]) 142 AC_CHECK_LIB([dgc], [dg_sys_info])])
124 143
125# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it 144# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
126# uses stabs), but it is still SVR4. We cannot check for <elf.h> because 145# uses stabs), but it is still SVR4. We cannot check for <elf.h> because
127# Irix 4.0.5F has the header but not the library. 146# Irix 4.0.5F has the header but not the library.
128if test $gl_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes; then 147if test $gl_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes; then
129 gl_have_func=yes 148 gl_have_func=yes
130 AC_DEFINE(SVR4, 1, [Define to 1 on System V Release 4.]) 149 AC_DEFINE([SVR4], [1], [Define to 1 on System V Release 4.])
131fi 150fi
132 151
133if test $gl_have_func = no; then 152if test $gl_have_func = no; then
134 AC_CHECK_HEADER(inq_stats/cpustats.h, 153 AC_CHECK_HEADER([inq_stats/cpustats.h],
135 [gl_have_func=yes 154 [gl_have_func=yes
136 AC_DEFINE(UMAX, 1, [Define to 1 for Encore UMAX.]) 155 AC_DEFINE([UMAX], [1], [Define to 1 for Encore UMAX.])
137 AC_DEFINE(UMAX4_3, 1, 156 AC_DEFINE([UMAX4_3], [1],
138 [Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h> 157 [Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
139 instead of <sys/cpustats.h>.])]) 158 instead of <sys/cpustats.h>.])])
140fi 159fi
141 160
142if test $gl_have_func = no; then 161if test $gl_have_func = no; then
143 AC_CHECK_HEADER(sys/cpustats.h, 162 AC_CHECK_HEADER([sys/cpustats.h],
144 [gl_have_func=yes; AC_DEFINE(UMAX)]) 163 [gl_have_func=yes; AC_DEFINE([UMAX])])
145fi 164fi
146 165
147if test $gl_have_func = no; then 166if test $gl_have_func = no; then
148 AC_CHECK_HEADERS(mach/mach.h) 167 AC_CHECK_HEADERS([mach/mach.h])
149fi 168fi
150 169
151AC_CHECK_HEADERS(nlist.h, 170AC_CHECK_HEADERS([nlist.h],
152[AC_CHECK_MEMBERS([struct nlist.n_un.n_name], 171[AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
153 [AC_DEFINE(NLIST_NAME_UNION, 1, 172 [AC_DEFINE([NLIST_NAME_UNION], [1],
154 [Define to 1 if your `struct nlist' has an 173 [Define to 1 if your `struct nlist' has an
155 `n_un' member. Obsolete, depend on 174 `n_un' member. Obsolete, depend on
156 `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [], 175 `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],