annotate m4/include_next.m4 @ 276:23034db7dd8a 2.5

fixed expression 'slots' to not store null on a pass 1 store
author lost
date Mon, 31 Aug 2009 08:39:36 +0000
parents d5392bb5da3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
272
d5392bb5da3c Added generated files
lost
parents:
diff changeset
1 # include_next.m4 serial 10
d5392bb5da3c Added generated files
lost
parents:
diff changeset
2 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
d5392bb5da3c Added generated files
lost
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
d5392bb5da3c Added generated files
lost
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
6
d5392bb5da3c Added generated files
lost
parents:
diff changeset
7 dnl From Paul Eggert and Derek Price.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
8
d5392bb5da3c Added generated files
lost
parents:
diff changeset
9 dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
10 dnl
d5392bb5da3c Added generated files
lost
parents:
diff changeset
11 dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
d5392bb5da3c Added generated files
lost
parents:
diff changeset
12 dnl 'include' otherwise.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
13 dnl
d5392bb5da3c Added generated files
lost
parents:
diff changeset
14 dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler
d5392bb5da3c Added generated files
lost
parents:
diff changeset
15 dnl supports it in the special case that it is the first include directive in
d5392bb5da3c Added generated files
lost
parents:
diff changeset
16 dnl the given file, or to 'include' otherwise.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
17 dnl
d5392bb5da3c Added generated files
lost
parents:
diff changeset
18 dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next,
d5392bb5da3c Added generated files
lost
parents:
diff changeset
19 dnl so as to avoid GCC warnings when the gcc option -pedantic is used.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
20 dnl '#pragma GCC system_header' has the same effect as if the file was found
d5392bb5da3c Added generated files
lost
parents:
diff changeset
21 dnl through the include search path specified with '-isystem' options (as
d5392bb5da3c Added generated files
lost
parents:
diff changeset
22 dnl opposed to the search path specified with '-I' options). Namely, gcc
d5392bb5da3c Added generated files
lost
parents:
diff changeset
23 dnl does not warn about some things, and on some systems (Solaris and Interix)
d5392bb5da3c Added generated files
lost
parents:
diff changeset
24 dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
d5392bb5da3c Added generated files
lost
parents:
diff changeset
25 dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
d5392bb5da3c Added generated files
lost
parents:
diff changeset
26 dnl of plain '__STDC__'.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
27
d5392bb5da3c Added generated files
lost
parents:
diff changeset
28 AC_DEFUN([gl_INCLUDE_NEXT],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
29 [
d5392bb5da3c Added generated files
lost
parents:
diff changeset
30 AC_LANG_PREPROC_REQUIRE()
d5392bb5da3c Added generated files
lost
parents:
diff changeset
31 AC_CACHE_CHECK([whether the preprocessor supports include_next],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
32 [gl_cv_have_include_next],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
33 [rm -rf conftestd1a conftestd1b conftestd2
d5392bb5da3c Added generated files
lost
parents:
diff changeset
34 mkdir conftestd1a conftestd1b conftestd2
d5392bb5da3c Added generated files
lost
parents:
diff changeset
35 dnl The include of <stdio.h> is because IBM C 9.0 on AIX 6.1 supports
d5392bb5da3c Added generated files
lost
parents:
diff changeset
36 dnl include_next when used as first preprocessor directive in a file,
d5392bb5da3c Added generated files
lost
parents:
diff changeset
37 dnl but not when preceded by another include directive. Additionally,
d5392bb5da3c Added generated files
lost
parents:
diff changeset
38 dnl with this same compiler, include_next is a no-op when used in a
d5392bb5da3c Added generated files
lost
parents:
diff changeset
39 dnl header file that was included by specifying its absolute file name.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
40 dnl Despite these two bugs, include_next is used in the compiler's
d5392bb5da3c Added generated files
lost
parents:
diff changeset
41 dnl <math.h>. By virtue of the second bug, we need to use include_next
d5392bb5da3c Added generated files
lost
parents:
diff changeset
42 dnl as well in this case.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
43 cat <<EOF > conftestd1a/conftest.h
d5392bb5da3c Added generated files
lost
parents:
diff changeset
44 #define DEFINED_IN_CONFTESTD1
d5392bb5da3c Added generated files
lost
parents:
diff changeset
45 #include_next <conftest.h>
d5392bb5da3c Added generated files
lost
parents:
diff changeset
46 #ifdef DEFINED_IN_CONFTESTD2
d5392bb5da3c Added generated files
lost
parents:
diff changeset
47 int foo;
d5392bb5da3c Added generated files
lost
parents:
diff changeset
48 #else
d5392bb5da3c Added generated files
lost
parents:
diff changeset
49 #error "include_next doesn't work"
d5392bb5da3c Added generated files
lost
parents:
diff changeset
50 #endif
d5392bb5da3c Added generated files
lost
parents:
diff changeset
51 EOF
d5392bb5da3c Added generated files
lost
parents:
diff changeset
52 cat <<EOF > conftestd1b/conftest.h
d5392bb5da3c Added generated files
lost
parents:
diff changeset
53 #define DEFINED_IN_CONFTESTD1
d5392bb5da3c Added generated files
lost
parents:
diff changeset
54 #include <stdio.h>
d5392bb5da3c Added generated files
lost
parents:
diff changeset
55 #include_next <conftest.h>
d5392bb5da3c Added generated files
lost
parents:
diff changeset
56 #ifdef DEFINED_IN_CONFTESTD2
d5392bb5da3c Added generated files
lost
parents:
diff changeset
57 int foo;
d5392bb5da3c Added generated files
lost
parents:
diff changeset
58 #else
d5392bb5da3c Added generated files
lost
parents:
diff changeset
59 #error "include_next doesn't work"
d5392bb5da3c Added generated files
lost
parents:
diff changeset
60 #endif
d5392bb5da3c Added generated files
lost
parents:
diff changeset
61 EOF
d5392bb5da3c Added generated files
lost
parents:
diff changeset
62 cat <<EOF > conftestd2/conftest.h
d5392bb5da3c Added generated files
lost
parents:
diff changeset
63 #ifndef DEFINED_IN_CONFTESTD1
d5392bb5da3c Added generated files
lost
parents:
diff changeset
64 #error "include_next test doesn't work"
d5392bb5da3c Added generated files
lost
parents:
diff changeset
65 #endif
d5392bb5da3c Added generated files
lost
parents:
diff changeset
66 #define DEFINED_IN_CONFTESTD2
d5392bb5da3c Added generated files
lost
parents:
diff changeset
67 EOF
d5392bb5da3c Added generated files
lost
parents:
diff changeset
68 gl_save_CPPFLAGS="$CPPFLAGS"
d5392bb5da3c Added generated files
lost
parents:
diff changeset
69 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
d5392bb5da3c Added generated files
lost
parents:
diff changeset
70 AC_COMPILE_IFELSE([#include <conftest.h>],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
71 [gl_cv_have_include_next=yes],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
72 [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
d5392bb5da3c Added generated files
lost
parents:
diff changeset
73 AC_COMPILE_IFELSE([#include <conftest.h>],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
74 [gl_cv_have_include_next=buggy],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
75 [gl_cv_have_include_next=no])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
76 ])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
77 CPPFLAGS="$gl_save_CPPFLAGS"
d5392bb5da3c Added generated files
lost
parents:
diff changeset
78 rm -rf conftestd1a conftestd1b conftestd2
d5392bb5da3c Added generated files
lost
parents:
diff changeset
79 ])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
80 PRAGMA_SYSTEM_HEADER=
d5392bb5da3c Added generated files
lost
parents:
diff changeset
81 if test $gl_cv_have_include_next = yes; then
d5392bb5da3c Added generated files
lost
parents:
diff changeset
82 INCLUDE_NEXT=include_next
d5392bb5da3c Added generated files
lost
parents:
diff changeset
83 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
d5392bb5da3c Added generated files
lost
parents:
diff changeset
84 if test -n "$GCC"; then
d5392bb5da3c Added generated files
lost
parents:
diff changeset
85 PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
d5392bb5da3c Added generated files
lost
parents:
diff changeset
86 fi
d5392bb5da3c Added generated files
lost
parents:
diff changeset
87 else
d5392bb5da3c Added generated files
lost
parents:
diff changeset
88 if test $gl_cv_have_include_next = buggy; then
d5392bb5da3c Added generated files
lost
parents:
diff changeset
89 INCLUDE_NEXT=include
d5392bb5da3c Added generated files
lost
parents:
diff changeset
90 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
d5392bb5da3c Added generated files
lost
parents:
diff changeset
91 else
d5392bb5da3c Added generated files
lost
parents:
diff changeset
92 INCLUDE_NEXT=include
d5392bb5da3c Added generated files
lost
parents:
diff changeset
93 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
d5392bb5da3c Added generated files
lost
parents:
diff changeset
94 fi
d5392bb5da3c Added generated files
lost
parents:
diff changeset
95 fi
d5392bb5da3c Added generated files
lost
parents:
diff changeset
96 AC_SUBST([INCLUDE_NEXT])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
97 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
98 AC_SUBST([PRAGMA_SYSTEM_HEADER])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
99 ])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
100
d5392bb5da3c Added generated files
lost
parents:
diff changeset
101 # gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
d5392bb5da3c Added generated files
lost
parents:
diff changeset
102 # ------------------------------------------
d5392bb5da3c Added generated files
lost
parents:
diff changeset
103 # For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
d5392bb5da3c Added generated files
lost
parents:
diff changeset
104 # '<foo.h>'; otherwise define it to be
d5392bb5da3c Added generated files
lost
parents:
diff changeset
105 # '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
106 # That way, a header file with the following line:
d5392bb5da3c Added generated files
lost
parents:
diff changeset
107 # #@INCLUDE_NEXT@ @NEXT_FOO_H@
d5392bb5da3c Added generated files
lost
parents:
diff changeset
108 # behaves (after sed substitution) as if it contained
d5392bb5da3c Added generated files
lost
parents:
diff changeset
109 # #include_next <foo.h>
d5392bb5da3c Added generated files
lost
parents:
diff changeset
110 # even if the compiler does not support include_next.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
111 # The three "///" are to pacify Sun C 5.8, which otherwise would say
d5392bb5da3c Added generated files
lost
parents:
diff changeset
112 # "warning: #include of /usr/include/... may be non-portable".
d5392bb5da3c Added generated files
lost
parents:
diff changeset
113 # Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
114 # Note: This macro assumes that the header file is not empty after
d5392bb5da3c Added generated files
lost
parents:
diff changeset
115 # preprocessing, i.e. it does not only define preprocessor macros but also
d5392bb5da3c Added generated files
lost
parents:
diff changeset
116 # provides some type/enum definitions or function/variable declarations.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
117 AC_DEFUN([gl_CHECK_NEXT_HEADERS],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
118 [
d5392bb5da3c Added generated files
lost
parents:
diff changeset
119 AC_REQUIRE([gl_INCLUDE_NEXT])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
120 AC_REQUIRE([AC_CANONICAL_HOST])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
121 AC_CHECK_HEADERS_ONCE([$1])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
122
d5392bb5da3c Added generated files
lost
parents:
diff changeset
123 m4_foreach_w([gl_HEADER_NAME], [$1],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
124 [AS_VAR_PUSHDEF([gl_next_header],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
125 [gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME])))
d5392bb5da3c Added generated files
lost
parents:
diff changeset
126 if test $gl_cv_have_include_next = yes; then
d5392bb5da3c Added generated files
lost
parents:
diff changeset
127 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
128 else
d5392bb5da3c Added generated files
lost
parents:
diff changeset
129 AC_CACHE_CHECK(
d5392bb5da3c Added generated files
lost
parents:
diff changeset
130 [absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
131 m4_quote(m4_defn([gl_next_header])),
d5392bb5da3c Added generated files
lost
parents:
diff changeset
132 [AS_VAR_PUSHDEF([gl_header_exists],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
133 [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))
d5392bb5da3c Added generated files
lost
parents:
diff changeset
134 if test AS_VAR_GET(gl_header_exists) = yes; then
d5392bb5da3c Added generated files
lost
parents:
diff changeset
135 AC_LANG_CONFTEST(
d5392bb5da3c Added generated files
lost
parents:
diff changeset
136 [AC_LANG_SOURCE(
d5392bb5da3c Added generated files
lost
parents:
diff changeset
137 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
d5392bb5da3c Added generated files
lost
parents:
diff changeset
138 )])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
139 dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
d5392bb5da3c Added generated files
lost
parents:
diff changeset
140 dnl that contain only a #include of other header files and no
d5392bb5da3c Added generated files
lost
parents:
diff changeset
141 dnl non-comment tokens of their own. This leads to a failure to
d5392bb5da3c Added generated files
lost
parents:
diff changeset
142 dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
d5392bb5da3c Added generated files
lost
parents:
diff changeset
143 dnl and others. The workaround is to force preservation of comments
d5392bb5da3c Added generated files
lost
parents:
diff changeset
144 dnl through option -C. This ensures all necessary #line directives
d5392bb5da3c Added generated files
lost
parents:
diff changeset
145 dnl are present. GCC supports option -C as well.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
146 case "$host_os" in
d5392bb5da3c Added generated files
lost
parents:
diff changeset
147 aix*) gl_absname_cpp="$ac_cpp -C" ;;
d5392bb5da3c Added generated files
lost
parents:
diff changeset
148 *) gl_absname_cpp="$ac_cpp" ;;
d5392bb5da3c Added generated files
lost
parents:
diff changeset
149 esac
d5392bb5da3c Added generated files
lost
parents:
diff changeset
150 dnl eval is necessary to expand gl_absname_cpp.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
151 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
d5392bb5da3c Added generated files
lost
parents:
diff changeset
152 dnl so use subshell.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
153 AS_VAR_SET([gl_next_header],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
154 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
d5392bb5da3c Added generated files
lost
parents:
diff changeset
155 sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
d5392bb5da3c Added generated files
lost
parents:
diff changeset
156 s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
d5392bb5da3c Added generated files
lost
parents:
diff changeset
157 s#^/[^/]#//&#
d5392bb5da3c Added generated files
lost
parents:
diff changeset
158 p
d5392bb5da3c Added generated files
lost
parents:
diff changeset
159 q
d5392bb5da3c Added generated files
lost
parents:
diff changeset
160 }'`'"'])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
161 else
d5392bb5da3c Added generated files
lost
parents:
diff changeset
162 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
163 fi
d5392bb5da3c Added generated files
lost
parents:
diff changeset
164 AS_VAR_POPDEF([gl_header_exists])])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
165 fi
d5392bb5da3c Added generated files
lost
parents:
diff changeset
166 AC_SUBST(
d5392bb5da3c Added generated files
lost
parents:
diff changeset
167 AS_TR_CPP([NEXT_]m4_quote(m4_defn([gl_HEADER_NAME]))),
d5392bb5da3c Added generated files
lost
parents:
diff changeset
168 [AS_VAR_GET([gl_next_header])])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
169 AS_VAR_POPDEF([gl_next_header])])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
170 ])