1
# include_next.m4 serial 3
2
dnl Copyright (C) 2006, 2007 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.
7
dnl From Paul Eggert and Derek Price.
9
AC_DEFUN([gl_INCLUDE_NEXT],
11
AC_LANG_PREPROC_REQUIRE()
12
AC_CACHE_CHECK([whether the preprocessor supports include_next],
13
[gl_cv_have_include_next],
14
[AC_PREPROC_IFELSE([#include_next <stddef.h>],
15
[gl_cv_have_include_next=yes],
16
[gl_cv_have_include_next=no])])
17
if test $gl_cv_have_include_next = yes; then
19
dnl FIXME: Remove HAVE_INCLUDE_NEXT and update everything that uses it
20
dnl to use @INCLUDE_NEXT@ instead.
21
AC_DEFINE([HAVE_INCLUDE_NEXT], 1,
22
[Define if your compiler supports the #include_next directive.])
24
INCLUDE_NEXT=include_next
28
AC_SUBST([INCLUDE_NEXT])
31
# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
32
# ------------------------------------------
33
# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
34
# '<foo.h>'; otherwise define it to be
35
# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
36
# That way, a header file with the following line:
37
# #@INCLUDE_NEXT@ @NEXT_FOO_H@
38
# behaves (after sed substitution) as if it contained
39
# #include_next <foo.h>
40
# even if the compiler does not support include_next.
41
# The three "///" are to pacify Sun C 5.8, which otherwise would say
42
# "warning: #include of /usr/include/... may be non-portable".
43
# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
44
AC_DEFUN([gl_CHECK_NEXT_HEADERS],
46
AC_REQUIRE([gl_INCLUDE_NEXT])
47
AC_CHECK_HEADERS_ONCE([$1])
49
AC_FOREACH([gl_HEADER_NAME], [$1],
50
[AS_VAR_PUSHDEF([gl_next_header],
51
[gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME])))
52
if test $gl_cv_have_include_next = yes; then
53
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
56
[absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
57
m4_quote(m4_defn([gl_next_header])),
58
[AS_VAR_PUSHDEF([gl_header_exists],
59
[ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))
60
if test AS_VAR_GET(gl_header_exists) = yes; then
63
[[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
65
dnl eval is necessary to expand ac_cpp.
66
dnl Ultrix and Pyramid sh refuse to redirect output of eval,
68
AS_VAR_SET([gl_next_header],
69
['"'`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
70
sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
71
s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
77
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
79
AS_VAR_POPDEF([gl_header_exists])])
82
AS_TR_CPP([NEXT_]m4_quote(m4_defn([gl_HEADER_NAME]))),
83
[AS_VAR_GET([gl_next_header])])
84
AS_VAR_POPDEF([gl_next_header])])