* absolute-header.m4 (gl_ABSOLUTE_HEADER): Use "" rather than <>
[gnulib.git] / m4 / absolute-header.m4
1 # absolute-header.m4 serial 5
2 dnl Copyright (C) 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl From Derek Price.
8
9 # gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
10 # ---------------------------------------
11 # Find the absolute name of a header file, assuming the header exists.
12 # If the header were sys/inttypes.h, this macro would define
13 # ABSOLUTE_SYS_INTTYPES_H to the `<>' quoted absolute name of sys/inttypes.h
14 # in config.h
15 # (e.g. `#define ABSOLUTE_SYS_INTTYPES_H <///usr/include/sys/inttypes.h>').
16 # The three "///" are to pacify Sun C 5.8, which otherwise would say
17 # "warning: #include of /usr/include/... may be non-portable".
18 AC_DEFUN([gl_ABSOLUTE_HEADER],
19 [AC_LANG_PREPROC_REQUIRE()dnl
20 AC_FOREACH([gl_HEADER_NAME], [$1],
21   [AS_VAR_PUSHDEF([gl_absolute_header],
22                   [gl_cv_absolute_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
23   AC_CACHE_CHECK([absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
24     m4_quote(m4_defn([gl_absolute_header])),
25     [AS_VAR_PUSHDEF([ac_header_exists],
26                     [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
27     AC_CHECK_HEADERS_ONCE(m4_quote(m4_defn([gl_HEADER_NAME])))dnl
28     if test AS_VAR_GET(ac_header_exists) = yes; then
29       AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]])])
30 dnl eval is necessary to expand ac_cpp.
31 dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
32       AS_VAR_SET(gl_absolute_header,
33 [`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
34 sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#;s#^/[^/]#//&#;p;q;}'`])
35     fi
36     AS_VAR_POPDEF([ac_header_exists])dnl
37     ])dnl
38   AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_quote(m4_defn([gl_HEADER_NAME]))),
39                      ["AS_VAR_GET(gl_absolute_header)"],
40                      [Define this to an absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>.])
41   AS_VAR_POPDEF([gl_absolute_header])dnl
42 ])dnl
43 ])# gl_ABSOLUTE_HEADER