Reword the copyright notices to match what's suggested in GPLv3.
[autoconf.git] / tests / c.at
blobe05a67c6aa27b6d5fc83784440671c5dd20d7aa4
1 #                                                       -*- Autotest -*-
3 AT_BANNER([C low level compiling/preprocessing macros.])
5 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
6 # 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 3 of the License, or
11 # (at your option) 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, see <http://www.gnu.org/licenses/>.
22 # Since the macros which compile are required by most tests, check
23 # them first.  But remember that looking for a compiler is even more
24 # primitive, so check those first.
27 ## ------------ ##
28 ## Extensions.  ##
29 ## ------------ ##
31 # As far as we know only `foo', `foo.exe' are possible executable,
32 # and `foo.o', `foo.obj' are possible object files.  Autoconf must not
33 # know that, but it is OK for the test suite to take this into account.
34 AT_CHECK_MACRO([Extensions],
35 [[AC_PROG_CC
36 case $ac_exeext in
37   '' | '.exe' ) ;;
38   * ) AC_MSG_ERROR([suspicious executable suffix: $ac_exeext]);;
39 esac
41 case $ac_objext in
42   'o' | 'obj' ) ;;
43   * ) AC_MSG_ERROR([suspicious object suffix: $ac_objext]);;
44 esac
45 ]])
49 ## -------------------------- ##
50 ## Broken/missing compilers.  ##
51 ## -------------------------- ##
54 # Check that Autoconf correctly diagnoses broken compilers, and in
55 # particular, if it does not exit 77, the test suite is in trouble...
56 # FIXME: Once a precise message decided, check stderr of configure.
57 AT_SETUP([Broken/missing compilers])
59 AT_DATA([configure.ac],
60 [[AC_INIT
61 CC=no-such-compiler
62 AC_PROG_CC
63 ]])
65 AT_CHECK_AUTOCONF
66 AT_CHECK_CONFIGURE([], 77, ignore, ignore)
68 AT_CLEANUP
71 ## ------------ ##
72 ## C keywords.  ##
73 ## ------------ ##
75 # GCC supports `const', `typeof', and `volatile'.
76 AT_CHECK_MACRO([C keywords],
77 [[AC_PROG_CC
78 AC_C_CONST
79 AC_C_TYPEOF
80 AC_C_VOLATILE
81 case $GCC,$ac_cv_c_const,$ac_cv_c_typeof,$ac_cv_c_volatile in
82  yes,*no*)
83    AC_MSG_ERROR([failed to detect `const', `typeof', or `volatile' support]);;
84 esac
85 ]])
89 ## --------------------------------- ##
90 ## AC_PROG_CPP requires AC_PROG_CC.  ##
91 ## --------------------------------- ##
93 # Must invoke AC_PROG_CC.
94 AT_CHECK_MACRO([AC_PROG_CPP requires AC_PROG_CC],
95 [[AC_PROG_CPP
96 test -z "$CC" &&
97    AC_MSG_ERROR([looked for a C preprocessor without looking for a compiler])
98 ]])
102 ## --------------------------- ##
103 ## AC_PROG_CPP with warnings.  ##
104 ## --------------------------- ##
107 # It's Ok for strict preprocessors to produce warnings.
109 AT_SETUP([AC_PROG_CPP with warnings])
111 AT_DATA([mycpp],
112 [[#! /bin/sh
113 echo noise >&2
114 exec "$@"
117 chmod +x mycpp
119 _AT_CHECK_AC_MACRO(
120 [[AC_PROG_CPP
121 # If the preprocessor is not strict, just ignore
122 test "x$ac_c_preproc_warn_flag" = xyes &&
123   AC_MSG_ERROR([preprocessor has no warning option], 77)
124 CPP="./mycpp $CPP"
125 AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
127 AT_CHECK_DEFINES(
128 [/* #undef HAVE_AUTOCONF_IO_H */
129 #define HAVE_STDIO_H 1
132 AT_CLEANUP
135 ## ------------------------------ ##
136 ## AC_PROG_CPP without warnings.  ##
137 ## ------------------------------ ##
139 AT_SETUP([AC_PROG_CPP without warnings])
141 # Ignore if /lib/cpp doesn't work
142 AT_CHECK([[echo '#include <stdio.h>' | /lib/cpp || exit 77]],
143   [], [ignore], [ignore])
145 # A cpp which exit status is meaningless.
146 AT_DATA([mycpp],
147 [[#! /bin/sh
148 /lib/cpp "$@"
149 exit 0
152 chmod +x mycpp
154 _AT_CHECK_AC_MACRO(
155 [[CPP=./mycpp
156 AC_PROG_CPP
157 test "x$ac_c_preproc_warn_flag" != xyes &&
158   AC_MSG_ERROR([failed to detect preprocessor warning option])
159 AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
161 AT_CHECK_DEFINES(
162 [/* #undef HAVE_AUTOCONF_IO_H */
163 #define HAVE_STDIO_H 1
166 AT_CLEANUP
170 ## -------------------- ##
171 ## AC_PROG_CPP via CC.  ##
172 ## -------------------- ##
175 # It's Ok for strict preprocessors to produce warnings.
177 AT_SETUP([AC_PROG_CPP via CC])
179 # Ignore if /lib/cpp doesn't work
180 AT_CHECK([[echo '#include <stdio.h>' | /lib/cpp || exit 77]],
181   [], [ignore], [ignore])
183 AT_DATA([mycc],
184 [[#! /bin/sh
185 echo "Annoying copyright message" >&2
186 exec "$@"
189 chmod +x mycc
191 # We go through the following contortions, in order to have the
192 # configure script go down the same codepaths as it would during a
193 # normal CPP selection check.  If we explicitly set CPP, it goes down
194 # a different codepath.
195 _AT_CHECK_AC_MACRO(
196 [[AC_PROG_CC
197 CC="./mycc $CC"
198 AC_PROG_CPP
199 # The test $CC compiler should have been selected.
200 test "$CPP" != "$CC -E" &&
201   AC_MSG_ERROR([error messages on stderr cause the preprocessor selection to fail])
203 # Exercise CPP.
204 AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
206 AT_CHECK_DEFINES(
207 [/* #undef HAVE_AUTOCONF_IO_H */
208 #define HAVE_STDIO_H 1
211 AT_CLEANUP