104
104
# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
105
105
# '<foo.h>'; otherwise define it to be
106
106
# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
107
# Also, if #include_next works as first preprocessing directive in a file,
108
# define NEXT_AS_FIRST_DIRECTIVE_FOO_H to be '<foo.h>'; otherwise define it to
110
# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
107
111
# That way, a header file with the following line:
108
# #@INCLUDE_NEXT@ @NEXT_FOO_H@
112
# #@INCLUDE_NEXT@ @NEXT_FOO_H@
114
# #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
109
115
# behaves (after sed substitution) as if it contained
110
# #include_next <foo.h>
116
# #include_next <foo.h>
111
117
# even if the compiler does not support include_next.
112
118
# The three "///" are to pacify Sun C 5.8, which otherwise would say
113
119
# "warning: #include of /usr/include/... may be non-portable".
124
130
m4_foreach_w([gl_HEADER_NAME], [$1],
125
131
[AS_VAR_PUSHDEF([gl_next_header],
126
[gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME])))
132
[gl_cv_next_]m4_defn([gl_HEADER_NAME]))
127
133
if test $gl_cv_have_include_next = yes; then
128
134
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
131
[absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
132
m4_quote(m4_defn([gl_next_header])),
133
[AS_VAR_PUSHDEF([gl_header_exists],
134
[ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))
135
if test AS_VAR_GET(gl_header_exists) = yes; then
138
[[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
140
dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
141
dnl that contain only a #include of other header files and no
142
dnl non-comment tokens of their own. This leads to a failure to
143
dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
144
dnl and others. The workaround is to force preservation of comments
145
dnl through option -C. This ensures all necessary #line directives
146
dnl are present. GCC supports option -C as well.
148
aix*) gl_absname_cpp="$ac_cpp -C" ;;
149
*) gl_absname_cpp="$ac_cpp" ;;
151
dnl eval is necessary to expand gl_absname_cpp.
152
dnl Ultrix and Pyramid sh refuse to redirect output of eval,
154
AS_VAR_SET([gl_next_header],
155
['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
156
sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
157
s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
163
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
165
AS_VAR_POPDEF([gl_header_exists])])
137
[absolute name of <]m4_defn([gl_HEADER_NAME])[>],
138
m4_defn([gl_next_header]),
139
[AS_VAR_PUSHDEF([gl_header_exists],
140
[ac_cv_header_]m4_defn([gl_HEADER_NAME]))
141
if test AS_VAR_GET(gl_header_exists) = yes; then
144
[[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
146
dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
147
dnl that contain only a #include of other header files and no
148
dnl non-comment tokens of their own. This leads to a failure to
149
dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
150
dnl and others. The workaround is to force preservation of comments
151
dnl through option -C. This ensures all necessary #line directives
152
dnl are present. GCC supports option -C as well.
154
aix*) gl_absname_cpp="$ac_cpp -C" ;;
155
*) gl_absname_cpp="$ac_cpp" ;;
157
dnl eval is necessary to expand gl_absname_cpp.
158
dnl Ultrix and Pyramid sh refuse to redirect output of eval,
160
AS_VAR_SET([gl_next_header],
161
['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
162
sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
163
s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
169
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
171
AS_VAR_POPDEF([gl_header_exists])])
168
AS_TR_CPP([NEXT_]m4_quote(m4_defn([gl_HEADER_NAME]))),
174
AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
169
175
[AS_VAR_GET([gl_next_header])])
176
if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
177
# INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
178
gl_next_as_first_directive='<'gl_HEADER_NAME'>'
180
# INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
181
gl_next_as_first_directive=AS_VAR_GET([gl_next_header])
184
AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
185
[$gl_next_as_first_directive])
170
186
AS_VAR_POPDEF([gl_next_header])])