Mercurial > hg-old > index.cgi
comparison m4/include_next.m4 @ 267:bec6d2480f08 2.6
Added add'l generated files for release
author | lost |
---|---|
date | Tue, 22 Dec 2009 05:33:32 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
266:5f25e7afac21 | 267:bec6d2480f08 |
---|---|
1 # include_next.m4 serial 12 | |
2 dnl Copyright (C) 2006-2009 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 | |
28 AC_DEFUN([gl_INCLUDE_NEXT], | |
29 [ | |
30 AC_LANG_PREPROC_REQUIRE() | |
31 AC_CACHE_CHECK([whether the preprocessor supports include_next], | |
32 [gl_cv_have_include_next], | |
33 [rm -rf conftestd1a conftestd1b conftestd2 | |
34 mkdir conftestd1a conftestd1b conftestd2 | |
35 dnl IBM C 9.0, 10.1 (original versions, prior to the 2009-01 updates) on | |
36 dnl AIX 6.1 support include_next when used as first preprocessor directive | |
37 dnl in a file, but not when preceded by another include directive. Check | |
38 dnl for this bug by including <stdio.h>. | |
39 dnl Additionally, with this same compiler, include_next is a no-op when | |
40 dnl used in a header file that was included by specifying its absolute | |
41 dnl file name. Despite these two bugs, include_next is used in the | |
42 dnl compiler's <math.h>. By virtue of the second bug, we need to use | |
43 dnl include_next as well in this case. | |
44 cat <<EOF > conftestd1a/conftest.h | |
45 #define DEFINED_IN_CONFTESTD1 | |
46 #include_next <conftest.h> | |
47 #ifdef DEFINED_IN_CONFTESTD2 | |
48 int foo; | |
49 #else | |
50 #error "include_next doesn't work" | |
51 #endif | |
52 EOF | |
53 cat <<EOF > conftestd1b/conftest.h | |
54 #define DEFINED_IN_CONFTESTD1 | |
55 #include <stdio.h> | |
56 #include_next <conftest.h> | |
57 #ifdef DEFINED_IN_CONFTESTD2 | |
58 int foo; | |
59 #else | |
60 #error "include_next doesn't work" | |
61 #endif | |
62 EOF | |
63 cat <<EOF > conftestd2/conftest.h | |
64 #ifndef DEFINED_IN_CONFTESTD1 | |
65 #error "include_next test doesn't work" | |
66 #endif | |
67 #define DEFINED_IN_CONFTESTD2 | |
68 EOF | |
69 gl_save_CPPFLAGS="$CPPFLAGS" | |
70 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" | |
71 AC_COMPILE_IFELSE([#include <conftest.h>], | |
72 [gl_cv_have_include_next=yes], | |
73 [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" | |
74 AC_COMPILE_IFELSE([#include <conftest.h>], | |
75 [gl_cv_have_include_next=buggy], | |
76 [gl_cv_have_include_next=no]) | |
77 ]) | |
78 CPPFLAGS="$gl_save_CPPFLAGS" | |
79 rm -rf conftestd1a conftestd1b conftestd2 | |
80 ]) | |
81 PRAGMA_SYSTEM_HEADER= | |
82 if test $gl_cv_have_include_next = yes; then | |
83 INCLUDE_NEXT=include_next | |
84 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next | |
85 if test -n "$GCC"; then | |
86 PRAGMA_SYSTEM_HEADER='#pragma GCC system_header' | |
87 fi | |
88 else | |
89 if test $gl_cv_have_include_next = buggy; then | |
90 INCLUDE_NEXT=include | |
91 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next | |
92 else | |
93 INCLUDE_NEXT=include | |
94 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include | |
95 fi | |
96 fi | |
97 AC_SUBST([INCLUDE_NEXT]) | |
98 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) | |
99 AC_SUBST([PRAGMA_SYSTEM_HEADER]) | |
100 ]) | |
101 | |
102 # gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...) | |
103 # ------------------------------------------ | |
104 # For each arg foo.h, if #include_next works, define NEXT_FOO_H to be | |
105 # '<foo.h>'; otherwise define it to be | |
106 # '"///usr/include/foo.h"', or whatever other absolute file name is suitable. | |
107 # That way, a header file with the following line: | |
108 # #@INCLUDE_NEXT@ @NEXT_FOO_H@ | |
109 # behaves (after sed substitution) as if it contained | |
110 # #include_next <foo.h> | |
111 # even if the compiler does not support include_next. | |
112 # The three "///" are to pacify Sun C 5.8, which otherwise would say | |
113 # "warning: #include of /usr/include/... may be non-portable". | |
114 # Use `""', not `<>', so that the /// cannot be confused with a C99 comment. | |
115 # Note: This macro assumes that the header file is not empty after | |
116 # preprocessing, i.e. it does not only define preprocessor macros but also | |
117 # provides some type/enum definitions or function/variable declarations. | |
118 AC_DEFUN([gl_CHECK_NEXT_HEADERS], | |
119 [ | |
120 AC_REQUIRE([gl_INCLUDE_NEXT]) | |
121 AC_REQUIRE([AC_CANONICAL_HOST]) | |
122 AC_CHECK_HEADERS_ONCE([$1]) | |
123 | |
124 m4_foreach_w([gl_HEADER_NAME], [$1], | |
125 [AS_VAR_PUSHDEF([gl_next_header], | |
126 [gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME]))) | |
127 if test $gl_cv_have_include_next = yes; then | |
128 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) | |
129 else | |
130 AC_CACHE_CHECK( | |
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 | |
136 AC_LANG_CONFTEST( | |
137 [AC_LANG_SOURCE( | |
138 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] | |
139 )]) | |
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. | |
147 case "$host_os" in | |
148 aix*) gl_absname_cpp="$ac_cpp -C" ;; | |
149 *) gl_absname_cpp="$ac_cpp" ;; | |
150 esac | |
151 dnl eval is necessary to expand gl_absname_cpp. | |
152 dnl Ultrix and Pyramid sh refuse to redirect output of eval, | |
153 dnl so use subshell. | |
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# | |
158 s#^/[^/]#//&# | |
159 p | |
160 q | |
161 }'`'"']) | |
162 else | |
163 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) | |
164 fi | |
165 AS_VAR_POPDEF([gl_header_exists])]) | |
166 fi | |
167 AC_SUBST( | |
168 AS_TR_CPP([NEXT_]m4_quote(m4_defn([gl_HEADER_NAME]))), | |
169 [AS_VAR_GET([gl_next_header])]) | |
170 AS_VAR_POPDEF([gl_next_header])]) | |
171 ]) |