Fix autoheader 2.62 regression on AC_DEFINE([__EXTENSIONS__]).
[autoconf/ericb.git] / tests / c.at
blobbc07c6ebc5e45f49a4de48ecfe58c17d5c681292
1 #                                                       -*- Autotest -*-
3 AT_BANNER([C low level compiling/preprocessing macros.])
5 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 Free
6 # Software Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 # 02110-1301, USA.
24 # Since the macros which compile are required by most tests, check
25 # them first.  But remember that looking for a compiler is even more
26 # primitive, so check those first.
29 ## ------------ ##
30 ## Extensions.  ##
31 ## ------------ ##
33 # As far as we know only `foo', `foo.exe' are possible executable,
34 # and `foo.o', `foo.obj' are possible object files.  Autoconf must not
35 # know that, but it is OK for the test suite to take this into account.
36 AT_CHECK_MACRO([Extensions],
37 [[AC_PROG_CC
38 case $ac_exeext in
39   '' | '.exe' ) ;;
40   * ) AC_MSG_ERROR([suspicious executable suffix: $ac_exeext]);;
41 esac
43 case $ac_objext in
44   'o' | 'obj' ) ;;
45   * ) AC_MSG_ERROR([suspicious object suffix: $ac_objext]);;
46 esac
47 ]])
51 ## -------------------------- ##
52 ## Broken/missing compilers.  ##
53 ## -------------------------- ##
56 # Check that Autoconf correctly diagnoses broken compilers, and in
57 # particular, if it does not exit 77, the test suite is in trouble...
58 # FIXME: Once a precise message decided, check stderr of configure.
59 AT_SETUP([Broken/missing compilers])
61 AT_DATA([configure.ac],
62 [[AC_INIT
63 CC=no-such-compiler
64 AC_PROG_CC
65 ]])
67 AT_CHECK_AUTOCONF
68 AT_CHECK_CONFIGURE([], 77, ignore, ignore)
70 AT_CLEANUP
73 ## ------------ ##
74 ## C keywords.  ##
75 ## ------------ ##
77 # GCC supports `const', `typeof', and `volatile'.
78 AT_CHECK_MACRO([C keywords],
79 [[AC_PROG_CC
80 AC_C_CONST
81 AC_C_TYPEOF
82 AC_C_VOLATILE
83 case $GCC,$ac_cv_c_const,$ac_cv_c_typeof,$ac_cv_c_volatile in
84  yes,*no*)
85    AC_MSG_ERROR([failed to detect `const', `typeof', or `volatile' support]);;
86 esac
87 ]])
91 ## --------------------------------- ##
92 ## AC_PROG_CPP requires AC_PROG_CC.  ##
93 ## --------------------------------- ##
95 # Must invoke AC_PROG_CC.
96 AT_CHECK_MACRO([AC_PROG_CPP requires AC_PROG_CC],
97 [[AC_PROG_CPP
98 test -z "$CC" &&
99    AC_MSG_ERROR([looked for a C preprocessor without looking for a compiler])
104 ## --------------------------- ##
105 ## AC_PROG_CPP with warnings.  ##
106 ## --------------------------- ##
109 # It's Ok for strict preprocessors to produce warnings.
111 AT_SETUP([AC_PROG_CPP with warnings])
113 AT_DATA([mycpp],
114 [[#! /bin/sh
115 echo noise >&2
116 exec "$@"
119 chmod +x mycpp
121 _AT_CHECK_AC_MACRO(
122 [[AC_PROG_CPP
123 # If the preprocessor is not strict, just ignore
124 test "x$ac_c_preproc_warn_flag" = xyes &&
125   AC_MSG_ERROR([preprocessor has no warning option], 77)
126 CPP="./mycpp $CPP"
127 AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
129 AT_CHECK_DEFINES(
130 [/* #undef HAVE_AUTOCONF_IO_H */
131 #define HAVE_STDIO_H 1
134 AT_CLEANUP
137 ## ------------------------------ ##
138 ## AC_PROG_CPP without warnings.  ##
139 ## ------------------------------ ##
141 AT_SETUP([AC_PROG_CPP without warnings])
143 # Ignore if /lib/cpp doesn't work
144 AT_CHECK([[echo '#include <stdio.h>' | /lib/cpp || exit 77]],
145   [], [ignore], [ignore])
147 # A cpp which exit status is meaningless.
148 AT_DATA([mycpp],
149 [[#! /bin/sh
150 /lib/cpp "$@"
151 exit 0
154 chmod +x mycpp
156 _AT_CHECK_AC_MACRO(
157 [[CPP=./mycpp
158 AC_PROG_CPP
159 test "x$ac_c_preproc_warn_flag" != xyes &&
160   AC_MSG_ERROR([failed to detect preprocessor warning option])
161 AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
163 AT_CHECK_DEFINES(
164 [/* #undef HAVE_AUTOCONF_IO_H */
165 #define HAVE_STDIO_H 1
168 AT_CLEANUP
172 ## -------------------- ##
173 ## AC_PROG_CPP via CC.  ##
174 ## -------------------- ##
177 # It's Ok for strict preprocessors to produce warnings.
179 AT_SETUP([AC_PROG_CPP via CC])
181 # Ignore if /lib/cpp doesn't work
182 AT_CHECK([[echo '#include <stdio.h>' | /lib/cpp || exit 77]],
183   [], [ignore], [ignore])
185 AT_DATA([mycc],
186 [[#! /bin/sh
187 echo "Annoying copyright message" >&2
188 exec "$@"
191 chmod +x mycc
193 # We go through the following contortions, in order to have the
194 # configure script go down the same codepaths as it would during a
195 # normal CPP selection check.  If we explicitly set CPP, it goes down
196 # a different codepath.
197 _AT_CHECK_AC_MACRO(
198 [[AC_PROG_CC
199 CC="./mycc $CC"
200 AC_PROG_CPP
201 # The test $CC compiler should have been selected.
202 test "$CPP" != "$CC -E" &&
203   AC_MSG_ERROR([error messages on stderr cause the preprocessor selection to fail])
205 # Exercise CPP.
206 AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
208 AT_CHECK_DEFINES(
209 [/* #undef HAVE_AUTOCONF_IO_H */
210 #define HAVE_STDIO_H 1
213 AT_CLEANUP
216 ## ------------------------------------ ##
217 ## AC_NO_EXECUTABLES (working linker).  ##
218 ## ------------------------------------ ##
220 AT_CHECK_MACRO([AC_NO_EXECUTABLES (working linker)],
221 [AC_NO_EXECUTABLES
222 AC_PROG_CC
226 ## ----------------------------------- ##
227 ## AC_NO_EXECUTABLES (broken linker).  ##
228 ## ----------------------------------- ##
230 AT_CHECK_MACRO([AC_NO_EXECUTABLES (broken linker)],
231 [LDFLAGS=-lnosuchlibrary
232 AC_NO_EXECUTABLES
233 AC_PROG_CC
237 ## -------------------------- ##
238 ## AC_USE_SYSTEM_EXTENSIONS.  ##
239 ## -------------------------- ##
241 AT_SETUP([AC_USE_SYSTEM_EXTENSIONS])
243 # Some existing configure.ac mixed AC_AIX (now an alias for
244 # AC_USE_SYSTEM_EXTENSIONS) and AC_DEFINE([__EXTENSIONS__]), which
245 # broke autoheader in 2.62.  Test that this is supported.
247 _AT_CHECK_AC_MACRO(
248 [[AC_AIX
249 AC_DEFINE([__EXTENSIONS__], [1], [Manually defined for Solaris])
252 _AT_CHECK_AC_MACRO(
253 [[AC_USE_SYSTEM_EXTENSIONS
254 AC_DEFINE([__EXTENSIONS__], [1], [Manually defined for Solaris])
257 AT_CLEANUP