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 <akim@epita.fr>
+
+ * 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 <akim@epita.fr>
* autoscan.in ($initfile): Remove.
# 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: ," <error.log >&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: ," <process.log >&2; \
echo >&2; \
exit 1; \
else \
$(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: ," <freeze.log >&2; \
echo >&2; \
exit 1; \
else \
# 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: ," <error.log >&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: ," <process.log >&2; \
echo >&2; \
exit 1; \
else \
$(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: ," <freeze.log >&2; \
echo >&2; \
exit 1; \
else \
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 <inttypes.h> header file.])],
- [ac_cv_header_inttypes_h=no])
-])
+])# _AC_INCLUDES_DEFAULT_REQUIREMENTS
# AC_INCLUDES_DEFAULT([INCLUDES])
## 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
# 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
[$3],
[$4])dnl
done
-])
+])# AC_CHECK_HEADERS
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
@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})
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
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 <inttypes.h> header file.])],
- [ac_cv_header_inttypes_h=no])
-])
+])# _AC_INCLUDES_DEFAULT_REQUIREMENTS
# AC_INCLUDES_DEFAULT([INCLUDES])
## 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
# 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
[$3],
[$4])dnl
done
-])
+])# AC_CHECK_HEADERS