This makes the generated sys/stat.h more self-contained (no need to include <config.h> first, except for typedefs).
2007-05-01 Bruno Haible <[EMAIL PROTECTED]> * 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. *** lib/sys_stat_.h 27 Apr 2007 18:17:05 -0000 1.1 --- lib/sys_stat_.h 1 May 2007 18:09:15 -0000 *************** *** 253,266 **** /* mingw does not support symlinks, therefore it does not have lstat. But without links, stat does just fine. */ ! #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 # include <io.h> static inline int --- 253,266 ---- /* mingw does not support symlinks, therefore it does not have lstat. But without links, stat does just fine. */ ! #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@ # include <io.h> static inline int *** m4/sys_stat_h.m4 27 Oct 2006 20:46:43 -0000 1.6 --- m4/sys_stat_h.m4 1 May 2007 18:09:15 -0000 *************** *** 1,5 **** ! # sys_stat_h.m4 serial 4 -*- Autoconf -*- ! dnl Copyright (C) 2006 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. --- 1,5 ---- ! # 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,17 **** --- 12,23 ---- 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,24 **** --- 25,42 ---- [], [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. *** modules/sys_stat 27 Apr 2007 18:18:49 -0000 1.13 --- modules/sys_stat 1 May 2007 18:09:15 -0000 *************** *** 22,27 **** --- 22,30 ---- rm -f [EMAIL PROTECTED] $@ { 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; \ } > [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@