> Jeff, which solution did you use for your particular problem? I'm reading > between the lines and assuming that you ended up passing something besides > [] or [-], because you wanted a compiler check (which rejects the header > as incompatible with your usage patterns) and not a preprocessor check > (which accepts the header as present). He passed [AC_INCLUDES_DEFAULT], I guess. > In which case, I agree with Ralf - the preprocessor check is broken more > often than it is correct. We've had the warning long enough; I think now > is an acceptable time to swap the default and favor the compiler check > over the preprocessor check. Yes, probably. However, notice this won't help Jeff because he wanted really really no warning. So the attached patch suppresses the warning completely if AC_PREREQ([2.64]) (actually anything > 2.63) is given. What do you think? (testsuite running except for the relevant tests). > Also, things like AC_CHECK_HEADERS_ONCE can't supply a fourth argument, > and hence they always use the header_mongrel implementation. In the past, > this has been an issue on the gnulib list, where you can't do > AC_CHECK_HEADERS_ONCE([ws2tcpip.h]) because it falls in the category of > headers that is present but not compilable on cygwin. Yes, that's bad. I made AC_CHECK_HEADERS_ONCE stick with MONGREL even with AC_PREREQ([2.64]). I'm not sure it's the right thing to do, it's surely the most conservative. Paolo
commit 852e48d74126ca0ad43efb41a4e4d7a7d3eabd8b Author: Paolo Bonzini <bonzini@xxxxxxx> Date: Fri Oct 31 16:53:17 2008 +0100 Finish AC_CHECK_HEADERS transition. * NEWS: Document change. * doc/autoconf.texi (Present But Cannot Be Compiled): Likewise. * lib/autoconf/general.m4 (AC_PREREQ): Store requested version. * lib/autoconf/headers.m4 (_AC_CHECK_HEADER_COMPAT): New name of AC_CHECK_HEADER. (_AC_CHECK_HEADER_NEW, AC_CHECK_HEADER): New. (_AC_CHECK_HEADER_PREPROC_BODY): New name of _AC_CHECK_HEADER_OLD_BODY. (_AC_CHECK_HEADER_COMPILE_BODY): New name of _AC_CHECK_HEADER_NEW_BODY. (_AC_CHECK_HEADER_PREPROC): New name of _AC_CHECK_HEADER_OLD. (_AC_CHECK_HEADER_COMPILE): New name of _AC_CHECK_HEADER_NEW. (_AC_HEADERS_EXPANSION): Force usage of _AC_CHECK_HEADER_MONGREL. * tests/local.at (AT_MAYBE_AC_PREREQ): New. * tests/semantics.at (AC_CHECK_HEADERS): Mention it tests <= 2.63 semantics. Add AC_PREREQ. (AC_CHECK_HEADERS_OLD, AC_CHECK_HEADER_NEW): Give better name. diff --git a/NEWS b/NEWS index d07c143..8d345ca 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,12 @@ GNU Autoconf NEWS - User visible changes. ** m4sugar requires m4_init in order to use m4_divert. +** Stricter header tests. As planned in Autoconf 2.56 (released in + 2002), AC_CHECK_HEADER and AC_CHECK_HEADERS are now honoring the + compiler result rather than the preprocessor result. Furthermore, + adding AC_PREREQ([2.64]) to your configure.ac file will disable + the preprocessor test altogether. + ** The following documented m4sugar macros are new: m4_curry m4_default_quoted m4_map_args m4_map_args_pair m4_set_map diff --git a/doc/autoconf.texi b/doc/autoconf.texi index d2997ef..6e73aab 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -22115,11 +22115,12 @@ Present But Cannot Be Compiled configuration, and maintainers finally had to deal with this issue elsewhere. -As of Autoconf 2.56 both checks are performed, and @command{configure} -complains loudly if the compiler and the preprocessor do not agree. -For the time being the result used is that of the preprocessor, to give -maintainers time to adjust their @file{configure.ac}, but in the -future, only the compiler will be considered. +The transition began with Autoconf 2.56. As of Autoconf 2.64 both +checks are performed, and @command{configure} complains loudly if the +compiler and the preprocessor do not agree. However, only the compiler +result is considered. If you wish to suppress the warning, just include +@code{AC_PREREQ(2.64)}, thus telling Autoconf that you are conscious of +the transition and are ready to complete it. Consider the following example: @@ -22161,8 +22162,7 @@ Present But Cannot Be Compiled configure: WARNING: pi.h: check for missing prerequisite headers? configure: WARNING: pi.h: see the Autoconf documentation configure: WARNING: pi.h: section "Present But Cannot Be Compiled" -configure: WARNING: pi.h: proceeding with the preprocessor's result -configure: WARNING: pi.h: in the future, the compiler will take precedence +configure: WARNING: pi.h: proceeding with the compiler's result configure: WARNING: ## -------------------------------------- ## configure: WARNING: ## Report this to bug-example@@example.org ## configure: WARNING: ## -------------------------------------- ## @@ -22197,7 +22197,7 @@ Present But Cannot Be Compiled @end example See @ref{Particular Headers}, for a list of headers with their -prerequisite. +prerequisites. @c ===================================================== History of Autoconf. diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index ccaf340..e574648 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -317,8 +317,8 @@ AU_DEFUN([AC_PREREQ], # AC_PREREQ(VERSION) # ------------------ # Complain and exit if the Autoconf version is less than VERSION. -m4_undefine([AC_PREREQ]) -m4_copy([m4_version_prereq], [AC_PREREQ]) +AC_DEFUN([AC_PREREQ], +[m4_version_prereq([$1])m4_define([_AC_PREREQ_VERSION], [$1])]) # AC_AUTOCONF_VERSION diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4 index fb6eb0c..659beb9 100644 --- a/lib/autoconf/headers.m4 +++ b/lib/autoconf/headers.m4 @@ -64,6 +64,53 @@ ## ------------------------------ ## +# _AC_CHECK_HEADER_COMPAT(HEADER-FILE, +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +# [INCLUDES]) +# ----------------------------------------------------------------- +# We finally finished moving to checking headers with the compiler instead +# of the preproc, so that we actually learn about the usability of a +# header instead of its mere presence. But since users are used to +# the old semantics, they check for headers in random order and +# without providing prerequisite headers. This macro implements the +# end of the transition phase, which gives a warning but proceeds +# anyway with the compiler's result. +# +# If INCLUDES is empty, then check both via the compiler and preproc. +# If the results are different, issue a warning. +# +# If INCLUDES is `-', keep only the old semantics. +# +# If INCLUDES is specified and different from `-', then use the new +# semantics only. +# +# The m4_indir allows for fewer expansions of $@. +AC_DEFUN([_AC_CHECK_HEADER_COMPAT], +[m4_indir(m4_case([$4], + [], [[_AC_CHECK_HEADER_MONGREL]], + [-], [[_AC_CHECK_HEADER_PREPROC]], + [[_AC_CHECK_HEADER_COMPILE]]), $@) +])# _AC_CHECK_HEADER_COMPAT + + +# _AC_CHECK_HEADER_NEW(HEADER-FILE, +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +# [INCLUDES]) +# -------------------------------------------------------------- +# This macro implements the new semantics. If INCLUDES is `-', do only +# the preprocessor test. +# +# If INCLUDES is not specified or different from `-', then do the +# compiler test only. +# +# The m4_indir allows for fewer expansions of $@. +AC_DEFUN([_AC_CHECK_HEADER_NEW], +[m4_indir(m4_if([$4], [-], + [[_AC_CHECK_HEADER_PREPROC]], + [[_AC_CHECK_HEADER_COMPILE]]), $@) +])# _AC_CHECK_HEADER_NEW + + # AC_CHECK_HEADER(HEADER-FILE, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], # [INCLUDES]) @@ -76,21 +123,20 @@ # transition phase, and should be cleaned up latter to use compilation # only. # -# If INCLUDES is empty, then check both via the compiler and preproc. -# If the results are different, issue a warning, but keep the preproc -# result. +# If INCLUDES is empty, and AC_PREREQ(2.64) was not given, then check +# both via the compiler and preproc. If the results are different, +# issue a warning, but keep the compiler result anyway. # -# If INCLUDES is `-', keep only the old semantics. +# If INCLUDES is `-', do only the preprocessor test. # -# If INCLUDES is specified and different from `-', then use the new -# semantics only. +# Otherwise, do the compiler test only. # -# The m4_indir allows for fewer expansions of $@. +# The macro is self-modifying for speed. AC_DEFUN([AC_CHECK_HEADER], -[m4_indir(m4_case([$4], - [], [[_AC_CHECK_HEADER_MONGREL]], - [-], [[_AC_CHECK_HEADER_OLD]], - [[_AC_CHECK_HEADER_NEW]]), $@) +[m4_if(m4_version_compare(m4_defn([_AC_PREREQ_VERSION]), [2.63]), 1, + [m4_undefine([$0])m4_copy([_AC_CHECK_HEADER_NEW], [$0])], + [m4_undefine([$0])m4_copy([_AC_CHECK_HEADER_COMPAT], [$0])])dnl +$0($@)dnl ])# AC_CHECK_HEADER @@ -121,22 +167,20 @@ case $ac_header_compiler:$ac_header_preproc:$ac_[]_AC_LANG_ABBREV[]_preproc_warn yes:no: ) AC_MSG_WARN([$[]2: accepted by the compiler, rejected by the preprocessor!]) AC_MSG_WARN([$[]2: proceeding with the compiler's result]) - ac_header_preproc=yes ;; no:yes:* ) AC_MSG_WARN([$[]2: present but cannot be compiled]) AC_MSG_WARN([$[]2: check for missing prerequisite headers?]) AC_MSG_WARN([$[]2: see the Autoconf documentation]) AC_MSG_WARN([$[]2: section "Present But Cannot Be Compiled"]) - AC_MSG_WARN([$[]2: proceeding with the preprocessor's result]) - AC_MSG_WARN([$[]2: in the future, the compiler will take precedence]) + AC_MSG_WARN([$[]2: proceeding with the compiler's result]) m4_ifset([AC_PACKAGE_BUGREPORT], [m4_n([( AS_BOX([Report this to ]AC_PACKAGE_BUGREPORT) ) | sed "s/^/$as_me: WARNING: /" >&2])])dnl ;; esac AC_CACHE_CHECK([for $[]2], [$[]3], - [AS_VAR_SET([$[]3], [$ac_header_preproc])])]) + [AS_VAR_SET([$[]3], [$ac_header_compiler])])]) AS_LINENO_POP ])#_AC_CHECK_HEADER_MONGREL_BODY @@ -147,10 +191,10 @@ esac # Check using both the compiler and the preprocessor. If they disagree, # warn, and the preproc wins. # -# This is not based on _AC_CHECK_HEADER_NEW and _AC_CHECK_HEADER_OLD +# This is not based on _AC_CHECK_HEADER_COMPILE and _AC_CHECK_HEADER_PREPROC # because it obfuscate the code to try to factor everything, in particular # because of the cache variables, and the `checking...' messages. -m4_define([_AC_CHECK_HEADER_MONGREL], +AC_DEFUN([_AC_CHECK_HEADER_MONGREL], [AC_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_header_mongrel], [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_header_mongrel], [LINENO HEADER VAR INCLUDES], @@ -165,10 +209,10 @@ AS_VAR_IF([ac_Header], [yes], [$2], [$3]) AS_VAR_POPDEF([ac_Header])])# _AC_CHECK_HEADER_MONGREL -# _AC_CHECK_HEADER_NEW_BODY -# ------------------------- -# Shell function body for _AC_CHECK_HEADER_NEW -m4_define([_AC_CHECK_HEADER_NEW_BODY], +# _AC_CHECK_HEADER_COMPILE_BODY +# ----------------------------- +# Shell function body for _AC_CHECK_HEADER_COMPILE +m4_define([_AC_CHECK_HEADER_COMPILE_BODY], [ AS_LINENO_PUSH([$[]1]) AC_CACHE_CHECK([for $[]2], [$[]3], [AC_COMPILE_IFELSE([AC_LANG_SOURCE([$[]4 @@ -176,56 +220,56 @@ m4_define([_AC_CHECK_HEADER_NEW_BODY], [AS_VAR_SET([$[]3], [yes])], [AS_VAR_SET([$[]3], [no])])]) AS_LINENO_POP -])# _AC_CHECK_HEADER_NEW_BODY +])# _AC_CHECK_HEADER_COMPILE_BODY -# _AC_CHECK_HEADER_NEW(HEADER-FILE, +# _AC_CHECK_HEADER_COMPILE(HEADER-FILE, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], # [INCLUDES = DEFAULT-INCLUDES]) # -------------------------------------------------------------- # Check the compiler accepts HEADER-FILE. The INCLUDES are defaulted. -AC_DEFUN([_AC_CHECK_HEADER_NEW], -[AC_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_header_new], - [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_header_new], +AC_DEFUN([_AC_CHECK_HEADER_COMPILE], +[AC_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_header_compile], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_header_compile], [LINENO HEADER VAR INCLUDES], [Tests whether HEADER exists and can be compiled using the include files in INCLUDES, setting the cache variable VAR accordingly.])], [$0_BODY])]dnl [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])]dnl -[ac_func_[]_AC_LANG_ABBREV[]_check_header_new ]dnl +[ac_func_[]_AC_LANG_ABBREV[]_check_header_compile ]dnl ["$LINENO" "$1" "ac_Header" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4])], [""])" AS_VAR_IF([ac_Header], [yes], [$2], [$3]) -AS_VAR_POPDEF([ac_Header])])# _AC_CHECK_HEADER_NEW +AS_VAR_POPDEF([ac_Header])])# _AC_CHECK_HEADER_COMPILE -# _AC_CHECK_HEADER_OLD_BODY -# ------------------------- -# Shell function body for _AC_CHECK_HEADER_OLD. -m4_define([_AC_CHECK_HEADER_OLD_BODY], +# _AC_CHECK_HEADER_PREPROC_BODY +# ----------------------------- +# Shell function body for _AC_CHECK_HEADER_PREPROC. +m4_define([_AC_CHECK_HEADER_PREPROC_BODY], [ AS_LINENO_PUSH([$[]1]) AC_CACHE_CHECK([for $[]2], [$[]3], [AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$[]2>])], [AS_VAR_SET([$[]3], [yes])], [AS_VAR_SET([$[]3], [no])])]) AS_LINENO_POP -])# _AC_CHECK_HEADER_OLD_BODY +])# _AC_CHECK_HEADER_PREPROC_BODY -# _AC_CHECK_HEADER_OLD(HEADER-FILE, +# _AC_CHECK_HEADER_PREPROC(HEADER-FILE, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # -------------------------------------------------------------- # Check the preprocessor accepts HEADER-FILE. -AC_DEFUN([_AC_CHECK_HEADER_OLD], -[AC_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_header_old], - [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_header_old], +AC_DEFUN([_AC_CHECK_HEADER_PREPROC], +[AC_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_header_preproc], + [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_header_preproc], [LINENO HEADER VAR], [Tests whether HEADER is present, setting the cache variable VAR accordingly.])], [$0_BODY])]dnl [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])]dnl -[ac_func_[]_AC_LANG_ABBREV[]_check_header_old "$LINENO" "$1" "ac_Header" +[ac_func_[]_AC_LANG_ABBREV[]_check_header_preproc "$LINENO" "$1" "ac_Header" AS_VAR_IF([ac_Header], [yes], [$2], [$3]) AS_VAR_POPDEF([ac_Header])dnl -])# _AC_CHECK_HEADER_OLD +])# _AC_CHECK_HEADER_PREPROC # AH_CHECK_HEADERS(HEADER-FILE...) @@ -267,7 +311,9 @@ AC_DEFUN([AC_CHECK_HEADERS_ONCE], m4_define([_AC_HEADERS_EXPANSION], [ m4_divert_text([DEFAULTS], [ac_header_list=]) + m4_pushdef([AC_CHECK_HEADER], [_AC_CHECK_HEADER_MONGREL($@)])dnl AC_CHECK_HEADERS([$ac_header_list]) + m4_popdef([AC_CHECK_HEADER])dnl m4_define([_AC_HEADERS_EXPANSION], []) ]) diff --git a/tests/local.at b/tests/local.at index a772a97..dc3c2ee 100644 --- a/tests/local.at +++ b/tests/local.at @@ -178,6 +178,15 @@ m4_define([AT_CHECK_M4SH], ## ------------------ ## +# AT_MAYBE_AC_PREREQ(CONFIGURE-AC-BODY) +# ------------------------------------- +# Expand to an AC_PREREQ macro unless CONFIGURE-AC-BODY already +# contains one. +m4_define([AT_MAYBE_AC_PREREQ], +[m4_if(m4_index([[$1]], [AC_PREREQ]), -1, + [[AC_PREREQ]](m4_PACKAGE_VERSION), [])]) + + # AT_DATA_AUTOCONF(FILE-NAME, CONTENTS) # ------------------------------------- # Escape the invalid tokens with @&t@. @@ -210,7 +219,8 @@ ls -1 | sed '/^at-/d;/^state-/d;/^config\./d' | sort >state-ls.$][1 ]]) AT_DATA([configure.ac], -[[AC_INIT +[AT_MAYBE_AC_PREREQ([$1]) +[AC_INIT AC_CONFIG_HEADERS(config.h:config.hin) AC_STATE_SAVE(before)] $1 @@ -222,7 +232,6 @@ cp "$abs_top_srcdir/build-aux/install-sh" \ "$abs_top_srcdir/build-aux/config.sub" . ])# AT_CONFIGURE_AC - # AT_CHECK_AUTOCONF(ARGS, [EXIT-STATUS = 0], STDOUT, STDERR) # ---------------------------------------------------------- # We always use "--force", to prevent problems with timestamps if the testsuite diff --git a/tests/semantics.at b/tests/semantics.at index 4075247..cb3138a 100644 --- a/tests/semantics.at +++ b/tests/semantics.at @@ -170,8 +170,9 @@ AT_CLEANUP # ---------------- # Check that it performs the correct actions: # Must define HAVE_STDIO_H, but not HAVE_AUTOCONF_IO_H. -AT_CHECK_MACRO([AC_CHECK_HEADERS], -[AC_CHECK_HEADERS(stdio.h autoconf_io.h)], +AT_CHECK_MACRO([AC_CHECK_HEADERS (2.63 or earlier)], +[AC_PREREQ([2.63]) +AC_CHECK_HEADERS(stdio.h autoconf_io.h)], [AT_CHECK_DEFINES( [/* #undef HAVE_AUTOCONF_IO_H */ #define HAVE_STDIO_H 1 @@ -182,7 +183,7 @@ AT_CHECK_MACRO([AC_CHECK_HEADERS], # -------------------- # Check that it performs the correct actions: # Must not check prerequisites, hence define header2.h -AT_SETUP([AC_CHECK_HEADERS_OLD]) +AT_SETUP([AC_CHECK_HEADERS (preprocessor test)]) AT_DATA([header1.h], [typedef int foo; @@ -209,7 +210,7 @@ AT_CLEANUP # -------------------- # Check that it performs the correct actions: # Must check prerequisites, hence define header2.h but not header3.h -AT_SETUP([AC_CHECK_HEADERS_NEW]) +AT_SETUP([AC_CHECK_HEADERS (compiler test)]) AT_DATA([header1.h], [typedef int foo;
_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf