bug-gnulib
[Top][All Lists]
Advanced

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

bug in use of AC_HEADER_DIRENT


From: Eric Blake
Subject: bug in use of AC_HEADER_DIRENT
Date: Tue, 14 Mar 2006 17:08:02 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

CVS findutils currently tickles a bug in its use of AC_HEADER_DIRENT.
Somehow, the combination of modules pulled in by findutils led to
the following macro chain (among others):

gl_INIT
+-gl_FUNC_DIRFD
| +-AC_HEADER_DIRENT
+-gl_FUNC_FTS
| +-AC_REQUIRE([gl_FUNC_FTS_CORE])
|   +-AC_REQUIRE([AC_HEADER_DIRENT])
+-gl_FUNC_GETCWD
| +-case
|   +-gl_PREREQ_GETCWD
|     +-AC_REQUIRE([AC_HEADER_DIRENT])
|     +-AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO])
|       +-AC_REQUIRE([AC_HEADER_DIRENT])
+-gl_SAVEDIR
| +-AC_REQUIRE([AC_HEADER_DIRENT])
| +-AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID])
|   +-AC_REQUIRE([AC_HEADER_DIRENT])
+-gl_XGETCWD
  +-AC_REQUIRE([gl_FUNC_GETCWD])


Somehow this chain was evil enough to make autoconf not expand
AC_HEADER_DIRENT until after gl_CHECK_TYPE_STRUCT_DIRENT_D_INO
and AC_FUNC_CLOSEDIR_VOID, leading to the following beauties in
the config.log:

configure:7157: checking for d_ino member in directory struct
configure:7194: gcc -o conftest.exe -g2 -Wall   conftest.c  >&5
conftest.c: In function `main':
conftest.c:78: error: storage size of 'dp' isn't known
conftest.c:78: warning: unused variable `dp'
...
configure:8773: checking whether closedir returns void
configure:8802: gcc -o conftest.exe -g2 -Wall   conftest.c  >&5
conftest.c:104:12: empty filename in #include
conftest.c: In function `main':
conftest.c:112: warning: implicit declaration of function `opendir'
...
configure:10761: checking for dirent.h that defines DIR
configure:10785: gcc -c -g2 -Wall  conftest.c >&5
configure:10791: $? = 0

I'm not sure if there is an underlying autoconf bug that also
needs to be fixed, but this patch solves the problem for
findutils by making sure that AC_HEADER_DIRENT is always
AC_REQUIRE'd, so that the dependency chain does not get
corrupted by mixing and matching AC_REQUIRE with straight
expansion.

Patched as follows:
m4/ChangeLog:
2006-03-14  Eric Blake  <address@hidden>

        * dirfd.m4 (gl_FUNC_DIRFD): Use AC_REQUIRE for AC_HEADER_DIRENT.
        * getcwd.m4 (gl_FUNC_GETCWD): Require gl_PREREQ_GETCWD outside
        of shell conditionals.

Index: m4/dirfd.m4
===================================================================
RCS file: /sources/gnulib/gnulib/m4/dirfd.m4,v
retrieving revision 1.18
diff -u -r1.18 dirfd.m4
--- m4/dirfd.m4 21 Mar 2005 22:06:27 -0000      1.18
+++ m4/dirfd.m4 14 Mar 2006 17:05:27 -0000
@@ -1,8 +1,8 @@
-#serial 10
+#serial 11  -*- autoconf -*-
 
 dnl Find out how to get the file descriptor associated with an open DIR*.
 
-# Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, 
Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -16,8 +16,8 @@
   dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
   AC_REQUIRE([AC_PROG_CPP])
   AC_REQUIRE([AC_PROG_EGREP])
+  AC_REQUIRE([AC_HEADER_DIRENT])
 
-  AC_HEADER_DIRENT
   dirfd_headers='
 #if HAVE_DIRENT_H
 # include <dirent.h>
@@ -55,7 +55,7 @@
              [how to get the file descriptor associated with an open DIR*],
                   gl_cv_sys_dir_fd_member_name,
       [
-        dirfd_save_CFLAGS=$CFLAGS
+       dirfd_save_CFLAGS=$CFLAGS
        for ac_expr in d_fd dd_fd; do
 
          CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
Index: m4/getcwd.m4
===================================================================
RCS file: /sources/gnulib/gnulib/m4/getcwd.m4,v
retrieving revision 1.9
diff -u -r1.9 getcwd.m4
--- m4/getcwd.m4        23 Sep 2005 04:15:13 -0000      1.9
+++ m4/getcwd.m4        14 Mar 2006 17:05:27 -0000
@@ -1,6 +1,7 @@
-# getcwd.m4 - check for working getcwd that is compatible with glibc
+# getcwd.m4 serial 2   -*- autoconf -*-
+# check for working getcwd that is compatible with glibc
 
-# Copyright (C) 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -14,7 +15,7 @@
    AC_CACHE_CHECK([whether getcwd (NULL, 0) allocates memory for result],
      [gl_cv_func_getcwd_null],
      [AC_TRY_RUN(
-        [
+       [
 #       include <stdlib.h>
 #       include <unistd.h>
 #       ifndef getcwd
@@ -39,6 +40,7 @@
 AC_DEFUN([gl_FUNC_GETCWD],
 [
   AC_REQUIRE([gl_FUNC_GETCWD_NULL])
+  AC_REQUIRE([gl_PREREQ_GETCWD])
 
   case $gl_cv_func_getcwd_null in
   yes) gl_FUNC_GETCWD_PATH_MAX;;
@@ -50,7 +52,7 @@
     AC_LIBOBJ([getcwd])
     AC_DEFINE([__GETCWD_PREFIX], [[rpl_]],
       [Define to rpl_ if the getcwd replacement function should be used.])
-    gl_PREREQ_GETCWD;;
+    ;;
   esac
 ])
 
-- 
Eric Blake






reply via email to

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