headers: make check of system header explicit
[gnulib.git] / m4 / wchar.m4
index 072f466..fd8a387 100644 (file)
@@ -7,40 +7,38 @@ dnl with or without modifications, as long as this notice is preserved.
 
 dnl Written by Eric Blake.
 
-# wchar.m4 serial 28
+# wchar.m4 serial 29
 
 AC_DEFUN([gl_WCHAR_H],
 [
   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
   AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
-  AC_CACHE_CHECK([whether <wchar.h> is standalone],
-    [gl_cv_header_wchar_h_standalone],
-    [AC_COMPILE_IFELSE([[#include <wchar.h>
-wchar_t w;]],
-      [gl_cv_header_wchar_h_standalone=yes],
-      [gl_cv_header_wchar_h_standalone=no])])
-
-  AC_REQUIRE([gt_TYPE_WINT_T])
-  if test $gt_cv_c_wint_t = yes; then
-    HAVE_WINT_T=1
-  else
-    HAVE_WINT_T=0
-  fi
-  AC_SUBST([HAVE_WINT_T])
-
   dnl Prepare for creating substitute <wchar.h>.
-  dnl Do it always: WCHAR_H may be empty here but can be set later.
   dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
   dnl character support).
+  dnl <wchar.h> is always overridden, because of GNULIB_POSIXCHECK.
   AC_CHECK_HEADERS_ONCE([wchar.h])
+  gl_CHECK_NEXT_HEADERS([wchar.h])
   if test $ac_cv_header_wchar_h = yes; then
     HAVE_WCHAR_H=1
+    AC_CACHE_CHECK([whether <wchar.h> is standalone],
+      [gl_cv_header_wchar_h_standalone],
+      [AC_COMPILE_IFELSE([[#include <wchar.h>
+wchar_t w;]],
+        [gl_cv_header_wchar_h_standalone=yes],
+        [gl_cv_header_wchar_h_standalone=no])])
   else
     HAVE_WCHAR_H=0
   fi
   AC_SUBST([HAVE_WCHAR_H])
-  dnl <wchar.h> is always overridden, because of GNULIB_POSIXCHECK.
-  gl_CHECK_NEXT_HEADERS([wchar.h])
+
+  AC_REQUIRE([gt_TYPE_WINT_T])
+  if test $gt_cv_c_wint_t = yes; then
+    HAVE_WINT_T=1
+  else
+    HAVE_WINT_T=0
+  fi
+  AC_SUBST([HAVE_WINT_T])
 ])
 
 dnl Check whether <wchar.h> is usable at all.