Debian Codegraph @

tests/compile.at

raw
1 # -*- autoconf -*-
2
3 AT_BANNER([Low level compiling/preprocessing macros.])
4
5 # Since the macros which compile are required by most tests, check
6 # them first. But remember that looking for a compiler is even more
7 # primitive, so check those first.
8
9
10 ## ------------------------------------- ##
11 ## AC_LANG, AC_LANG_PUSH & AC_LANG_POP. ##
12 ## ------------------------------------- ##
13
14 AT_SETUP([AC_LANG, AC_LANG_PUSH & AC_LANG_POP])
15
16 AT_DATA([configure.ac],
17 [[AC_INIT
18 # C
19 AC_LANG(C)
20 # C
21 AC_LANG_PUSH(C)
22 # C C
23 AC_LANG_PUSH(C++)
24 # C++ C C
25 AC_LANG(C++)
26 # C++ C C
27 AC_LANG_PUSH(Fortran 77)
28 # F77 C++ C C
29 AC_LANG_POP(Fortran 77)
30 # C++ C C
31 AC_LANG(C++)
32 # C++ C C
33 AC_LANG_POP(C++)
34 # C C
35 AC_LANG_POP(C)
36 # C
37 ]])
38
39 AT_CHECK_AUTOCONF
40 AT_CHECK([sed -n 's/^ac_ext=//p' configure], 0,
41 [c
42 c
43 c
44 cc
45 cc
46 f
47 cc
48 cc
49 c
50 c
51 ])
52
53 AT_CLEANUP
54
55
56 ## ------------ ##
57 ## Extensions. ##
58 ## ------------ ##
59
60 # As far as we know only `foo', `foo.exe' are possible executable,
61 # and `foo.o', `foo.obj' are possible object files. Autoconf must not
62 # know that, but it is OK for the test suite to take this into account.
63 AT_CHECK_MACRO([Extensions],
64 [[AC_PROG_CC
65 case $ac_exeext in
66 '' | '.exe' ) ;;
67 * ) AC_MSG_ERROR([suspicious executable suffix: $ac_exeext]);;
68 esac
69
70 case $ac_objext in
71 'o' | 'obj' ) ;;
72 * ) AC_MSG_ERROR([suspicious object suffix: $ac_objext]);;
73 esac
74 AS_EXIT([0])
75 ]])
76
77
78
79 ## -------------------------- ##
80 ## Broken/missing compilers. ##
81 ## -------------------------- ##
82
83
84 # Check that Autoconf correctly diagnoses broken compilers, and in
85 # particular, if it does not exit 77, the test suite is in trouble...
86 # FIXME: Once a precise message decided, check stderr of configure.
87 AT_SETUP([Broken/missing compilers])
88
89 AT_DATA([configure.ac],
90 [[AC_INIT
91 CC=no-such-compiler
92 AC_PROG_CC
93 ]])
94
95 AT_CHECK_AUTOCONF
96 AT_CHECK_CONFIGURE([], 77, ignore, ignore)
97
98 AT_CLEANUP
99
100
101 ## ------------ ##
102 ## C keywords. ##
103 ## ------------ ##
104
105 # GCC supports `const', `volatile', and `inline'.
106 AT_CHECK_MACRO([C keywords],
107 [[AC_PROG_CC
108 AC_C_CONST
109 AC_C_INLINE
110 AC_C_VOLATILE
111 case $GCC,$ac_cv_c_const,$ac_cv_c_inline,$ac_cv_c_volatile in
112 yes,*no*)
113 AC_MSG_ERROR([failed to detect `const', `inline' or `volatile' support]);;
114 esac
115 ]])
116
117
118
119 ## --------------------------------- ##
120 ## AC_PROG_CPP requires AC_PROG_CC. ##
121 ## --------------------------------- ##
122
123 # Must invoke AC_PROG_CC.
124 AT_CHECK_MACRO([AC_PROG_CPP requires AC_PROG_CC],
125 [[AC_PROG_CPP
126 test -z "$CC" &&
127 AC_MSG_ERROR([looked for a C preprocessor without looking for a compiler])
128 ]])
129
130
131
132 ## --------------------------- ##
133 ## AC_PROG_CPP with warnings. ##
134 ## --------------------------- ##
135
136
137 # It's Ok for strict preprocessors to produce warnings.
138
139 AT_SETUP([AC_PROG_CPP with warnings])
140
141 AT_DATA([mycpp],
142 [[#! /bin/sh
143 echo noise >&2
144 exec ${1+"$@"}
145 ]])
146
147 chmod +x mycpp
148
149 _AT_CHECK_AC_MACRO(
150 [[AC_PROG_CPP
151 # If the preprocessor is not strict, just ignore
152 test "x$ac_c_preproc_warn_flag" = xyes &&
153 AC_MSG_ERROR([preprocessor has no warning option], 77)
154 CPP="./mycpp $CPP"
155 AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
156
157 AT_CHECK_DEFINES(
158 [/* #undef HAVE_AUTOCONF_IO_H */
159 #define HAVE_STDIO_H 1
160 ])
161
162 AT_CLEANUP
163
164
165 ## ------------------------------ ##
166 ## AC_PROG_CPP without warnings. ##
167 ## ------------------------------ ##
168
169 AT_SETUP([AC_PROG_CPP without warnings])
170
171 # Ignore if /lib/cpp doesn't work
172 AT_CHECK([/lib/cpp </dev/null || exit 77], [], [ignore], [ignore])
173
174 # A cpp which exit status is meaningless.
175 AT_DATA([mycpp],
176 [[#! /bin/sh
177 /lib/cpp ${1+"$@"}
178 exit 0
179 ]])
180
181 chmod +x mycpp
182
183 _AT_CHECK_AC_MACRO(
184 [[CPP=./mycpp
185 AC_PROG_CPP
186 test "x$ac_c_preproc_warn_flag" != xyes &&
187 AC_MSG_ERROR([failed to detect preprocessor warning option])
188 AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
189
190 AT_CHECK_DEFINES(
191 [/* #undef HAVE_AUTOCONF_IO_H */
192 #define HAVE_STDIO_H 1
193 ])
194
195 AT_CLEANUP
196
197
198
199 ## -------------------- ##
200 ## AC_PROG_CPP via CC. ##
201 ## -------------------- ##
202
203
204 # It's Ok for strict preprocessors to produce warnings.
205
206 AT_SETUP([AC_PROG_CPP via CC])
207
208 # Ignore if /lib/cpp doesn't work
209 AT_CHECK([/lib/cpp </dev/null || exit 77], [], [ignore], [ignore])
210
211 AT_DATA([mycc],
212 [[#! /bin/sh
213 echo "Annoying copyright message" >&2
214 exec "$@"
215 ]])
216
217 chmod +x mycc
218
219 # We go through the following contortions, in order to have the
220 # configure script go down the same codepaths as it would during a
221 # normal CPP selection check. If we explicitly set CPP, it goes down
222 # a different codepath.
223 _AT_CHECK_AC_MACRO(
224 [[AC_PROG_CC
225 CC="./mycc $CC"
226 AC_PROG_CPP
227 # The test $CC compiler should have been selected.
228 test "$CPP" != "$CC -E" &&
229 AC_MSG_ERROR([error messages on stderr cause the preprocessor selection to fail])
230
231 # Exercise CPP.
232 AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
233
234 AT_CHECK_DEFINES(
235 [/* #undef HAVE_AUTOCONF_IO_H */
236 #define HAVE_STDIO_H 1
237 ])
238
239 AT_CLEANUP
240
241
242 ## ------------------ ##
243 ## AC_TRY_LINK_FUNC. ##
244 ## ------------------ ##
245
246 AT_CHECK_MACRO([AC_TRY_LINK_FUNC],
247 [AC_TRY_LINK_FUNC(printf,,
248 [AC_MSG_ERROR([cannot find `printf'])])
249 AC_TRY_LINK_FUNC(Be_doomed_if_your_libc_has_a_function_named_like_this,
250 [AC_MSG_ERROR([found a nonexistent function])])])
251
252
253
254 ## --------------------- ##
255 ## Fortran 77 Compiler. ##
256 ## --------------------- ##
257
258
259 AT_CHECK_MACRO([GNU Fortran 77],
260 [[AC_LANG(Fortran 77)
261 AC_LANG_COMPILER
262
263 if AC_TRY_COMMAND([$F77 --version | grep GNU >&2]); then
264 # Be sure to remove files which might be created by compilers that
265 # don't support --version.
266 rm -f a.exe a.out
267 # Has GNU in --version.
268 test "$G77" != yes &&
269 AC_MSG_ERROR([failed to recognize GNU Fortran 77 compiler])
270 else
271 # Be sure to remove files which might be created by compilers that
272 # don't support --version.
273 rm -f a.exe a.out
274 # Has not.
275 test "$G77" = yes &&
276 AC_MSG_ERROR([incorrectly recognized a GNU Fortran 77 compiler])
277 fi]])