changeset 8780:d9e13374d316

Make the generated sys/stat.h more self-contained.
author Bruno Haible <bruno@clisp.org>
date Tue, 01 May 2007 18:14:44 +0000
parents cd42657bc151
children ef37a3689142
files ChangeLog lib/sys_stat_.h m4/sys_stat_h.m4 modules/sys_stat
diffstat 4 files changed, 35 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-05-01  Bruno Haible  <bruno@clisp.org>
+
+	* lib/sys_stat_.h: Test HAVE_LSTAT, HAVE_DECL_MKDIR, HAVE_IO_H at
+	configure time.
+	* m4/sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): Substitute HAVE_LSTAT,
+	HAVE_DECL_MKDIR, HAVE_IO_H via AC_SUBST.
+	* modules/sys_stat (Makefile.am): Substitute their values into
+	sys/stat.h.
+
 2007-05-01  Bruno Haible  <bruno@clisp.org>
 
 	* lib/glob_.h: Test HAVE_SYS_CDEFS_H at configure time.
@@ -30162,4 +30171,4 @@
 
 	* m4/isc-posix.m4: New file.
 
-1998-05-10  Jim Meyering  <meyering@ascend.com>
+1998-05-10  Jim Meyering  <meyering@ascend.com>
\ No newline at end of file
--- a/lib/sys_stat_.h
+++ b/lib/sys_stat_.h
@@ -253,14 +253,14 @@
 
 /* mingw does not support symlinks, therefore it does not have lstat.  But
    without links, stat does just fine.  */
-#if ! HAVE_LSTAT
+#if ! @HAVE_LSTAT@
 # define lstat stat
 #endif
 
 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
    Additionally, it declares _mkdir (and depending on compile flags, an
    alias mkdir), only in the nonstandard io.h.  */
-#if ! HAVE_DECL_MKDIR && HAVE_IO_H
+#if ! @HAVE_DECL_MKDIR@ && @HAVE_IO_H@
 # include <io.h>
 
 static inline int
--- a/m4/sys_stat_h.m4
+++ b/m4/sys_stat_h.m4
@@ -1,5 +1,5 @@
-# sys_stat_h.m4 serial 4   -*- Autoconf -*-
-dnl Copyright (C) 2006 Free Software Foundation, Inc.
+# sys_stat_h.m4 serial 5   -*- Autoconf -*-
+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.
@@ -12,6 +12,12 @@
   dnl Check for lstat.  Systems that lack it (mingw) also lack symlinks, so
   dnl stat is a good replacement.
   AC_CHECK_FUNCS_ONCE([lstat])
+  if test $ac_cv_func_lstat = yes; then
+    HAVE_LSTAT=1
+  else
+    HAVE_LSTAT=0
+  fi
+  AC_SUBST([HAVE_LSTAT])
 
   dnl Check for mkdir.  Mingw has _mkdir(name) in the nonstandard <io.h>
   dnl instead.
@@ -19,6 +25,18 @@
     [],
     [AC_CHECK_HEADERS([io.h])],
     [#include <sys/stat.h>])
+  if test $ac_cv_have_decl_mkdir = yes; then
+    HAVE_DECL_MKDIR=1
+  else
+    HAVE_DECL_MKDIR=0
+  fi
+  AC_SUBST([HAVE_DECL_MKDIR])
+  if test "$ac_cv_header_io_h" = yes; then
+    HAVE_IO_H=1
+  else
+    HAVE_IO_H=0
+  fi
+  AC_SUBST([HAVE_IO_H])
   AC_REQUIRE([AC_C_INLINE])
 
   dnl Check for broken stat macros.
--- a/modules/sys_stat
+++ b/modules/sys_stat
@@ -22,6 +22,9 @@
 	rm -f $@-t $@
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's|@''ABSOLUTE_SYS_STAT_H''@|$(ABSOLUTE_SYS_STAT_H)|g' \
+	      -e 's|@''HAVE_IO_H''@|$(HAVE_IO_H)|g' \
+	      -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
+	      -e 's|@''HAVE_DECL_MKDIR''@|$(HAVE_DECL_MKDIR)|g' \
 	      < $(srcdir)/sys_stat_.h; \
 	} > $@-t
 	mv $@-t $@