Simplify macrology that creates unistd.h.
authorBruno Haible <bruno@clisp.org>
Sun, 28 Jan 2007 16:10:39 +0000 (16:10 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 28 Jan 2007 16:10:39 +0000 (16:10 +0000)
ChangeLog
m4/fchdir.m4
m4/unistd_h.m4
modules/fchdir

index 41d153ccad99571da6c39d8a73e51cf4cbfca824..886120a6c7163a1cfad9081b317bb50972a7fdd2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-01-28  Bruno Haible  <bruno@clisp.org>
+
+       * m4/unistd_h.m4 (gl_HEADER_UNISTD_DEFAULTS): New macro.
+       (gl_HEADER_UNISTD): Require it. Don't set UNISTD_H to empty here.
+       * m4/fchdir.m4 (gl_FUNC_FCHDIR): Require gl_HEADER_UNISTD_DEFAULTS.
+       Set UNISTD_H instead of UNISTD_H2.
+       * modules/fchdir (BUILT_SOURCES): Drop $(UNISTD_H2).
+
 2007-01-28  Bruno Haible  <bruno@clisp.org>
 
        * modules/mbchar (Makefile.am): Add mbchar.c to lib_SOURCES.
 2007-01-28  Bruno Haible  <bruno@clisp.org>
 
        * modules/mbchar (Makefile.am): Add mbchar.c to lib_SOURCES.
index caebfcbe0610cafd5ea15f1dfd7aca5028ed4c38..6998eae435a7e1fa8525252a2a564b478b5f255b 100644 (file)
@@ -1,11 +1,12 @@
-# fchdir.m4 serial 1
-dnl Copyright (C) 2006 Free Software Foundation, Inc.
+# fchdir.m4 serial 2
+dnl Copyright (C) 2006-2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_FUNC_FCHDIR],
 [
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_FUNC_FCHDIR],
 [
+  AC_REQUIRE([gl_HEADER_UNISTD_DEFAULTS])
   AC_CHECK_FUNCS_ONCE([fchdir])
   if test $ac_cv_func_fchdir = no; then
     AC_LIBOBJ([fchdir])
   AC_CHECK_FUNCS_ONCE([fchdir])
   if test $ac_cv_func_fchdir = no; then
     AC_LIBOBJ([fchdir])
@@ -15,14 +16,12 @@ AC_DEFUN([gl_FUNC_FCHDIR],
     gl_ABSOLUTE_HEADER([dirent.h])
     ABSOLUTE_DIRENT_H=\"$gl_cv_absolute_dirent_h\"
     DIRENT_H='dirent.h'
     gl_ABSOLUTE_HEADER([dirent.h])
     ABSOLUTE_DIRENT_H=\"$gl_cv_absolute_dirent_h\"
     DIRENT_H='dirent.h'
-    UNISTD_H2='unistd.h'
+    UNISTD_H='unistd.h'
   else
     DIRENT_H=
   else
     DIRENT_H=
-    UNISTD_H2=
   fi
   AC_SUBST([ABSOLUTE_DIRENT_H])
   AC_SUBST([DIRENT_H])
   fi
   AC_SUBST([ABSOLUTE_DIRENT_H])
   AC_SUBST([DIRENT_H])
-  AC_SUBST([UNISTD_H2])
 ])
 
 # Prerequisites of lib/fchdir.c.
 ])
 
 # Prerequisites of lib/fchdir.c.
index 9d499dfe842651a84200650db497d382eb9ff366..d38de90fe8536348e5c158d96366f35dec7d6fb0 100644 (file)
@@ -1,5 +1,5 @@
-# unistd_h.m4 serial 3
-dnl Copyright (C) 2006 Free Software Foundation, Inc.
+# unistd_h.m4 serial 4
+dnl Copyright (C) 2006-2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -8,12 +8,13 @@ dnl Written by Simon Josefsson
 
 AC_DEFUN([gl_HEADER_UNISTD],
 [
 
 AC_DEFUN([gl_HEADER_UNISTD],
 [
-  AC_CHECK_HEADERS([unistd.h], [
-    UNISTD_H=''
-  ], [
+  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
+  dnl once only, before all statements that occur in other macros.
+  AC_REQUIRE([gl_HEADER_UNISTD_DEFAULTS])
+
+  AC_CHECK_HEADERS([unistd.h], [], [
     UNISTD_H='unistd.h'
   ])
     UNISTD_H='unistd.h'
   ])
-  AC_SUBST(UNISTD_H)
   dnl This module decides to build unistd.h if it is missing.
   dnl The fchdir module decides to build unistd.h if fchdir() is missing.
   dnl Therefore check for the prerequisites of lib/unistd.h always.
   dnl This module decides to build unistd.h if it is missing.
   dnl The fchdir module decides to build unistd.h if fchdir() is missing.
   dnl Therefore check for the prerequisites of lib/unistd.h always.
@@ -30,3 +31,9 @@ AC_DEFUN([gl_PREREQ_UNISTD],
   fi
   AC_SUBST([ABSOLUTE_UNISTD_H])
 ])
   fi
   AC_SUBST([ABSOLUTE_UNISTD_H])
 ])
+
+AC_DEFUN([gl_HEADER_UNISTD_DEFAULTS],
+[
+  UNISTD_H=
+  AC_SUBST(UNISTD_H)
+])
index f3d177fae9b89d71c5998ad628c262e636915fb4..8d9fca812811b558544a7fd05af8006eb11cb53d 100644 (file)
@@ -18,7 +18,7 @@ configure.ac:
 gl_FUNC_FCHDIR
 
 Makefile.am:
 gl_FUNC_FCHDIR
 
 Makefile.am:
-BUILT_SOURCES += $(DIRENT_H) $(UNISTD_H2)
+BUILT_SOURCES += $(DIRENT_H)
 
 # We need the following in order to create <dirent.h> when the system
 # doesn't have one that works with the given compiler.
 
 # We need the following in order to create <dirent.h> when the system
 # doesn't have one that works with the given compiler.