absolute-header, include-next: Add support for MSVC compiler.
[gnulib.git] / m4 / absolute-header.m4
index dba8dbf..b6ace93 100644 (file)
@@ -1,4 +1,4 @@
-# absolute-header.m4 serial 13
+# absolute-header.m4 serial 14
 dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -53,6 +53,7 @@ m4_foreach_w([gl_HEADER_NAME], [$1],
 #   - it is silent.
 AC_DEFUN([gl_ABSOLUTE_HEADER_ONE],
 [
+  AC_REQUIRE([AC_CANONICAL_HOST])
   AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])])
   dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
   dnl that contain only a #include of other header files and no
@@ -65,15 +66,32 @@ AC_DEFUN([gl_ABSOLUTE_HEADER_ONE],
     aix*) gl_absname_cpp="$ac_cpp -C" ;;
     *)    gl_absname_cpp="$ac_cpp" ;;
   esac
+changequote(,)
+  case "$host_os" in
+    mingw*)
+      dnl For the sake of native Windows compilers (excluding gcc),
+      dnl treat backslash as a directory separator, like /.
+      dnl Actually, these compilers use a double-backslash as
+      dnl directory separator, inside the
+      dnl   # line "filename"
+      dnl directives.
+      gl_dirsep_regex='[/\\]'
+      ;;
+    *)
+      gl_dirsep_regex='/'
+      ;;
+  esac
+changequote([,])
+  gl_absolute_header_sed='\#'"${gl_dirsep_regex}"'$1#{
+      s#.*"\(.*'"${gl_dirsep_regex}"'$1\)".*#\1#
+      s#^/[^/]#//&#
+      p
+      q
+    }'
   dnl eval is necessary to expand gl_absname_cpp.
   dnl Ultrix and Pyramid sh refuse to redirect output of eval,
   dnl so use subshell.
   AS_VAR_SET([gl_cv_absolute_]AS_TR_SH([[$1]]),
 [`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
-sed -n '\#/$1#{
-        s#.*"\(.*/$1\)".*#\1#
-        s#^/[^/]#//&#
-        p
-        q
-}'`])
+  sed -n "$gl_absolute_header_sed"`])
 ])