* modules/inttypes: New file.
[gnulib.git] / m4 / full-header-path.m4
1 # full-header-path.m4 serial 1
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_FULL_HEADER_PATH(HEADER1 HEADER2 ...)
10 # ----------------------------------------
11 # Find the full path to a header file, when the #include_next directive
12 # doesn't work and the header exists in the first place.  If the header were
13 # sys/inttypes.h (and it existed and #include_next didn't work), this macro
14 # would define FULL_PATH_SYS_INTTYPES_H to the quoted full path to
15 # sys/inttypes.h in config.h
16 # (e.g. `#define FULL_PATH_SYS_INTTYPES_H "/usr/include/sys/inttypes.h"').
17 AC_DEFUN([gl_FULL_HEADER_PATH],
18 [AC_LANG_PREPROC_REQUIRE()dnl
19 AC_REQUIRE([gl_INCLUDE_NEXT])dnl
20 if test $gl_cv_have_include_next = no; then
21 AC_FOREACH([gl_HEADER_NAME], [$1],
22   [AS_VAR_PUSHDEF([gl_full_header_path],
23                   [gl_cv_full_path_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
24   AC_CACHE_CHECK([full path to <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
25     m4_quote(m4_defn([gl_full_header_path])),
26     [AS_VAR_PUSHDEF([ac_header_exists],
27                     [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
28     AC_CHECK_HEADERS_ONCE(m4_quote(m4_defn([gl_HEADER_NAME])))dnl
29     if test AS_VAR_GET(ac_header_exists) = yes; then
30       AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]])])
31 dnl eval is necessary to expand ac_cpp.
32 dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
33       AS_VAR_SET(gl_full_header_path,
34 [`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
35 sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#;p;q;}'`])
36     fi
37     AS_VAR_POPDEF([ac_header_exists])dnl
38     ])dnl
39   AC_DEFINE_UNQUOTED([FULL_PATH_]m4_quote(translit(m4_defn([gl_HEADER_NAME]),
40                                                    [-./abcdefghijklmnopqrstuvwxyz],
41                                                    [___ABCDEFGHIJKLMNOPQRSTUVWXYZ])),
42                      ["AS_VAR_GET(gl_full_header_path)"],
43                      [Define this to the full path to <]m4_quote(m4_defn([gl_HEADER_NAME]))[>.])
44   AS_VAR_POPDEF([gl_full_header_path])dnl
45 ])dnl
46 fi
47 ])# gl_FULL_HEADER_PATH