Hello, autoconf-patches

1. Currently the description of AC_CHECK_HEADER in the headers.m4 (where
it is defined) states that the preprocessor check result has precedence
over the compiler check result which is not true.

2. when "./configure"ing a piece of software it's wery strange to

a) see that a header is checked for presence after it has been checked
for usability (assuming the person who sees that knows nothing about
internals of AC_CHECK_HEADER and that "presence" in this context stands
for the ability to preprocess, and "usability" stands for the ability to
compile a header).

b) see that a header is usable, but not present (building apache
portable runtime on FreeBSD spits that for sys/syslimits.h)

the reason for this is the fact that sys/syslimits.h of FreeBSD's is not
ment to be included directly and this is achieved with an #error in it.
When testing sys/syslimits.h with compiler, AC_CHECK_HEADER prepends
#include <sys/syslimits.h> with AC_INCLUDE_DEFAULTS and that happens to
avoid the #error. But when testing with preprocessor, no
AC_INCLUDE_DEFAULTS is used, so the test fails.

to make it brief: if a header is protected from userland with the #error
directive we'll most probably see warning messages and schidzoid
statements about usability of an absent file.

Well, warnings are to show that something is wrong, and protecting
includes with #error is right, at least in FreeBSD realm. Perhaps it's
not a bad idea to use AC_INCLUDE_DEFAULTS or some other mechanism when
checking a header with preprocessor (at least on FreeBSD).

OK, now to the patch:

1. It changes word "preprocessor" for "compiler" in AC_CHECK_HEADER
comment.

2. places AC_PREPROC_IFELSE before AC_COMPILE_IFELSE in
_AC_CHECK_HEADER_MONGREL_BODY


as for using some prerequisites when checking a header with perprocessor
that is only an idea

best

Alex
diff -uBrN autoconf/lib/autoconf/headers.m4 autoconf_modified/lib/autoconf/headers.m4
--- autoconf/lib/autoconf/headers.m4	2009-07-29 18:28:56.000000000 +0400
+++ autoconf_modified/lib/autoconf/headers.m4	2009-08-04 22:37:39.000000000 +0400
@@ -77,7 +77,7 @@
 # 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
+# If the results are different, issue a warning, but keep the compiler
 # result.
 #
 # If INCLUDES is `-', keep only the old semantics.
@@ -101,7 +101,15 @@
 [  AS_LINENO_PUSH([$[]1])
   AS_VAR_SET_IF([$[]3],
 		[AC_CACHE_CHECK([for $[]2], [$[]3], [])],
-		[# Is the header compilable?
+		[# Is the header present?
+AC_MSG_CHECKING([$[]2 presence])
+AC_PREPROC_IFELSE([AC_LANG_SOURCE([...@%:@include <$[]2>])],
+		  [ac_header_preproc=yes],
+		  [ac_header_preproc=no])
+AC_MSG_RESULT([$ac_header_preproc])
+
+# Is the header compilable?
+
 AC_MSG_CHECKING([$[]2 usability])
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([$[]4
 @%:@include <$[]2>])],
@@ -109,13 +117,6 @@
 		  [ac_header_compiler=no])
 AC_MSG_RESULT([$ac_header_compiler])
 
-# Is the header present?
-AC_MSG_CHECKING([$[]2 presence])
-AC_PREPROC_IFELSE([AC_LANG_SOURCE([...@%:@include <$[]2>])],
-		  [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:$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in #((
   yes:no: )

Reply via email to