autoconf-patches
[Top][All Lists]
Advanced

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

Checking automatically for default headers


From: Akim Demaille
Subject: Checking automatically for default headers
Date: 15 Jan 2001 18:05:10 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Crater Lake)

A suggestion from Jim: as soon as default includes are used, let's
look for the headers which correspond.  And, BTW, let's not include
the definition of the default headers when they are not used (see the
changes of Autoconf's own configure).

Not only does this improve the learning curve for beginners, but it
can also help you perform the checks in the right order...

Ooops.  I realize I have not written the ChangeLog yet.  I will.

Index: acgeneral.m4
===================================================================
RCS file: /cvs/autoconf/acgeneral.m4,v
retrieving revision 1.653
diff -u -u -r1.653 acgeneral.m4
--- acgeneral.m4 2001/01/15 07:29:24 1.653
+++ acgeneral.m4 2001/01/15 17:02:01
@@ -802,42 +802,6 @@
 ac_tr_sh="sed y%*+%pp%;s%[[^_$ac_cr_alnum]]%_%g"
 ac_tr_cpp="sed y%*$ac_cr_az%P$ac_cr_AZ%;s%[[^_$ac_cr_alnum]]%_%g"
 
-# By default always use an empty string as the executable extension.
-# Only change it if the script calls AC_EXEEXT.
-ac_exeext=
-# By default assume that objects files use an extension of .o.  Only
-# change it if the script calls AC_OBJEXT.
-ac_objext=o
-# Factoring default headers for most tests.
-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 STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# if HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
-#endif
-#if HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-#  include <memory.h>
-# endif
-# include <string.h>
-#else
-# if HAVE_STRINGS_H
-#  include <strings.h>
-# endif
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif"
 m4_divert_pop()dnl
 ])# _AC_INIT_DEFAULTS
 
@@ -2263,15 +2227,46 @@
 # Always use the same set of default headers for all the generic
 # macros.  It is easier to document, to extend, and to understand than
 # having specific defaults for each macro.
-
-# Of course, one would like to issue these default headers only if
-# they were used, i.e.., AC_INCLUDES_DEFAULT was called, and the
-# default `branch' was run.  Unfortunately AC_INCLUDES_DEFAULT is
-# called unquoted, so it is unsafe to try to divert from there.
-# Therefore, the following *is* buggy, but this is the kind of
-# tradeoff we accept in order to improve configure.
 
-# See _AC_INIT_PREPARE to see the value of `ac_includes_default'.
+# _AC_INCLUDES_DEFAULT_REQUIREMENTS
+# ---------------------------------
+# Required when AC_INCLUDES_DEFAULT uses its default branch.
+AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
+[m4_divert_text([DEFAULTS],
+[# Factoring default headers for most tests.
+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 STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#else
+# if HAVE_STRINGS_H
+#  include <strings.h>
+# endif
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+])dnl
+AC_REQUIRE([AC_HEADER_STDC])dnl
+AC_CHECK_HEADERS(stdlib.h string.h memory.h strings.h inttypes.h unistd.h)
+])
 
 
 # AC_INCLUDES_DEFAULT([INCLUDES])
@@ -2313,15 +2308,15 @@
 # Because I don't see any backward compatible means to fix the
 # brokenness of AC_TRY_COMPILE, we are doomed to leave a extra new
 # line here.
-m4_define([AC_INCLUDES_DEFAULT],
+AC_DEFUN([AC_INCLUDES_DEFAULT],
 [m4_ifval([$1], [$1
 ],
-          [$ac_includes_default])])
+          [AC_REQUIRE([_AC_INCLUDES_DEFAULT_REQUIREMENTS])dnl
+$ac_includes_default])])
 
 
 
 
-
 ## -------------------------- ##
 ## Generic structure checks.  ##
 ## -------------------------- ##
@@ -2338,7 +2333,6 @@
                [AC_FATAL([$0: requires literal arguments])])dnl
 m4_if(m4_regexp([$1], [\.]), -1,
       [AC_FATAL([$0: Did not see any dot in `$1'])])dnl
-AC_REQUIRE([AC_HEADER_STDC])dnl
 AC_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl
 dnl Extract the aggregate name, and the member name
 AC_CACHE_CHECK([for $1], ac_Member,
@@ -3231,8 +3225,7 @@
 # variable, we just use a cast to avoid warnings from the compiler.
 # Suggested by Paul Eggert.
 m4_define([_AC_CHECK_TYPE_NEW],
-[AC_REQUIRE([AC_HEADER_STDC])dnl
-AC_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
+[AC_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
 AC_CACHE_CHECK([for $1], ac_Type,
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
 [if (($1 *) 0)
Index: configure
===================================================================
RCS file: /cvs/autoconf/configure,v
retrieving revision 1.98
diff -u -u -r1.98 configure
--- configure 2001/01/12 09:39:26 1.98
+++ configure 2001/01/15 17:02:01
@@ -131,41 +131,6 @@
 ac_tr_sh="sed y%*+%pp%;s%[^_$ac_cr_alnum]%_%g"
 ac_tr_cpp="sed y%*$ac_cr_az%P$ac_cr_AZ%;s%[^_$ac_cr_alnum]%_%g"
 
-# By default always use an empty string as the executable extension.
-# Only change it if the script calls AC_EXEEXT.
-ac_exeext=
-# By default assume that objects files use an extension of .o.  Only
-# change it if the script calls AC_OBJEXT.
-ac_objext=o
-# Factoring default headers for most tests.
-ac_includes_default="\
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# if HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
-#endif
-#if HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-#  include <memory.h>
-# endif
-# include <string.h>
-#else
-# if HAVE_STRINGS_H
-#  include <strings.h>
-# endif
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif"
 ac_unique_file="acgeneral.m4"
 
 # Initialize some variables set by options.
Index: doc/autoconf.texi
===================================================================
RCS file: /cvs/autoconf/doc/autoconf.texi,v
retrieving revision 1.412
diff -u -u -r1.412 autoconf.texi
--- doc/autoconf.texi 2001/01/15 07:40:11 1.412
+++ doc/autoconf.texi 2001/01/15 17:02:06
@@ -2672,6 +2672,9 @@
 @end group
 @end example
 
+If the default includes are used, then Autoconf will automatically check
+for the presence of these headers, i.e., you don't need to run
address@hidden, nor check for @file{stdlib.h} etc.
 
 @node Alternative Programs, Libraries, Common Behavior, Existing Tests
 @section Alternative Programs
Index: tests/semantics.at
===================================================================
RCS file: /cvs/autoconf/tests/semantics.at,v
retrieving revision 1.14
diff -u -u -r1.14 semantics.at
--- tests/semantics.at 2001/01/11 15:17:13 1.14
+++ tests/semantics.at 2001/01/15 17:02:06
@@ -103,7 +103,13 @@
 typedef unsigned char ucharchar[2];]])
 AC_CHECK_SIZEOF(ucharcharchar)]],
 [AT_CHECK_DEFINES(
-[#define SIZEOF_CHAR 1
+[#define HAVE_INTTYPES_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
+#define HAVE_UNISTD_H 1
+#define SIZEOF_CHAR 1
 #define SIZEOF_CHARCHAR 2
 #define SIZEOF_CHARCHARCHAR 0
 #define SIZEOF_UCHARCHAR 2



reply via email to

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