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.m498
1 files changed, 57 insertions, 41 deletions
diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4
index d6101fe..c7e0672 100644
--- a/gl/m4/include_next.m4
+++ b/gl/m4/include_next.m4
@@ -1,5 +1,5 @@
1# include_next.m4 serial 12 1# include_next.m4 serial 14
2dnl Copyright (C) 2006-2009 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2010 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.
@@ -104,10 +104,16 @@ EOF
104# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be 104# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
105# '<foo.h>'; otherwise define it to be 105# '<foo.h>'; otherwise define it to be
106# '"///usr/include/foo.h"', or whatever other absolute file name is suitable. 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
109# be
110# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
107# That way, a header file with the following line: 111# That way, a header file with the following line:
108# #@INCLUDE_NEXT@ @NEXT_FOO_H@ 112# #@INCLUDE_NEXT@ @NEXT_FOO_H@
113# or
114# #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
109# behaves (after sed substitution) as if it contained 115# behaves (after sed substitution) as if it contained
110# #include_next <foo.h> 116# #include_next <foo.h>
111# even if the compiler does not support include_next. 117# even if the compiler does not support include_next.
112# The three "///" are to pacify Sun C 5.8, which otherwise would say 118# The three "///" are to pacify Sun C 5.8, which otherwise would say
113# "warning: #include of /usr/include/... may be non-portable". 119# "warning: #include of /usr/include/... may be non-portable".
@@ -123,49 +129,59 @@ AC_DEFUN([gl_CHECK_NEXT_HEADERS],
123 129
124 m4_foreach_w([gl_HEADER_NAME], [$1], 130 m4_foreach_w([gl_HEADER_NAME], [$1],
125 [AS_VAR_PUSHDEF([gl_next_header], 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 if test $gl_cv_have_include_next = yes; then 133 if test $gl_cv_have_include_next = yes; then
128 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) 134 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
129 else 135 else
130 AC_CACHE_CHECK( 136 AC_CACHE_CHECK(
131 [absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>], 137 [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
132 m4_quote(m4_defn([gl_next_header])), 138 m4_defn([gl_next_header]),
133 [AS_VAR_PUSHDEF([gl_header_exists], 139 [AS_VAR_PUSHDEF([gl_header_exists],
134 [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME]))) 140 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
135 if test AS_VAR_GET(gl_header_exists) = yes; then 141 if test AS_VAR_GET(gl_header_exists) = yes; then
136 AC_LANG_CONFTEST( 142 AC_LANG_CONFTEST(
137 [AC_LANG_SOURCE( 143 [AC_LANG_SOURCE(
138 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] 144 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
139 )]) 145 )])
140 dnl AIX "xlc -E" and "cc -E" omit #line directives for header files 146 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 147 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 148 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> 149 dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
144 dnl and others. The workaround is to force preservation of comments 150 dnl and others. The workaround is to force preservation of comments
145 dnl through option -C. This ensures all necessary #line directives 151 dnl through option -C. This ensures all necessary #line directives
146 dnl are present. GCC supports option -C as well. 152 dnl are present. GCC supports option -C as well.
147 case "$host_os" in 153 case "$host_os" in
148 aix*) gl_absname_cpp="$ac_cpp -C" ;; 154 aix*) gl_absname_cpp="$ac_cpp -C" ;;
149 *) gl_absname_cpp="$ac_cpp" ;; 155 *) gl_absname_cpp="$ac_cpp" ;;
150 esac 156 esac
151 dnl eval is necessary to expand gl_absname_cpp. 157 dnl eval is necessary to expand gl_absname_cpp.
152 dnl Ultrix and Pyramid sh refuse to redirect output of eval, 158 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
153 dnl so use subshell. 159 dnl so use subshell.
154 AS_VAR_SET([gl_next_header], 160 AS_VAR_SET([gl_next_header],
155 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | 161 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
156 sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{ 162 sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
157 s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1# 163 s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
158 s#^/[^/]#//&# 164 s#^/[^/]#//&#
159 p 165 p
160 q 166 q
161 }'`'"']) 167 }'`'"'])
162 else 168 else
163 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) 169 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
164 fi 170 fi
165 AS_VAR_POPDEF([gl_header_exists])]) 171 AS_VAR_POPDEF([gl_header_exists])])
166 fi 172 fi
167 AC_SUBST( 173 AC_SUBST(
168 AS_TR_CPP([NEXT_]m4_quote(m4_defn([gl_HEADER_NAME]))), 174 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
169 [AS_VAR_GET([gl_next_header])]) 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'>'
179 else
180 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
181 gl_next_as_first_directive=AS_VAR_GET([gl_next_header])
182 fi
183 AC_SUBST(
184 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
185 [$gl_next_as_first_directive])
170 AS_VAR_POPDEF([gl_next_header])]) 186 AS_VAR_POPDEF([gl_next_header])])
171]) 187])