Mercurial > emacs
annotate m4/include_next.m4 @ 112438:11f1b4757236
* image.c (x_create_bitmap_from_xpm_data): Add cast to fix type clash
when calling XpmCreatePixmapFromData.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sat, 22 Jan 2011 20:33:12 -0800 |
parents | c81ff7082a9a |
children |
rev | line source |
---|---|
112403
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
1 # include_next.m4 serial 18 |
112308 | 2 dnl Copyright (C) 2006-2011 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. | |
6 | |
7 dnl From Paul Eggert and Derek Price. | |
8 | |
9 dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER. | |
10 dnl | |
11 dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to | |
12 dnl 'include' otherwise. | |
13 dnl | |
14 dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler | |
15 dnl supports it in the special case that it is the first include directive in | |
16 dnl the given file, or to 'include' otherwise. | |
17 dnl | |
18 dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next, | |
19 dnl so as to avoid GCC warnings when the gcc option -pedantic is used. | |
20 dnl '#pragma GCC system_header' has the same effect as if the file was found | |
21 dnl through the include search path specified with '-isystem' options (as | |
22 dnl opposed to the search path specified with '-I' options). Namely, gcc | |
23 dnl does not warn about some things, and on some systems (Solaris and Interix) | |
24 dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side | |
25 dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead | |
26 dnl of plain '__STDC__'. | |
27 dnl | |
28 dnl PRAGMA_COLUMNS can be used in files that override system header files, so | |
29 dnl as to avoid compilation errors on HP NonStop systems when the gnulib file | |
30 dnl is included by a system header file that does a "#pragma COLUMNS 80" (which | |
31 dnl has the effect of truncating the lines of that file and all files that it | |
32 dnl includes to 80 columns) and the gnulib file has lines longer than 80 | |
33 dnl columns. | |
34 | |
35 AC_DEFUN([gl_INCLUDE_NEXT], | |
36 [ | |
37 AC_LANG_PREPROC_REQUIRE() | |
38 AC_CACHE_CHECK([whether the preprocessor supports include_next], | |
39 [gl_cv_have_include_next], | |
40 [rm -rf conftestd1a conftestd1b conftestd2 | |
41 mkdir conftestd1a conftestd1b conftestd2 | |
42 dnl IBM C 9.0, 10.1 (original versions, prior to the 2009-01 updates) on | |
43 dnl AIX 6.1 support include_next when used as first preprocessor directive | |
44 dnl in a file, but not when preceded by another include directive. Check | |
45 dnl for this bug by including <stdio.h>. | |
46 dnl Additionally, with this same compiler, include_next is a no-op when | |
47 dnl used in a header file that was included by specifying its absolute | |
48 dnl file name. Despite these two bugs, include_next is used in the | |
49 dnl compiler's <math.h>. By virtue of the second bug, we need to use | |
50 dnl include_next as well in this case. | |
51 cat <<EOF > conftestd1a/conftest.h | |
52 #define DEFINED_IN_CONFTESTD1 | |
53 #include_next <conftest.h> | |
54 #ifdef DEFINED_IN_CONFTESTD2 | |
55 int foo; | |
56 #else | |
57 #error "include_next doesn't work" | |
58 #endif | |
59 EOF | |
60 cat <<EOF > conftestd1b/conftest.h | |
61 #define DEFINED_IN_CONFTESTD1 | |
62 #include <stdio.h> | |
63 #include_next <conftest.h> | |
64 #ifdef DEFINED_IN_CONFTESTD2 | |
65 int foo; | |
66 #else | |
67 #error "include_next doesn't work" | |
68 #endif | |
69 EOF | |
70 cat <<EOF > conftestd2/conftest.h | |
71 #ifndef DEFINED_IN_CONFTESTD1 | |
72 #error "include_next test doesn't work" | |
73 #endif | |
74 #define DEFINED_IN_CONFTESTD2 | |
75 EOF | |
76 gl_save_CPPFLAGS="$CPPFLAGS" | |
77 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" | |
78 dnl We intentionally avoid using AC_LANG_SOURCE here. | |
79 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]], | |
80 [gl_cv_have_include_next=yes], | |
81 [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" | |
82 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]], | |
83 [gl_cv_have_include_next=buggy], | |
84 [gl_cv_have_include_next=no]) | |
85 ]) | |
86 CPPFLAGS="$gl_save_CPPFLAGS" | |
87 rm -rf conftestd1a conftestd1b conftestd2 | |
88 ]) | |
89 PRAGMA_SYSTEM_HEADER= | |
90 if test $gl_cv_have_include_next = yes; then | |
91 INCLUDE_NEXT=include_next | |
92 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next | |
93 if test -n "$GCC"; then | |
94 PRAGMA_SYSTEM_HEADER='#pragma GCC system_header' | |
95 fi | |
96 else | |
97 if test $gl_cv_have_include_next = buggy; then | |
98 INCLUDE_NEXT=include | |
99 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next | |
100 else | |
101 INCLUDE_NEXT=include | |
102 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include | |
103 fi | |
104 fi | |
105 AC_SUBST([INCLUDE_NEXT]) | |
106 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) | |
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 | |
114 choke 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]) | |
126 ]) | |
127 | |
128 # gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...) | |
129 # ------------------------------------------ | |
130 # For each arg foo.h, if #include_next works, define NEXT_FOO_H to be | |
131 # '<foo.h>'; otherwise define it to be | |
132 # '"///usr/include/foo.h"', or whatever other absolute file name is suitable. | |
133 # Also, if #include_next works as first preprocessing directive in a file, | |
134 # define NEXT_AS_FIRST_DIRECTIVE_FOO_H to be '<foo.h>'; otherwise define it to | |
135 # be | |
136 # '"///usr/include/foo.h"', or whatever other absolute file name is suitable. | |
137 # That way, a header file with the following line: | |
138 # #@INCLUDE_NEXT@ @NEXT_FOO_H@ | |
139 # or | |
140 # #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@ | |
141 # behaves (after sed substitution) as if it contained | |
142 # #include_next <foo.h> | |
143 # even if the compiler does not support include_next. | |
144 # The three "///" are to pacify Sun C 5.8, which otherwise would say | |
145 # "warning: #include of /usr/include/... may be non-portable". | |
146 # Use `""', not `<>', so that the /// cannot be confused with a C99 comment. | |
147 # Note: This macro assumes that the header file is not empty after | |
148 # preprocessing, i.e. it does not only define preprocessor macros but also | |
149 # provides some type/enum definitions or function/variable declarations. | |
112403
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
150 # |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
151 # This macro also checks whether each header exists, by invoking |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
152 # AC_CHECK_HEADERS_ONCE or AC_CHECK_HEADERS on each argument. |
112308 | 153 AC_DEFUN([gl_CHECK_NEXT_HEADERS], |
154 [ | |
112403
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
155 gl_NEXT_HEADERS_INTERNAL([$1], [check]) |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
156 ]) |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
157 |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
158 # gl_NEXT_HEADERS(HEADER1 HEADER2 ...) |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
159 # ------------------------------------ |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
160 # Like gl_CHECK_NEXT_HEADERS, except do not check whether the headers exist. |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
161 # This is suitable for headers like <stddef.h> that are standardized by C89 |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
162 # and therefore can be assumed to exist. |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
163 AC_DEFUN([gl_NEXT_HEADERS], |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
164 [ |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
165 gl_NEXT_HEADERS_INTERNAL([$1], [assume]) |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
166 ]) |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
167 |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
168 # The guts of gl_CHECK_NEXT_HEADERS and gl_NEXT_HEADERS. |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
169 AC_DEFUN([gl_NEXT_HEADERS_INTERNAL], |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
170 [ |
112308 | 171 AC_REQUIRE([gl_INCLUDE_NEXT]) |
172 AC_REQUIRE([AC_CANONICAL_HOST]) | |
112403
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
173 |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
174 m4_if([$2], [check], |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
175 [AC_CHECK_HEADERS_ONCE([$1]) |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
176 ]) |
112308 | 177 |
178 m4_foreach_w([gl_HEADER_NAME], [$1], | |
179 [AS_VAR_PUSHDEF([gl_next_header], | |
180 [gl_cv_next_]m4_defn([gl_HEADER_NAME])) | |
181 if test $gl_cv_have_include_next = yes; then | |
182 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) | |
183 else | |
184 AC_CACHE_CHECK( | |
185 [absolute name of <]m4_defn([gl_HEADER_NAME])[>], | |
186 m4_defn([gl_next_header]), | |
112403
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
187 [m4_if([$2], [check], |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
188 [AS_VAR_PUSHDEF([gl_header_exists], |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
189 [ac_cv_header_]m4_defn([gl_HEADER_NAME])) |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
190 if test AS_VAR_GET(gl_header_exists) = yes; then |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
191 AS_VAR_POPDEF([gl_header_exists]) |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
192 ]) |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
193 AC_LANG_CONFTEST( |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
194 [AC_LANG_SOURCE( |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
195 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
196 )]) |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
197 dnl AIX "xlc -E" and "cc -E" omit #line directives for header |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
198 dnl files that contain only a #include of other header files and |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
199 dnl no non-comment tokens of their own. This leads to a failure |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
200 dnl to detect the absolute name of <dirent.h>, <signal.h>, |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
201 dnl <poll.h> and others. The workaround is to force preservation |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
202 dnl of comments through option -C. This ensures all necessary |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
203 dnl #line directives are present. GCC supports option -C as well. |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
204 case "$host_os" in |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
205 aix*) gl_absname_cpp="$ac_cpp -C" ;; |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
206 *) gl_absname_cpp="$ac_cpp" ;; |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
207 esac |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
208 dnl eval is necessary to expand gl_absname_cpp. |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
209 dnl Ultrix and Pyramid sh refuse to redirect output of eval, |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
210 dnl so use subshell. |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
211 AS_VAR_SET([gl_next_header], |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
212 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
213 sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{ |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
214 s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1# |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
215 s#^/[^/]#//&# |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
216 p |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
217 q |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
218 }'`'"']) |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
219 m4_if([$2], [check], |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
220 [else |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
221 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
222 fi |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
223 ]) |
c81ff7082a9a
src/config.in: shrink slightly
Paul Eggert <eggert@cs.ucla.edu>
parents:
112308
diff
changeset
|
224 ]) |
112308 | 225 fi |
226 AC_SUBST( | |
227 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), | |
228 [AS_VAR_GET([gl_next_header])]) | |
229 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then | |
230 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' | |
231 gl_next_as_first_directive='<'gl_HEADER_NAME'>' | |
232 else | |
233 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' | |
234 gl_next_as_first_directive=AS_VAR_GET([gl_next_header]) | |
235 fi | |
236 AC_SUBST( | |
237 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])), | |
238 [$gl_next_as_first_directive]) | |
239 AS_VAR_POPDEF([gl_next_header])]) | |
240 ]) | |
241 | |
242 # Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE; | |
243 # this fallback is safe for all earlier autoconf versions. | |
244 m4_define_default([AC_LANG_DEFINES_PROVIDED]) |