autoconf
[Top][All Lists]
Advanced

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

Re: autoconf 2.5, 2.13, and Vim


From: Akim Demaille
Subject: Re: autoconf 2.5, 2.13, and Vim
Date: 12 Jun 2001 15:37:47 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Copyleft)

>>>>> "Paul" == Paul Eggert <address@hidden> writes:

>> So, are you actually saying that *any* #include <foo.h> should be
>> checked?

Paul> No, just if there's a good reason for it.  For example,
Paul> AC_HEADER_STAT need not bother to wrap the '#include
Paul> <sys/types.h>' inside '#if HAVE_SYS_TYPES_H', since POSIX
Paul> specifies 'stat' and only POSIX and POSIX-like systems have
Paul> 'stat'.  It's theoretically possible for a system to have 'stat'
Paul> but not <sys/types.h>, but I think it's not worth bothering
Paul> about unless that turns into a problem.

Well, too late, here is a proto monster patch.  Of course, I'd like to
convert all the internal tests to use the default includes.  One
positive point is that at least we are using consistent conditions to
test the features, and secondly, the ac_require machinery will handle
the AC_CHECK_HEADERS by itself, simplifying configure.

Paul> Yes, in _AC_INCLUDES_DEFAULT_REQUIREMENTS and in
Paul> AC_PROG_CC_STDC.  But the other occurrences of sys/stat.h assume
Paul> POSIX, and thus need not be wrapped.

Well, again, too late, I went till the end of it :(

Index: NEWS
===================================================================
RCS file: /cvs/autoconf/NEWS,v
retrieving revision 1.150
diff -u -u -r1.150 NEWS
--- NEWS 2001/06/06 15:03:29 1.150
+++ NEWS 2001/06/12 13:20:50
@@ -1,6 +1,7 @@
 * Major changes in Autoconf 2.50a                       -*- outline -*-
 ** Default includes
-Now include stdint.h.
+- Now include stdint.h.
+- sys/types.h and sys/stat.h are guarded.
 
 ** Bug fixes
 - Mostly in the test suite.
@@ -8,6 +9,12 @@
 - configure accepts --prefix='' again.
 - AC_CHECK_LIB works properly when its first argument is not a
   literal.
+- HAVE_INTTYPES_H is defined only if not conflicting with previous
+  headers.
+
+** Generic macros
+- AC_CHECK_HEADER and AC_CHECK_HEADERS support a fourth argument to
+  specify pre-includes.
 
 * Major changes in Autoconf 2.50
 
Index: acfunctions.m4
===================================================================
RCS file: /cvs/autoconf/acfunctions.m4,v
retrieving revision 1.34
diff -u -u -r1.34 acfunctions.m4
--- acfunctions.m4 2001/06/04 16:07:23 1.34
+++ acfunctions.m4 2001/06/12 13:20:51
@@ -257,8 +257,12 @@
 [AC_REQUIRE([AC_TYPE_UID_T])dnl
 AC_CHECK_HEADERS(unistd.h)
 AC_CACHE_CHECK([for working chown], ac_cv_func_chown_works,
-[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
-#include <sys/stat.h>
+[AC_RUN_IFELSE([AC_LANG_SOURCE([[#if SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #include <fcntl.h>
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
@@ -302,7 +306,9 @@
 AC_CACHE_CHECK([whether closedir returns void],
                [ac_cv_func_closedir_void],
 [AC_RUN_IFELSE([AC_LANG_SOURCE(
-[#include <sys/types.h>
+[#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <$ac_header_dirent>
 
 int closedir ();
@@ -599,7 +605,8 @@
 # AC_FUNC_GETPGRP
 # ---------------
 AC_DEFUN([AC_FUNC_GETPGRP],
-[AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void,
+[AC_CHECK_HEADERS(sys/types.h)
+AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void,
 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
 /*
  * If this system has a BSD-style getpgrp(),
@@ -608,7 +615,9 @@
  * Snarfed from Chet Ramey's bash pgrp.c test program
  */
 #include <stdio.h>
-#include <sys/types.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 
 int     pid;
 int     pg1, pg2, pg3, pg4;
@@ -936,7 +945,7 @@
 # AC_FUNC_MMAP
 # ------------
 AC_DEFUN([AC_FUNC_MMAP],
-[AC_CHECK_HEADERS(stdlib.h unistd.h)
+[AC_CHECK_HEADERS(sys/types.h sys/stat.h stdlib.h unistd.h)
 AC_CHECK_FUNCS(getpagesize)
 AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
 [AC_RUN_IFELSE([AC_LANG_SOURCE(
@@ -961,7 +970,10 @@
    The main things grep needs to know about mmap are:
    * does it exist and is it safe to write into the mmap'd area
    * how to use it (BSD variants)  */
-#include <sys/types.h>
+
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <fcntl.h>
 #include <sys/mman.h>
 
@@ -972,8 +984,10 @@
 #endif
 #if HAVE_UNISTD_H
 # include <unistd.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
 #endif
-#include <sys/stat.h>
 
 /* This mess was copied from the GNU getpagesize.h.  */
 #if !HAVE_GETPAGESIZE
@@ -1115,13 +1129,17 @@
 # function's arguments, and define those types in `SELECT_TYPE_ARG1',
 # `SELECT_TYPE_ARG234', and `SELECT_TYPE_ARG5'.
 AC_DEFUN([AC_FUNC_SELECT_ARGTYPES],
-[AC_CACHE_CHECK([types of arguments for select],
+[AC_REQUIRE([AC_HEADER_TIME])dnl
+AC_CHECK_HEADERS(sys/types.h sys/select.h sys/socket.h)
+AC_CACHE_CHECK([types of arguments for select],
 [ac_cv_func_select_args],
 [for ac_arg234 in 'fd_set *' 'int *' 'void *'; do
  for ac_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do
   for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[#include <sys/types.h>
+[#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #if HAVE_SYS_TIME_H
 # include <sys/time.h>
 #endif
@@ -1186,12 +1204,17 @@
 # HAVE_LSTAT_EMPTY_STRING_BUG) and arrange to compile the wrapper
 # function.
 m4_define([_AC_FUNC_STAT],
-[AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])dnl
+[AC_CHECK_HEADERS(sys/types.h sys/stat.h)
+AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])dnl
 AC_CACHE_CHECK([whether $1 accepts an empty string],
                [ac_cv_func_$1_empty_string_bug],
 [AC_TRY_RUN(
-[#include <sys/types.h>
-#include <sys/stat.h>
+[#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 
 int
 main ()
@@ -1410,12 +1433,18 @@
 # AC_FUNC_UTIME_NULL
 # ------------------
 AC_DEFUN([AC_FUNC_UTIME_NULL],
-[AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
+[AC_CHECK_HEADERS(sys/types.h sys/stat.h)
+AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
 [rm -f conftest.data; >conftest.data
 # Sequent interprets utime(file, 0) to mean use start of epoch.  Wrong.
 AC_TRY_RUN(
-[#include <sys/types.h>
-#include <sys/stat.h>
+[#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+
 int
 main ()
 {
@@ -1446,12 +1475,16 @@
 # -------------
 AC_DEFUN([AC_FUNC_VFORK],
 [AC_REQUIRE([AC_TYPE_PID_T])dnl
-AC_CHECK_HEADERS(unistd.h vfork.h)
+AC_CHECK_HEADERS(sys/types.h sys/stat.h unistd.h vfork.h)
 AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
 [AC_TRY_RUN([/* Thanks to Paul Eggert for this test.  */
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #if HAVE_UNISTD_H
 # include <unistd.h>
 #endif
@@ -1577,12 +1610,16 @@
 # AC_FUNC_WAIT3
 # -------------
 AC_DEFUN([AC_FUNC_WAIT3],
-[AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rusage,
+[AC_CHECK_HEADERS(sys/types.h)
+AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rusage,
 [AC_TRY_RUN(
-[#include <sys/types.h>
+[#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <sys/time.h>
 #include <sys/resource.h>
-#include <stdio.h>
+
 /* HP-UX has wait3 but does not fill in rusage at all.  */
 int
 main ()
Index: acgeneral.m4
===================================================================
RCS file: /cvs/autoconf/acgeneral.m4,v
retrieving revision 1.730
diff -u -u -r1.730 acgeneral.m4
--- acgeneral.m4 2001/06/06 15:03:29 1.730
+++ acgeneral.m4 2001/06/12 13:21:01
@@ -2180,8 +2180,12 @@
 dnl If ever you change this variable, please keep autoconf.texi in sync.
 ac_includes_default="\
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #if STDC_HEADERS
 # include <stdlib.h>
 # include <stddef.h>
@@ -2212,7 +2216,7 @@
 #endif"
 ])dnl
 AC_REQUIRE([AC_HEADER_STDC])dnl
-AC_CHECK_HEADERS(stdlib.h string.h memory.h strings.h inttypes.h stdint.h 
unistd.h)
+AC_CHECK_HEADERS(sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h 
inttypes.h stdint.h unistd.h, [], [], $ac_includes_default)
 ])
 
 
Index: acheaders.m4
===================================================================
RCS file: /cvs/autoconf/acheaders.m4,v
retrieving revision 1.7
diff -u -u -r1.7 acheaders.m4
--- acheaders.m4 2001/06/04 16:07:23 1.7
+++ acheaders.m4 2001/06/12 13:21:02
@@ -60,12 +60,15 @@
 ## 1. Generic tests for headers.  ##
 ## ------------------------------ ##
 
-# AC_CHECK_HEADER(HEADER-FILE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-# ----------------------------------------------------------------------
+# AC_CHECK_HEADER(HEADER-FILE,
+#                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+#                 [INCLUDES])
+# ---------------------------------------------------------
 AC_DEFUN([AC_CHECK_HEADER],
 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
 AC_CACHE_CHECK([for $1], ac_Header,
-               [AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include 
<$1>])],
+               [AC_PREPROC_IFELSE([AC_LANG_SOURCE([m4_n([$4])dnl
address@hidden:@include <$1>])],
                                   [AS_VAR_SET(ac_Header, yes)],
                                   [AS_VAR_SET(ac_Header, no)])])
 AS_IF([test AS_VAR_GET(ac_Header) = yes], [$2], [$3])[]dnl
@@ -83,6 +86,7 @@
 
 # AC_CHECK_HEADERS(HEADER-FILE...
 #                  [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#                 [INCLUDES])
 # ----------------------------------------------------------
 AC_DEFUN([AC_CHECK_HEADERS],
 [AH_CHECK_HEADERS([$1])dnl
@@ -90,7 +94,8 @@
 do
 AC_CHECK_HEADER($ac_header,
                 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$ac_header)) $2],
-                [$3])dnl
+                [$3],
+                [$4])dnl
 done
 ])
 
@@ -111,7 +116,9 @@
 m4_define([_AC_CHECK_HEADER_DIRENT],
 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_dirent_$1])dnl
 AC_CACHE_CHECK([for $1 that defines DIR], ac_Header,
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <$1>
 ],
                                     [DIR *dirp = 0;])],
@@ -135,6 +142,7 @@
 # ----------------
 AC_DEFUN([AC_HEADER_DIRENT],
 [AH_CHECK_HEADERS_DIRENT(dirent.h sys/ndir.h sys/dir.h ndir.h)
+AC_CHECK_HEADERS(sys/types.h)
 ac_header_dirent=no
 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
   _AC_CHECK_HEADER_DIRENT($ac_hdr,
@@ -154,7 +162,7 @@
 # ---------------
 AC_DEFUN([AC_HEADER_MAJOR],
 [AC_CACHE_CHECK(whether sys/types.h defines makedev,
-  ac_cv_header_sys_types_h_makedev,
+                ac_cv_header_sys_types_h_makedev,
 [AC_TRY_LINK([#include <sys/types.h>
 ], [return makedev(0, 0);],
   ac_cv_header_sys_types_h_makedev=yes, ac_cv_header_sys_types_h_makedev=no)
@@ -180,9 +188,12 @@
 # --------------
 # FIXME: Shouldn't this be named AC_HEADER_SYS_STAT?
 AC_DEFUN([AC_HEADER_STAT],
-[AC_CACHE_CHECK(whether stat file-mode macros are broken,
+[AC_CHECK_HEADERS(sys/types.h)
+AC_CACHE_CHECK(whether stat file-mode macros are broken,
   ac_cv_header_stat_broken,
-[AC_EGREP_CPP([You lose], [#include <sys/types.h>
+[AC_EGREP_CPP([You lose], [#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <sys/stat.h>
 
 #if defined(S_ISBLK) && defined(S_IFDIR)
@@ -272,10 +283,13 @@
 # AC_HEADER_SYS_WAIT
 # ------------------
 AC_DEFUN([AC_HEADER_SYS_WAIT],
-[AC_CACHE_CHECK([for sys/wait.h that is POSIX.1 compatible],
-  ac_cv_header_sys_wait_h,
+[AC_CHECK_HEADERS(sys/types.h)
+AC_CACHE_CHECK([for sys/wait.h that is POSIX.1 compatible],
+                ac_cv_header_sys_wait_h,
 [AC_COMPILE_IFELSE(
-[AC_LANG_PROGRAM([#include <sys/types.h>
+[AC_LANG_PROGRAM([#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <sys/wait.h>
 #ifndef WEXITSTATUS
 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
@@ -299,9 +313,12 @@
 # AC_HEADER_TIME
 # --------------
 AC_DEFUN([AC_HEADER_TIME],
-[AC_CACHE_CHECK([whether time.h and sys/time.h may both be included],
-  ac_cv_header_time,
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
+[AC_CHECK_HEADERS(sys/types.h)
+AC_CACHE_CHECK([whether time.h and sys/time.h may both be included],
+               ac_cv_header_time,
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <sys/time.h>
 #include <time.h>
 ],
@@ -318,10 +335,13 @@
 # _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
 # ----------------------------------
 m4_define([_AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H],
-[AC_CACHE_CHECK([whether termios.h defines TIOCGWINSZ],
+[AC_CHECK_HEADERS(sys/types.h)
+AC_CACHE_CHECK([whether termios.h defines TIOCGWINSZ],
                 ac_cv_sys_tiocgwinsz_in_termios_h,
 [AC_EGREP_CPP([yes],
-              [#include <sys/types.h>
+              [#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <termios.h>
 #ifdef TIOCGWINSZ
   yes
@@ -335,10 +355,13 @@
 # _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
 # ----------------------------------
 m4_define([_AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL],
-[AC_CACHE_CHECK([whether sys/ioctl.h defines TIOCGWINSZ],
+[AC_CHECK_HEADERS(sys/types.h)
+AC_CACHE_CHECK([whether sys/ioctl.h defines TIOCGWINSZ],
                 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h,
 [AC_EGREP_CPP([yes],
-              [#include <sys/types.h>
+              [#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <sys/ioctl.h>
 #ifdef TIOCGWINSZ
   yes
Index: aclang.m4
===================================================================
RCS file: /cvs/autoconf/aclang.m4,v
retrieving revision 1.133
diff -u -u -r1.133 aclang.m4
--- aclang.m4 2001/06/11 21:44:22 1.133
+++ aclang.m4 2001/06/12 13:21:05
@@ -1376,6 +1376,7 @@
 [AC_REQUIRE([AC_PROG_CC])dnl
 AC_BEFORE([$0], [AC_C_INLINE])dnl
 AC_BEFORE([$0], [AC_C_CONST])dnl
+AC_CHECK_HEADERS(sys/types.h sys/stat.h)
 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
 dnl a magic option to avoid problems with ANSI preprocessor commands
 dnl like #elif.
@@ -1389,9 +1390,15 @@
 AC_LANG_CONFTEST([AC_LANG_PROGRAM(
 [[#include <stdarg.h>
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
 static char *e (p, i)
@@ -1496,10 +1503,13 @@
 # AC_C_BIGENDIAN
 # --------------
 AC_DEFUN([AC_C_BIGENDIAN],
-[AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
+[AC_CHECK_HEADERS(sys/types.h)
+AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
 [ac_cv_c_bigendian=unknown
 # See if sys/param.h defines the BYTE_ORDER macro.
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <sys/param.h>
 ],
 [#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
@@ -1507,7 +1517,9 @@
 #endif
 ])],
 [# It does; now see whether it defined to BIG_ENDIAN or not.
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <sys/param.h>
 ], [#if BYTE_ORDER != BIG_ENDIAN
  not big endian
Index: acspecific.m4
===================================================================
RCS file: /cvs/autoconf/acspecific.m4,v
retrieving revision 1.338
diff -u -u -r1.338 acspecific.m4
--- acspecific.m4 2001/04/15 16:20:30 1.338
+++ acspecific.m4 2001/06/12 13:21:09
@@ -294,10 +294,13 @@
 # AC_DECL_SYS_SIGLIST
 # -------------------
 AC_DEFUN([AC_DECL_SYS_SIGLIST],
-[AC_CACHE_CHECK([for sys_siglist declaration in signal.h or unistd.h],
-  ac_cv_decl_sys_siglist,
+[AC_CHECK_HEADERS(sys/types.h unistd.h)
+AC_CACHE_CHECK([for sys_siglist declaration in signal.h or unistd.h],
+               ac_cv_decl_sys_siglist,
 [AC_COMPILE_IFELSE(
-[AC_LANG_PROGRAM([#include <sys/types.h>
+[AC_LANG_PROGRAM([#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <signal.h>
 /* NetBSD declares sys_siglist in unistd.h.  */
 #if HAVE_UNISTD_H
@@ -495,14 +498,16 @@
 # interrupted by a signal, define `HAVE_RESTARTABLE_SYSCALLS'.
 AC_DEFUN([AC_SYS_RESTARTABLE_SYSCALLS],
 [AC_REQUIRE([AC_HEADER_SYS_WAIT])dnl
-AC_CHECK_HEADERS(unistd.h)
+AC_CHECK_HEADERS(sys/types.h unistd.h)
 AC_CACHE_CHECK(for restartable system calls, ac_cv_sys_restartable_syscalls,
 [AC_RUN_IFELSE([AC_LANG_SOURCE(
 [/* Exit 0 (true) if wait returns something other than -1,
    i.e. the pid of the child, which means that wait was restarted
    after getting the signal.  */
 
-#include <sys/types.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <signal.h>
 #if HAVE_UNISTD_H
 # include <unistd.h>
@@ -553,9 +558,14 @@
 # AC_SYS_POSIX_TERMIOS
 # --------------------
 AC_DEFUN([AC_SYS_POSIX_TERMIOS],
-[AC_CACHE_CHECK([POSIX termios], ac_cv_sys_posix_termios,
-[AC_TRY_LINK([#include <sys/types.h>
-#include <unistd.h>
+[AC_CHECK_HEADERS(sys/types.h unistd.h)
+AC_CACHE_CHECK([POSIX termios], ac_cv_sys_posix_termios,
+[AC_TRY_LINK([#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
 @%:@include <termios.h>],
              [/* SunOS 4.0.3 has termios.h but not the library calls.  */
    tcgetattr(0, 0);],
Index: actypes.m4
===================================================================
RCS file: /cvs/autoconf/actypes.m4,v
retrieving revision 1.4
diff -u -u -r1.4 actypes.m4
--- actypes.m4 2001/06/04 16:07:23 1.4
+++ actypes.m4 2001/06/12 13:21:11
@@ -244,10 +244,13 @@
 # -----------------
 AC_DEFUN([AC_TYPE_GETGROUPS],
 [AC_REQUIRE([AC_TYPE_UID_T])dnl
+AC_CHECK_HEADERS(sys/types.h)
 AC_CACHE_CHECK(type of array argument to getgroups, ac_cv_type_getgroups,
 [AC_RUN_IFELSE([AC_LANG_SOURCE(
 [[/* Thanks to Mike Rendell for this test.  */
-#include <sys/types.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #define NGID 256
 #undef MAX
 #define MAX(x, y) ((x) > (y) ? (x) : (y))
@@ -313,9 +316,12 @@
 # --------------
 # Note that identifiers starting with SIG are reserved by ANSI C.
 AC_DEFUN([AC_TYPE_SIGNAL],
-[AC_CACHE_CHECK([return type of signal handlers], ac_cv_type_signal,
+[AC_CHECK_HEADERS(sys/types.h)
+AC_CACHE_CHECK([return type of signal handlers], ac_cv_type_signal,
 [AC_COMPILE_IFELSE(
-[AC_LANG_PROGRAM([#include <sys/types.h>
+[AC_LANG_PROGRAM([#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <signal.h>
 #ifdef signal
 # undef signal
@@ -516,9 +522,12 @@
 # FIXME: This macro is badly named, it should be AC_CHECK_TYPE_STRUCT_TM.
 # Or something else, but what? AC_CHECK_TYPE_STRUCT_TM_IN_SYS_TIME?
 AC_DEFUN([AC_STRUCT_TM],
-[AC_CACHE_CHECK([whether struct tm is in sys/time.h or time.h],
-  ac_cv_struct_tm,
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
+[AC_CHECK_HEADERS(sys/types.h)
+AC_CACHE_CHECK([whether struct tm is in sys/time.h or time.h],
+               ac_cv_struct_tm,
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <time.h>
 ],
                                     [struct tm *tp; tp->tm_sec;])],
@@ -538,7 +547,9 @@
 # external array `tzname' is found, define `HAVE_TZNAME'.
 AC_DEFUN([AC_STRUCT_TIMEZONE],
 [AC_REQUIRE([AC_STRUCT_TM])dnl
-AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
+AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #include <$ac_cv_struct_tm>
 ])
 if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
Index: doc/autoconf.texi
===================================================================
RCS file: /cvs/autoconf/doc/autoconf.texi,v
retrieving revision 1.461
diff -u -u -r1.461 autoconf.texi
--- doc/autoconf.texi 2001/06/11 20:19:07 1.461
+++ doc/autoconf.texi 2001/06/12 13:21:48
@@ -2778,8 +2778,12 @@
 @example
 @group
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #if STDC_HEADERS
 # include <stdlib.h>
 # include <stddef.h>
@@ -3860,15 +3864,20 @@
 as well as find out whether it is present, you have to write your own
 test for it (@pxref{Writing Tests}).
 
address@hidden AC_CHECK_HEADER (@var{header-file}, @ovar{action-if-found}, 
@ovar{action-if-not-found})
address@hidden AC_CHECK_HEADER (@var{header-file}, @ovar{action-if-found}, 
@ovar{action-if-not-found}, @ovar{includes})
 @maindex CHECK_HEADER
 If the system header file @var{header-file} exists, execute shell commands
 @var{action-if-found}, otherwise execute @var{action-if-not-found}.  If
 you just want to define a symbol if the header file is available,
 consider using @code{AC_CHECK_HEADERS} instead.
+
+This macro actually checks whether @var{header-file} can be included
+without error.  If @var{includes} is specified, they are included before
address@hidden  Note that the @var{includes} are @emph{not}
+defaulted.  They might be in future releases.
 @end defmac
 
address@hidden AC_CHECK_HEADERS (@address@hidden, @ovar{action-if-found}, 
@ovar{action-if-not-found})
address@hidden AC_CHECK_HEADERS (@address@hidden, @ovar{action-if-found}, 
@ovar{action-if-not-found}, @ovar{includes})
 @maindex CHECK_HEADERS
 @cvindex address@hidden
 For each given system header file @var{header-file} in the
@@ -3878,6 +3887,11 @@
 files is found.  You can give it a value of @samp{break} to break out of
 the loop on the first match.  If @var{action-if-not-found} is given, it
 is executed when one of the header files is not found.
+
+This macro actually checks whether @var{header-file} can be included
+without error.  If @var{includes} is specified, they are included before
address@hidden  Note that the @var{includes} are @emph{not}
+defaulted.  They might be in future releases.
 @end defmac
 
 @node Declarations, Structures, Header Files, Existing Tests



reply via email to

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