summaryrefslogtreecommitdiffstats
path: root/gl/m4/include_next.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/include_next.m4')
-rw-r--r--gl/m4/include_next.m490
1 files changed, 22 insertions, 68 deletions
diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4
index 108d9456..bdd542bc 100644
--- a/gl/m4/include_next.m4
+++ b/gl/m4/include_next.m4
@@ -1,12 +1,13 @@
1# include_next.m4 serial 23 1# include_next.m4 serial 26
2dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2021 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Paul Eggert and Derek Price. 7dnl From Paul Eggert and Derek Price.
8 8
9dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER. 9dnl Sets INCLUDE_NEXT, INCLUDE_NEXT_AS_FIRST_DIRECTIVE, PRAGMA_SYSTEM_HEADER,
10dnl and PRAGMA_COLUMNS.
10dnl 11dnl
11dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to 12dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
12dnl 'include' otherwise. 13dnl 'include' otherwise.
@@ -105,19 +106,21 @@ dnl We intentionally avoid using AC_LANG_SOURCE here.
105 AC_SUBST([INCLUDE_NEXT]) 106 AC_SUBST([INCLUDE_NEXT])
106 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) 107 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
107 AC_SUBST([PRAGMA_SYSTEM_HEADER]) 108 AC_SUBST([PRAGMA_SYSTEM_HEADER])
108 AC_CACHE_CHECK([whether system header files limit the line length], 109
109 [gl_cv_pragma_columns], 110 dnl HP NonStop systems, which define __TANDEM, limit the line length
110 [dnl HP NonStop systems, which define __TANDEM, have this misfeature. 111 dnl after including some system header files.
111 AC_EGREP_CPP([choke me], 112 AC_CACHE_CHECK([whether source code line length is unlimited],
113 [gl_cv_source_line_length_unlimited],
114 [AC_EGREP_CPP([choke me],
112 [ 115 [
113#ifdef __TANDEM 116#ifdef __TANDEM
114choke me 117choke me
115#endif 118#endif
116 ], 119 ],
117 [gl_cv_pragma_columns=yes], 120 [gl_cv_source_line_length_unlimited=no],
118 [gl_cv_pragma_columns=no]) 121 [gl_cv_source_line_length_unlimited=yes])
119 ]) 122 ])
120 if test $gl_cv_pragma_columns = yes; then 123 if test $gl_cv_source_line_length_unlimited = no; then
121 PRAGMA_COLUMNS="#pragma COLUMNS 10000" 124 PRAGMA_COLUMNS="#pragma COLUMNS 10000"
122 else 125 else
123 PRAGMA_COLUMNS= 126 PRAGMA_COLUMNS=
@@ -175,89 +178,40 @@ AC_DEFUN([gl_NEXT_HEADERS_INTERNAL],
175 [AC_CHECK_HEADERS_ONCE([$1]) 178 [AC_CHECK_HEADERS_ONCE([$1])
176 ]) 179 ])
177 180
178dnl FIXME: gl_next_header and gl_header_exists must be used unquoted
179dnl until we can assume autoconf 2.64 or newer.
180 m4_foreach_w([gl_HEADER_NAME], [$1], 181 m4_foreach_w([gl_HEADER_NAME], [$1],
181 [AS_VAR_PUSHDEF([gl_next_header], 182 [AS_VAR_PUSHDEF([gl_next_header],
182 [gl_cv_next_]m4_defn([gl_HEADER_NAME])) 183 [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
183 if test $gl_cv_have_include_next = yes; then 184 if test $gl_cv_have_include_next = yes; then
184 AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) 185 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
185 else 186 else
186 AC_CACHE_CHECK( 187 AC_CACHE_CHECK(
187 [absolute name of <]m4_defn([gl_HEADER_NAME])[>], 188 [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
188 m4_defn([gl_next_header]), 189 [gl_next_header],
189 [m4_if([$2], [check], 190 [m4_if([$2], [check],
190 [AS_VAR_PUSHDEF([gl_header_exists], 191 [AS_VAR_PUSHDEF([gl_header_exists],
191 [ac_cv_header_]m4_defn([gl_HEADER_NAME])) 192 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
192 if test AS_VAR_GET(gl_header_exists) = yes; then 193 if test AS_VAR_GET([gl_header_exists]) = yes; then
193 AS_VAR_POPDEF([gl_header_exists]) 194 AS_VAR_POPDEF([gl_header_exists])
194 ]) 195 ])
195 AC_LANG_CONFTEST( 196 gl_ABSOLUTE_HEADER_ONE(gl_HEADER_NAME)
196 [AC_LANG_SOURCE( 197 AS_VAR_COPY([gl_header], [gl_cv_absolute_]AS_TR_SH(gl_HEADER_NAME))
197 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] 198 AS_VAR_SET([gl_next_header], ['"'$gl_header'"'])
198 )])
199 dnl AIX "xlc -E" and "cc -E" omit #line directives for header
200 dnl files that contain only a #include of other header files and
201 dnl no non-comment tokens of their own. This leads to a failure
202 dnl to detect the absolute name of <dirent.h>, <signal.h>,
203 dnl <poll.h> and others. The workaround is to force preservation
204 dnl of comments through option -C. This ensures all necessary
205 dnl #line directives are present. GCC supports option -C as well.
206 case "$host_os" in
207 aix*) gl_absname_cpp="$ac_cpp -C" ;;
208 *) gl_absname_cpp="$ac_cpp" ;;
209 esac
210changequote(,)
211 case "$host_os" in
212 mingw*)
213 dnl For the sake of native Windows compilers (excluding gcc),
214 dnl treat backslash as a directory separator, like /.
215 dnl Actually, these compilers use a double-backslash as
216 dnl directory separator, inside the
217 dnl # line "filename"
218 dnl directives.
219 gl_dirsep_regex='[/\\]'
220 ;;
221 *)
222 gl_dirsep_regex='\/'
223 ;;
224 esac
225 dnl A sed expression that turns a string into a basic regular
226 dnl expression, for use within "/.../".
227 gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
228changequote([,])
229 gl_header_literal_regex=`echo ']m4_defn([gl_HEADER_NAME])[' \
230 | sed -e "$gl_make_literal_regex_sed"`
231 gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
232 s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
233changequote(,)dnl
234 s|^/[^/]|//&|
235changequote([,])dnl
236 p
237 q
238 }'
239 dnl eval is necessary to expand gl_absname_cpp.
240 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
241 dnl so use subshell.
242 AS_VAR_SET(gl_next_header,
243 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
244 sed -n "$gl_absolute_header_sed"`'"'])
245 m4_if([$2], [check], 199 m4_if([$2], [check],
246 [else 200 [else
247 AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) 201 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
248 fi 202 fi
249 ]) 203 ])
250 ]) 204 ])
251 fi 205 fi
252 AC_SUBST( 206 AC_SUBST(
253 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), 207 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
254 [AS_VAR_GET(gl_next_header)]) 208 [AS_VAR_GET([gl_next_header])])
255 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then 209 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
256 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' 210 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
257 gl_next_as_first_directive='<'gl_HEADER_NAME'>' 211 gl_next_as_first_directive='<'gl_HEADER_NAME'>'
258 else 212 else
259 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' 213 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
260 gl_next_as_first_directive=AS_VAR_GET(gl_next_header) 214 gl_next_as_first_directive=AS_VAR_GET([gl_next_header])
261 fi 215 fi
262 AC_SUBST( 216 AC_SUBST(
263 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])), 217 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),