3 AT_BANNER([Low level compiling/preprocessing macros.])
5 # Copyright (C) 2000, 2001, 2003, 2005, 2006, 2007, 2008, 2009, 2010
6 # Free 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 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 ## AC_LANG, AC_LANG_PUSH & AC_LANG_POP. ##
29 ## ------------------------------------- ##
31 AT_SETUP([[AC_LANG, AC_LANG_PUSH & AC_LANG_POP]])
33 AT_DATA([configure.ac],
44 AC_LANG_PUSH([Erlang])
46 AC_LANG_PUSH([Fortran 77])
48 AC_LANG_POP([Fortran 77])
61 AT_CHECK([sed -n 's/^ac_ext=//p' configure], 0,
79 ## ---------------------- ##
80 ## AC_REQUIRE & AC_LANG. ##
81 ## ---------------------- ##
83 AT_SETUP([AC_REQUIRE & AC_LANG])
85 AT_DATA([configure.ac],
86 [[AC_DEFUN([AC_F77_1],
87 [AC_LANG_PUSH([Fortran 77])
88 if test $ac_ext != f; then
89 AC_MSG_ERROR([F77_1: current shell language is $ac_ext, expected Fortran])
96 [AC_LANG_PUSH([Fortran 77])
97 AC_REQUIRE([AC_F77_1])
98 if test $ac_ext != f; then
99 AC_MSG_ERROR([F77_2: current shell language is $ac_ext, expected Fortran])
115 ## --------------- ##
117 ## --------------- ##
119 AT_SETUP([AC_RUN_IFELSE])
121 AT_DATA([configure.ac],
124 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0])],
126 [AC_MSG_ERROR([saw `return 0' as a failure])])
128 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 2])],
129 [AC_MSG_ERROR([saw `return 2' as a success])],
131 test $estatus != 2 &&
132 AC_MSG_ERROR([did not get as 2 exit status: $estatus])])
134 # The old stinky one.
135 AC_TRY_RUN([int main () { return 3; }],
136 [AC_MSG_ERROR([saw `return 3' as a success])],
138 test $estatus != 3 &&
139 AC_MSG_ERROR([did not get 3 as exit status: $estatus])])
144 AT_CHECK_CONFIGURE([-q])
148 ## -------------------------- ##
149 ## Order of `rm' and actions. ##
150 ## -------------------------- ##
152 AT_SETUP([Order of user actions and cleanup])
153 AT_DATA([configure.ac],
157 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([int ok;], [])],
158 [test -f conftest.err || AS_EXIT([1])],
160 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([#define 12 34], [])],
162 [test -f conftest.err || AS_EXIT([1])])
164 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int ok;], [])],
165 [test -f conftest.$ac_objext || AS_EXIT([1])],
167 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int bad bad;], [])],
169 [test -f conftest.err || AS_EXIT([1])])
171 AC_LINK_IFELSE([AC_LANG_PROGRAM([int ok;], [])],
172 [test -f conftest$ac_exeext || AS_EXIT([1])],
174 AC_LINK_IFELSE([AC_LANG_PROGRAM([int bad bad;], [])],
176 [test -f conftest.err || AS_EXIT([1])])
178 AC_RUN_IFELSE([AC_LANG_PROGRAM([int ok;], [])],
179 [./conftest$ac_exeext || AS_EXIT([1])],
182 d@&t@nl conftest.err not generated by AC_RUN_IFELSE?
183 AC_RUN_IFELSE([AC_LANG_PROGRAM([int bad bad;], [])],
189 AT_CHECK_CONFIGURE([-q])
194 ## ------------------ ##
195 ## AC_TRY_LINK_FUNC. ##
196 ## ------------------ ##
198 AT_CHECK_MACRO([AC_TRY_LINK_FUNC],
199 [AC_TRY_LINK_FUNC(printf,,
200 [AC_MSG_ERROR([cannot find `printf'])])
201 AC_TRY_LINK_FUNC(Be_doomed_if_your_libc_has_a_function_named_like_this,
202 [AC_MSG_ERROR([found a nonexistent function])])])
204 ## -------------------- ##
205 ## Multiple languages. ##
206 ## -------------------- ##
208 AT_SETUP([Multiple languages])
210 # This test should be skipped if the C compiler is a C++ compiler.
211 AT_DATA([configure.ac],
220 ]])], [], AS_EXIT([77]))
226 # This test should be skipped on systems without a C++ compiler.
227 AT_DATA([configure.ac],
237 ]])], [], AS_EXIT([77]))
244 AT_DATA([configure.ac],
251 AC_MSG_CHECKING([a simple C program that is not valid C++])
252 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([enum a { A, B, C };
253 enum a f(enum a in) { return in++; }], [])],
254 [AC_MSG_RESULT([ok])],
255 [AC_MSG_RESULT([failed])
256 AC_MSG_ERROR([could not compile test program])])
260 AC_MSG_CHECKING([a simple C++ program that is not valid C])
261 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([class A {};], [])],
262 [AC_MSG_RESULT([ok])],
263 [AC_MSG_RESULT([failed])
264 AC_MSG_ERROR([could not compile test program])])
266 AC_CHECK_HEADER([cstring])
271 AT_CHECK_CONFIGURE([-q])