From: Akim Demaille Date: Tue, 3 Jul 2001 14:12:40 +0000 (+0000) Subject: * acheaders.m4 (AC_CHECK_HEADER): When INCLUDES are set, use the X-Git-Tag: AUTOCONF-2.50c~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ce8361c3d4e19ebab98aab9b4e603fd4c25cf37;p=thirdparty%2Fautoconf.git * acheaders.m4 (AC_CHECK_HEADER): When INCLUDES are set, use the compiler, not the preprocessor. * acgeneral.m4 (_AC_INCLUDES_DEFAULT_REQUIREMENTS): No longer use dedicated code to check for inttypes.h, as AC_CHECK_HEADERS does the right thing. * Makefile.am (.m4.m4f): Emphasize M4 error messages and fail earlier if there are. --- diff --git a/ChangeLog b/ChangeLog index ac8cba8dd..3adaff211 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2001-07-03 Akim Demaille + + * acheaders.m4 (AC_CHECK_HEADER): When INCLUDES are set, use the + compiler, not the preprocessor. + * acgeneral.m4 (_AC_INCLUDES_DEFAULT_REQUIREMENTS): No longer use + dedicated code to check for inttypes.h, as AC_CHECK_HEADERS does + the right thing. + * Makefile.am (.m4.m4f): Emphasize M4 error messages and fail + earlier if there are. + 2001-07-03 Akim Demaille * autoscan.in ($initfile): Remove. diff --git a/Makefile.am b/Makefile.am index 5c7f81b78..ad69002fa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -180,11 +180,19 @@ autoscan: $(srcdir)/autoscan.in $(srcdir)/configure.in # force an end of line when reporting errors. .m4.m4f: $(M4) --include $(srcdir) --fatal-warning --define divert \ - $(srcdir)/$*.m4 | \ + $(srcdir)/$*.m4 2>error.log | \ sed 's/#.*//;/^$$/d' >process.log + if grep . error.log >/dev/null 2>&1; then \ + echo "ERROR: Processing $(srcdir)/$*.m4 produced errors:" >&2; \ + sed "s,^,$(srcdir)/$*.m4: ," &2; \ + echo >&2; \ + exit 1; \ + else \ + rm -f error.log; \ + fi if grep . process.log >/dev/null 2>&1; then \ - echo "Processing $(srcdir)/$*.m4 produced output:" >&2; \ - sed "s,^,$(srcdir)/$*.m4: ," < process.log >&2; \ + echo "ERROR: Processing $(srcdir)/$*.m4 produced output:" >&2; \ + sed "s,^,$(srcdir)/$*.m4: ," &2; \ echo >&2; \ exit 1; \ else \ @@ -193,8 +201,8 @@ autoscan: $(srcdir)/autoscan.in $(srcdir)/configure.in $(M4) --include $(srcdir) --fatal-warning --freeze-state=$*.m4f \ $(srcdir)/$*.m4 >freeze.log if grep . freeze.log >/dev/null 2>&1; then \ - echo "Freezing $(srcdir)/$*.m4 produced output:" >&2; \ - sed "s,^,$(srcdir)/$*.m4: ," < freeze.log >&2; \ + echo "ERROR: Freezing $(srcdir)/$*.m4 produced output:" >&2; \ + sed "s,^,$(srcdir)/$*.m4: ," &2; \ echo >&2; \ exit 1; \ else \ diff --git a/Makefile.in b/Makefile.in index 498fca183..6d4ff03a0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -495,11 +495,19 @@ autoscan: $(srcdir)/autoscan.in $(srcdir)/configure.in # force an end of line when reporting errors. .m4.m4f: $(M4) --include $(srcdir) --fatal-warning --define divert \ - $(srcdir)/$*.m4 | \ + $(srcdir)/$*.m4 2>error.log | \ sed 's/#.*//;/^$$/d' >process.log + if grep . error.log >/dev/null 2>&1; then \ + echo "ERROR: Processing $(srcdir)/$*.m4 produced errors:" >&2; \ + sed "s,^,$(srcdir)/$*.m4: ," &2; \ + echo >&2; \ + exit 1; \ + else \ + rm -f error.log; \ + fi if grep . process.log >/dev/null 2>&1; then \ - echo "Processing $(srcdir)/$*.m4 produced output:" >&2; \ - sed "s,^,$(srcdir)/$*.m4: ," < process.log >&2; \ + echo "ERROR: Processing $(srcdir)/$*.m4 produced output:" >&2; \ + sed "s,^,$(srcdir)/$*.m4: ," &2; \ echo >&2; \ exit 1; \ else \ @@ -508,8 +516,8 @@ autoscan: $(srcdir)/autoscan.in $(srcdir)/configure.in $(M4) --include $(srcdir) --fatal-warning --freeze-state=$*.m4f \ $(srcdir)/$*.m4 >freeze.log if grep . freeze.log >/dev/null 2>&1; then \ - echo "Freezing $(srcdir)/$*.m4 produced output:" >&2; \ - sed "s,^,$(srcdir)/$*.m4: ," < freeze.log >&2; \ + echo "ERROR: Freezing $(srcdir)/$*.m4 produced output:" >&2; \ + sed "s,^,$(srcdir)/$*.m4: ," &2; \ echo >&2; \ exit 1; \ else \ diff --git a/acgeneral.m4 b/acgeneral.m4 index c82b96414..7e6faeb54 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -2237,15 +2237,9 @@ ac_includes_default="\ AC_REQUIRE([AC_HEADER_STDC])dnl # On IRIX 5.3, sys/types and inttypes.h are conflicting. AC_CHECK_HEADERS([sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - stdint.h unistd.h], + inttypes.h stdint.h unistd.h], [], [], $ac_includes_default) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#define HAVE_INTTYPES_H 1 -$ac_includes_default])], - [ac_cv_header_inttypes_h=yes, -AC_DEFINE([HAVE_INTTYPES_H], 1, - [Define if you have the header file.])], - [ac_cv_header_inttypes_h=no]) -]) +])# _AC_INCLUDES_DEFAULT_REQUIREMENTS # AC_INCLUDES_DEFAULT([INCLUDES]) diff --git a/acheaders.m4 b/acheaders.m4 index 44da612b0..ac88b23e4 100644 --- a/acheaders.m4 +++ b/acheaders.m4 @@ -60,17 +60,26 @@ ## 1. Generic tests for headers. ## ## ------------------------------ ## + # AC_CHECK_HEADER(HEADER-FILE, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], # [INCLUDES]) # --------------------------------------------------------- +# If INCLUDES is empty and strictly empty, use the preprocessor to +# check whether HEADER-FILE exists. If INCLUDES is set, then use the +# compiler to check whether INCLUDES followed by HEADER-FILE compiles +# with success. 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([m4_n([$4])dnl + [m4_ifval([$4], + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([$4 @%:@include <$1>])], - [AS_VAR_SET(ac_Header, yes)], - [AS_VAR_SET(ac_Header, no)])]) + [AS_VAR_SET(ac_Header, yes)], + [AS_VAR_SET(ac_Header, no)])], + [AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@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 AS_VAR_POPDEF([ac_Header])dnl ])# AC_CHECK_HEADER @@ -85,8 +94,8 @@ m4_define([AH_CHECK_HEADERS], # AC_CHECK_HEADERS(HEADER-FILE... -# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# [INCLUDES]) +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +# [INCLUDES]) # ---------------------------------------------------------- AC_DEFUN([AC_CHECK_HEADERS], [AH_CHECK_HEADERS([$1])dnl @@ -97,7 +106,7 @@ AC_CHECK_HEADER($ac_header, [$3], [$4])dnl done -]) +])# AC_CHECK_HEADERS diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 169cfa63d..527760505 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -923,8 +923,8 @@ argument explicit, or you may simply omit the trailing commas. The three lines below are equivalent: @example -AC_CHECK_HEADERS(stdio.h, [], []) -AC_CHECK_HEADERS(stdio.h,,) +AC_CHECK_HEADERS(stdio.h, [], [], []) +AC_CHECK_HEADERS(stdio.h,,,) AC_CHECK_HEADERS(stdio.h) @end example @@ -3935,15 +3935,42 @@ test for it (@pxref{Writing Tests}). @defmac 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. +If the system header file @var{header-file} is usable, 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. + +The meaning of ``usable'' depends upon the content of @var{includes}: + +@table @asis +@item if @var{includes} is empty +check whether + +@example +@var{header-file} +@end example + +@noindent +can be @emph{preprocessed} without error. + +@item if @var{include} is set +Check whether + +@example +@var{includes} +#include <@var{header-file}> +@end example + +@noindent +can be @emph{compiled} without error. You may use +@code{AC_CHECK_HEADER} (and @code{AC_CHECK_HEADERS}) to check whether +two headers are compatible. +@end table -This macro actually checks whether @var{header-file} can be included -without error. If @var{includes} is specified, they are included before -@var{header-file}. Note that the @var{includes} are @emph{not} -defaulted. They might be in future releases. +You may pass any kind of dummy content for @var{includes}, such as a +single space, a comment, to check whether @var{header-file} compiles +with success. @end defmac @defmac AC_CHECK_HEADERS (@var{header-file}@dots{}, @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{includes}) @@ -3957,10 +3984,8 @@ 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 -@var{header-file}. Note that the @var{includes} are @emph{not} -defaulted. They might be in future releases. +Be sure to read the documentation of @code{AC_CHECK_HEADER} to +understand the influence of @var{includes}. @end defmac @node Declarations, Structures, Header Files, Existing Tests diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index c82b96414..7e6faeb54 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -2237,15 +2237,9 @@ ac_includes_default="\ AC_REQUIRE([AC_HEADER_STDC])dnl # On IRIX 5.3, sys/types and inttypes.h are conflicting. AC_CHECK_HEADERS([sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - stdint.h unistd.h], + inttypes.h stdint.h unistd.h], [], [], $ac_includes_default) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#define HAVE_INTTYPES_H 1 -$ac_includes_default])], - [ac_cv_header_inttypes_h=yes, -AC_DEFINE([HAVE_INTTYPES_H], 1, - [Define if you have the header file.])], - [ac_cv_header_inttypes_h=no]) -]) +])# _AC_INCLUDES_DEFAULT_REQUIREMENTS # AC_INCLUDES_DEFAULT([INCLUDES]) diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4 index 44da612b0..ac88b23e4 100644 --- a/lib/autoconf/headers.m4 +++ b/lib/autoconf/headers.m4 @@ -60,17 +60,26 @@ ## 1. Generic tests for headers. ## ## ------------------------------ ## + # AC_CHECK_HEADER(HEADER-FILE, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], # [INCLUDES]) # --------------------------------------------------------- +# If INCLUDES is empty and strictly empty, use the preprocessor to +# check whether HEADER-FILE exists. If INCLUDES is set, then use the +# compiler to check whether INCLUDES followed by HEADER-FILE compiles +# with success. 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([m4_n([$4])dnl + [m4_ifval([$4], + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([$4 @%:@include <$1>])], - [AS_VAR_SET(ac_Header, yes)], - [AS_VAR_SET(ac_Header, no)])]) + [AS_VAR_SET(ac_Header, yes)], + [AS_VAR_SET(ac_Header, no)])], + [AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@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 AS_VAR_POPDEF([ac_Header])dnl ])# AC_CHECK_HEADER @@ -85,8 +94,8 @@ m4_define([AH_CHECK_HEADERS], # AC_CHECK_HEADERS(HEADER-FILE... -# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# [INCLUDES]) +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +# [INCLUDES]) # ---------------------------------------------------------- AC_DEFUN([AC_CHECK_HEADERS], [AH_CHECK_HEADERS([$1])dnl @@ -97,7 +106,7 @@ AC_CHECK_HEADER($ac_header, [$3], [$4])dnl done -]) +])# AC_CHECK_HEADERS