autoconf-patches
[Top][All Lists]
Advanced

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

Re: AC_CHECK_HEADERS with CC only


From: Akim Demaille
Subject: Re: AC_CHECK_HEADERS with CC only
Date: 22 Oct 2002 14:01:51 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

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

>> From: Akim Demaille <address@hidden> Date: 11 Oct 2002 11:42:37
>> +0200
>> 
>> This is my current proposal.

Paul> That looks good to me.  I checked in your code, but I tweaked
Paul> the documentation a bit so I installed the following doc change
Paul> instead.  Among other things, I thought it best not to mention
Paul> AC_HEADER_TIME here since it's not strictly equivalent to
Paul> AC_CHECK_HEADER.  I also added a suggested workaround for any
Paul> incompatibility.

In agreement with Paul, I'm reversing this patch, keeping it for
2.55.  In the meanwhile I have strengthened the error message from
AC_CHECK_HEADERS if some difference is found.  But I'm leaving the
documentation changes.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        Restore the 2002-10-11  Akim Demaille  <address@hidden> patch:

        * lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL)
        (AC_CHECK_HEADER, _AC_CHECK_HEADER_NEW,_AC_CHECK_HEADER_OLD): Restore.
        (_AC_CHECK_HEADER_NEW): Rename as...
        (AC_CHECK_HEADER): this.

Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.267
diff -u -u -r1.267 NEWS
--- NEWS 22 Oct 2002 11:41:58 -0000 1.267
+++ NEWS 22 Oct 2002 12:01:31 -0000
@@ -10,10 +10,6 @@
 
 ** Macros
 
-- AC_CHECK_HEADER/AC_CHECK_HEADERS
-  These macros now check whether the headers are compilable, i.e., they
-  compile headers rather than merely preprocess them.
-
 - New macros
   AC_FUNC_MBRTOWC
 
Index: lib/autoconf/headers.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/headers.m4,v
retrieving revision 1.23
diff -u -u -r1.23 headers.m4
--- lib/autoconf/headers.m4 11 Oct 2002 23:52:06 -0000 1.23
+++ lib/autoconf/headers.m4 22 Oct 2002 12:01:31 -0000
@@ -67,8 +67,93 @@
 #                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
 #                 [INCLUDES])
 # ---------------------------------------------------------
-# Check the compiler accepts HEADER-FILE.  The INCLUDES are defaulted.
+# We are slowly 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
+# 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 `-', keep only the old semantics.
+#
+# If INCLUDES is specified and different from `-', then use the new
+# semantics only.
 AC_DEFUN([AC_CHECK_HEADER],
+[m4_case([$4],
+         [],  [_AC_CHECK_HEADER_MONGREL($@)],
+         [-], [_AC_CHECK_HEADER_OLD($@)],
+              [_AC_CHECK_HEADER_NEW($@)])
+])# AC_CHECK_HEADER
+
+
+# _AC_CHECK_HEADER_MONGREL(HEADER-FILE,
+#                          [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+#                          [INCLUDES])
+# --------------------------------------------------------------
+# 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
+# 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],
+[AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
+AS_VAR_SET_IF(ac_Header,
+              [AC_CACHE_CHECK([for $1], ac_Header, [])],
+              [# Is the header compilable?
+AC_MSG_CHECKING([$1 usability])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([$4])
address@hidden:@include <$1>])],
+                  [ac_header_compiler=yes],
+                  [ac_header_compiler=no])
+AC_MSG_RESULT([$ac_header_compiler])
+
+# Is the header present?
+AC_MSG_CHECKING([$1 presence])
+AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include <$1>])],
+                  [ac_header_preproc=yes],
+                  [ac_header_preproc=no])
+AC_MSG_RESULT([$ac_header_preproc])
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    AC_MSG_WARN([$1: accepted by the compiler, rejected by the preprocessor!])
+    AC_MSG_WARN([$1: proceeding with the preprocessor's result])
+    (
+      AS_BOX([Report this to address@hidden)
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    AC_MSG_WARN([$1: present but cannot be compiled])
+    AC_MSG_WARN([$1: check for missing prerequisite headers?])
+    AC_MSG_WARN([$1: proceeding with the preprocessor's result])
+    (
+      AS_BOX([Report this to address@hidden)
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+AC_CACHE_CHECK([for $1], ac_Header,
+               [AS_VAR_SET(ac_Header, $ac_header_preproc)])
+])dnl ! set ac_HEADER
+AS_IF([test AS_VAR_GET(ac_Header) = yes], [$2], [$3])[]dnl
+AS_VAR_POPDEF([ac_Header])dnl
+])# _AC_CHECK_HEADER_MONGREL
+
+
+# _AC_CHECK_HEADER_NEW(HEADER-FILE,
+#                      [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+#                      [INCLUDES])
+# --------------------------------------------------------------
+# Check the compiler accepts HEADER-FILE.  The INCLUDES are defaulted.
+m4_define([_AC_CHECK_HEADER_NEW],
 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
 AC_CACHE_CHECK([for $1], ac_Header,
                [AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([$4])
@@ -77,7 +162,22 @@
                                   [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_HEADER_NEW
+
+
+# _AC_CHECK_HEADER_OLD(HEADER-FILE,
+#                      [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# --------------------------------------------------------------
+# Check the preprocessor accepts HEADER-FILE.
+m4_define([_AC_CHECK_HEADER_OLD],
+[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>])],
+                                         [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_OLD
 
 
 # AH_CHECK_HEADERS(HEADER-FILE...)





reply via email to

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