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.m4167
1 files changed, 125 insertions, 42 deletions
diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4
index c7e0672..108d945 100644
--- a/gl/m4/include_next.m4
+++ b/gl/m4/include_next.m4
@@ -1,5 +1,5 @@
1# include_next.m4 serial 14 1# include_next.m4 serial 23
2dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2013 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.
@@ -24,6 +24,13 @@ dnl does not warn about some things, and on some systems (Solaris and Interix)
24dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side 24dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
25dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead 25dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
26dnl of plain '__STDC__'. 26dnl of plain '__STDC__'.
27dnl
28dnl PRAGMA_COLUMNS can be used in files that override system header files, so
29dnl as to avoid compilation errors on HP NonStop systems when the gnulib file
30dnl is included by a system header file that does a "#pragma COLUMNS 80" (which
31dnl has the effect of truncating the lines of that file and all files that it
32dnl includes to 80 columns) and the gnulib file has lines longer than 80
33dnl columns.
27 34
28AC_DEFUN([gl_INCLUDE_NEXT], 35AC_DEFUN([gl_INCLUDE_NEXT],
29[ 36[
@@ -68,10 +75,11 @@ EOF
68EOF 75EOF
69 gl_save_CPPFLAGS="$CPPFLAGS" 76 gl_save_CPPFLAGS="$CPPFLAGS"
70 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" 77 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
71 AC_COMPILE_IFELSE([#include <conftest.h>], 78dnl We intentionally avoid using AC_LANG_SOURCE here.
79 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
72 [gl_cv_have_include_next=yes], 80 [gl_cv_have_include_next=yes],
73 [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" 81 [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
74 AC_COMPILE_IFELSE([#include <conftest.h>], 82 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
75 [gl_cv_have_include_next=buggy], 83 [gl_cv_have_include_next=buggy],
76 [gl_cv_have_include_next=no]) 84 [gl_cv_have_include_next=no])
77 ]) 85 ])
@@ -97,6 +105,24 @@ EOF
97 AC_SUBST([INCLUDE_NEXT]) 105 AC_SUBST([INCLUDE_NEXT])
98 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) 106 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
99 AC_SUBST([PRAGMA_SYSTEM_HEADER]) 107 AC_SUBST([PRAGMA_SYSTEM_HEADER])
108 AC_CACHE_CHECK([whether system header files limit the line length],
109 [gl_cv_pragma_columns],
110 [dnl HP NonStop systems, which define __TANDEM, have this misfeature.
111 AC_EGREP_CPP([choke me],
112 [
113#ifdef __TANDEM
114choke me
115#endif
116 ],
117 [gl_cv_pragma_columns=yes],
118 [gl_cv_pragma_columns=no])
119 ])
120 if test $gl_cv_pragma_columns = yes; then
121 PRAGMA_COLUMNS="#pragma COLUMNS 10000"
122 else
123 PRAGMA_COLUMNS=
124 fi
125 AC_SUBST([PRAGMA_COLUMNS])
100]) 126])
101 127
102# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...) 128# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
@@ -117,71 +143,128 @@ EOF
117# even if the compiler does not support include_next. 143# even if the compiler does not support include_next.
118# The three "///" are to pacify Sun C 5.8, which otherwise would say 144# The three "///" are to pacify Sun C 5.8, which otherwise would say
119# "warning: #include of /usr/include/... may be non-portable". 145# "warning: #include of /usr/include/... may be non-portable".
120# Use `""', not `<>', so that the /// cannot be confused with a C99 comment. 146# Use '""', not '<>', so that the /// cannot be confused with a C99 comment.
121# Note: This macro assumes that the header file is not empty after 147# Note: This macro assumes that the header file is not empty after
122# preprocessing, i.e. it does not only define preprocessor macros but also 148# preprocessing, i.e. it does not only define preprocessor macros but also
123# provides some type/enum definitions or function/variable declarations. 149# provides some type/enum definitions or function/variable declarations.
150#
151# This macro also checks whether each header exists, by invoking
152# AC_CHECK_HEADERS_ONCE or AC_CHECK_HEADERS on each argument.
124AC_DEFUN([gl_CHECK_NEXT_HEADERS], 153AC_DEFUN([gl_CHECK_NEXT_HEADERS],
125[ 154[
155 gl_NEXT_HEADERS_INTERNAL([$1], [check])
156])
157
158# gl_NEXT_HEADERS(HEADER1 HEADER2 ...)
159# ------------------------------------
160# Like gl_CHECK_NEXT_HEADERS, except do not check whether the headers exist.
161# This is suitable for headers like <stddef.h> that are standardized by C89
162# and therefore can be assumed to exist.
163AC_DEFUN([gl_NEXT_HEADERS],
164[
165 gl_NEXT_HEADERS_INTERNAL([$1], [assume])
166])
167
168# The guts of gl_CHECK_NEXT_HEADERS and gl_NEXT_HEADERS.
169AC_DEFUN([gl_NEXT_HEADERS_INTERNAL],
170[
126 AC_REQUIRE([gl_INCLUDE_NEXT]) 171 AC_REQUIRE([gl_INCLUDE_NEXT])
127 AC_REQUIRE([AC_CANONICAL_HOST]) 172 AC_REQUIRE([AC_CANONICAL_HOST])
128 AC_CHECK_HEADERS_ONCE([$1])
129 173
174 m4_if([$2], [check],
175 [AC_CHECK_HEADERS_ONCE([$1])
176 ])
177
178dnl FIXME: gl_next_header and gl_header_exists must be used unquoted
179dnl until we can assume autoconf 2.64 or newer.
130 m4_foreach_w([gl_HEADER_NAME], [$1], 180 m4_foreach_w([gl_HEADER_NAME], [$1],
131 [AS_VAR_PUSHDEF([gl_next_header], 181 [AS_VAR_PUSHDEF([gl_next_header],
132 [gl_cv_next_]m4_defn([gl_HEADER_NAME])) 182 [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
133 if test $gl_cv_have_include_next = yes; then 183 if test $gl_cv_have_include_next = yes; then
134 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) 184 AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>'])
135 else 185 else
136 AC_CACHE_CHECK( 186 AC_CACHE_CHECK(
137 [absolute name of <]m4_defn([gl_HEADER_NAME])[>], 187 [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
138 m4_defn([gl_next_header]), 188 m4_defn([gl_next_header]),
139 [AS_VAR_PUSHDEF([gl_header_exists], 189 [m4_if([$2], [check],
140 [ac_cv_header_]m4_defn([gl_HEADER_NAME])) 190 [AS_VAR_PUSHDEF([gl_header_exists],
141 if test AS_VAR_GET(gl_header_exists) = yes; then 191 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
142 AC_LANG_CONFTEST( 192 if test AS_VAR_GET(gl_header_exists) = yes; then
143 [AC_LANG_SOURCE( 193 AS_VAR_POPDEF([gl_header_exists])
144 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] 194 ])
145 )]) 195 AC_LANG_CONFTEST(
146 dnl AIX "xlc -E" and "cc -E" omit #line directives for header files 196 [AC_LANG_SOURCE(
147 dnl that contain only a #include of other header files and no 197 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
148 dnl non-comment tokens of their own. This leads to a failure to 198 )])
149 dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h> 199 dnl AIX "xlc -E" and "cc -E" omit #line directives for header
150 dnl and others. The workaround is to force preservation of comments 200 dnl files that contain only a #include of other header files and
151 dnl through option -C. This ensures all necessary #line directives 201 dnl no non-comment tokens of their own. This leads to a failure
152 dnl are present. GCC supports option -C as well. 202 dnl to detect the absolute name of <dirent.h>, <signal.h>,
153 case "$host_os" in 203 dnl <poll.h> and others. The workaround is to force preservation
154 aix*) gl_absname_cpp="$ac_cpp -C" ;; 204 dnl of comments through option -C. This ensures all necessary
155 *) gl_absname_cpp="$ac_cpp" ;; 205 dnl #line directives are present. GCC supports option -C as well.
156 esac 206 case "$host_os" in
157 dnl eval is necessary to expand gl_absname_cpp. 207 aix*) gl_absname_cpp="$ac_cpp -C" ;;
158 dnl Ultrix and Pyramid sh refuse to redirect output of eval, 208 *) gl_absname_cpp="$ac_cpp" ;;
159 dnl so use subshell. 209 esac
160 AS_VAR_SET([gl_next_header], 210changequote(,)
161 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | 211 case "$host_os" in
162 sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{ 212 mingw*)
163 s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1# 213 dnl For the sake of native Windows compilers (excluding gcc),
164 s#^/[^/]#//&# 214 dnl treat backslash as a directory separator, like /.
165 p 215 dnl Actually, these compilers use a double-backslash as
166 q 216 dnl directory separator, inside the
167 }'`'"']) 217 dnl # line "filename"
168 else 218 dnl directives.
169 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) 219 gl_dirsep_regex='[/\\]'
170 fi 220 ;;
171 AS_VAR_POPDEF([gl_header_exists])]) 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],
246 [else
247 AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>'])
248 fi
249 ])
250 ])
172 fi 251 fi
173 AC_SUBST( 252 AC_SUBST(
174 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), 253 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
175 [AS_VAR_GET([gl_next_header])]) 254 [AS_VAR_GET(gl_next_header)])
176 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then 255 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
177 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' 256 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
178 gl_next_as_first_directive='<'gl_HEADER_NAME'>' 257 gl_next_as_first_directive='<'gl_HEADER_NAME'>'
179 else 258 else
180 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' 259 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
181 gl_next_as_first_directive=AS_VAR_GET([gl_next_header]) 260 gl_next_as_first_directive=AS_VAR_GET(gl_next_header)
182 fi 261 fi
183 AC_SUBST( 262 AC_SUBST(
184 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])), 263 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
185 [$gl_next_as_first_directive]) 264 [$gl_next_as_first_directive])
186 AS_VAR_POPDEF([gl_next_header])]) 265 AS_VAR_POPDEF([gl_next_header])])
187]) 266])
267
268# Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE;
269# this fallback is safe for all earlier autoconf versions.
270m4_define_default([AC_LANG_DEFINES_PROVIDED])