[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Paul Eggert
Subject: Re: Bug in AC_FUNC_GETLOADAVG
Date: Wed, 8 May 2002 15:40:19 -0700 (PDT)

> From: "Paul D. Smith" <address@hidden>
> Date: 08 May 2002 17:12:39 -0400
> Bleah.  This macro is really whacked, as is the getloadavg.c file
> itself.

Yes.  I think the problem is that getloadavg.c predates autoconf, so
it uses a bunch of ad-hoc rules that really should be removed and
replaced with autoconf'ed versions.  But nobody has had the time to
do it "right".

>   # AC_FUNC_GETLOADAVG is documented to set the NLIST_STRUCT value, but it
>   # doesn't.  So, we will.
>   if test "$ac_cv_header_nlist_h" = yes; then
>     AC_TRY_COMPILE([#include <nlist.h>],
>         [struct nlist nl;
>          nl.n_name = "string";
>          return 0;],
>         make_cv_nlist_struct=yes,
>         make_cv_nlist_struct=no)
>     if test "$make_cv_nlist_struct" = yes; then
>          [Define if struct nlist.n_name is a pointer rather than an array.])
>     fi
>   fi
> That allows my test cross-compile (to QNX) to compile.

Which getloadavg.c were you using?  The latest one I know of is in

Does that sh-utils have a similar problem on QNX?  (Try its "uptime"
command.)  If not, perhaps you could just use the sh-utils getloadavg.c,
and sidestep the problems you're experiencing.

> Looking at the getloadavg.c code I see that as long as the SVR4 macro is
> set, we assume that we have either nlist or knlist() (unless we're on
> SGI, sigh).
> Looking at AC_FUNC_GETLOADAVG I see that we set SVR4 if we can find the
> elf_begin() function in -lelf.
> That, to me, seems like a pretty bogus test for SVR4, and checking for
> SVR4 seems like a pretty bogus way to decide whether you have nlist()

Yes, a lot of stuff in there is bogus, but nobody has had the time to
fix it.

To help remove some of the confusion, I have installed the following
patch to CVS autoconf.  This merges the sh-utils changes to
AC_FUNC_GETLOADAVG, and fixes the doc bug that you noted.  A lot of
work still remains in this area, thogh.  (If you want to volunteer, I
don't envy you ....)

2002-05-08  Paul Eggert  <address@hidden>

        * lib/autoconf/functions.m4 (AC_FUNC_GETLOADAVG): Add optional
        argument specifying location of getloadavg.c.  This removes a
        FIXME.  This idea was taken from Jim Meyering's implementation in
        * doc/autoconf.texi (Particular Functions): Document this.
        Also, mention HAVE_NLIST_H rather than NLIST_STRUCT, since
        that's what the code does; this fixes a bug reported by
        Paul D. Smith.

Index: doc/autoconf.texi
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.622
diff -p -u -r1.622 autoconf.texi
--- doc/autoconf.texi   3 May 2002 16:09:11 -0000       1.622
+++ doc/autoconf.texi   8 May 2002 22:29:29 -0000
@@ -3591,13 +3591,13 @@ Ultrix 4.3, where @samp{getgroups (0, 0)
 needed to get that function.  This macro runs @code{AC_TYPE_GETGROUPS}.
 @end defmac
address@hidden AC_FUNC_GETLOADAVG
address@hidden AC_FUNC_GETLOADAVG (@dvar{dir, .})
 @cvindex SVR4
 @cvindex DGUX
 @cvindex UMAX
 @cvindex UMAX4_3
address@hidden NLIST_STRUCT
address@hidden HAVE_NLIST_H
 @cvindex NEED_SETGID
@@ -3613,8 +3613,9 @@ Check how to get the system load average
 @code{GETLOADAVG_LIBS} to any libraries needed to get that function.
 Also add @code{GETLOADAVG_LIBS} to @code{LIBS}.
-Otherwise, require an @code{AC_LIBOBJ} replacement (@file{getloadavg.c})
-of @samp{getloadavg}, and possibly define several other C preprocessor
+Otherwise, require an @code{AC_LIBOBJ} replacement for
address@hidden with source code in @address@hidden/getloadavg.c},
+and possibly define several other C preprocessor
 macros and output variables:
@@ -3626,7 +3627,7 @@ Define @code{SVR4}, @code{DGUX}, @code{U
 those systems.
-If @file{nlist.h} is found, define @code{NLIST_STRUCT}.
+If @file{nlist.h} is found, define @code{HAVE_NLIST_H}.
 If @samp{struct nlist} has an @samp{n_un.n_name} member, define
Index: lib/autoconf/functions.m4
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/functions.m4,v
retrieving revision 1.59
diff -p -u -r1.59 functions.m4
--- lib/autoconf/functions.m4   8 May 2002 19:56:55 -0000       1.59
+++ lib/autoconf/functions.m4   8 May 2002 22:29:29 -0000
@@ -492,6 +492,14 @@ AC_CHECK_HEADERS(nlist.h,
 [ac_have_func=no # yes means we've found a way to get the load average.
+# The directory to find getloadavg.c in.
+ac_lib_dir_getloadavg=$srcdir[]m4_ifval([$1], [/$1])
+# Make sure getloadavg.c is where it belongs, at configure-time.
+test -f "$ac_lib_dir_getloadavg/getloadavg.c" ||
+  AC_MSG_ERROR([$ac_lib_dir_getloadavg/getloadavg.c is missing])
+# FIXME: Add an autoconf-time test, too?
 # Check for getloadavg, but be sure not to touch the cache variable.
@@ -533,11 +541,10 @@ AC_CHECK_FUNCS(getloadavg, [],
 # Some definitions of getloadavg require that the program be installed setgid.
-dnl FIXME: Don't hardwire the path of getloadavg.c in the top-level directory.
 AC_CACHE_CHECK(whether getloadavg requires setgid,
 [AC_EGREP_CPP([Yowza Am I SETGID yet],
-[#include "$srcdir/getloadavg.c"
+[#include "$ac_lib_dir_getloadavg/getloadavg.c"
 Yowza Am I SETGID yet

reply via email to

[Prev in Thread] Current Thread [Next in Thread]