1# ===========================================================================
2#       http://www.nongnu.org/autoconf-archive/ax_absolute_header.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7#   AX_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
8#
9# DESCRIPTION
10#
11#   Find the absolute name of a header file, assuming the header exists. If
12#   the header were sys/inttypes.h, this macro would define
13#   ABSOLUTE_SYS_INTTYPES_H to the `""' quoted absolute name of
14#   sys/inttypes.h in config.h (e.g. `#define ABSOLUTE_SYS_INTTYPES_H
15#   "///usr/include/sys/inttypes.h"'). The three "///" are to pacify Sun C
16#   5.8, which otherwise would say "warning: #include of /usr/include/...
17#   may be non-portable". Use `""', not `<>', so that the /// cannot be
18#   confused with a C99 comment.
19#
20# LICENSE
21#
22#   Copyright (c) 2009 Derek Price
23#   Copyright (c) 2009 Rhys Ulerich <rhys.ulerich@gmail.com>
24#
25#   Copying and distribution of this file, with or without modification, are
26#   permitted in any medium without royalty provided the copyright notice
27#   and this notice are preserved.
28
29dnl Copyright (C) 2006, 2007 Free Software Foundation, Inc.
30dnl This file is free software; the Free Software Foundation
31dnl gives unlimited permission to copy and/or distribute it,
32dnl with or without modifications, as long as this notice is preserved.
33
34dnl From Derek Price.
35dnl Modified by Rhys Ulerich to use AC_CHECK_HEADERS instead of _ONCE
36
37AC_DEFUN([AX_ABSOLUTE_HEADER],
38[AC_LANG_PREPROC_REQUIRE()dnl
39AC_FOREACH([gl_HEADER_NAME], [$1],
40  [AS_VAR_PUSHDEF([gl_absolute_header],
41                  [gl_cv_absolute_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
42  AC_CACHE_CHECK([absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
43    m4_quote(m4_defn([gl_absolute_header])),
44    [AS_VAR_PUSHDEF([ac_header_exists],
45                    [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
46    AC_CHECK_HEADERS(m4_quote(m4_defn([gl_HEADER_NAME])))dnl
47    if test AS_VAR_GET(ac_header_exists) = yes; then
48      AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]])])
49dnl eval is necessary to expand ac_cpp.
50dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
51      AS_VAR_SET(gl_absolute_header,
52[`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
53sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
54        s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
55        s#^/[^/]#//&#
56        p
57        q
58}'`])
59    fi
60    AS_VAR_POPDEF([ac_header_exists])dnl
61    ])dnl
62  AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_quote(m4_defn([gl_HEADER_NAME]))),
63                     ["AS_VAR_GET(gl_absolute_header)"],
64                     [Define this to an absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>.])
65  AS_VAR_POPDEF([gl_absolute_header])dnl
66])dnl
67])# AX_ABSOLUTE_HEADER
68