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