Tweak m4_wrap to force FIFO or LIFO semantics.
[autoconf.git] / tests / compile.at
blob8863c60ab57d4783fd8f7c0d2c2b6b61cf3a77ec
1 #                                                       -*- Autotest -*-
3 AT_BANNER([Low level compiling/preprocessing macros.])
5 # Copyright (C) 2000, 2001, 2003, 2005, 2006, 2007 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 ## 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],
34 [[AC_INIT
35 # C
36 AC_LANG(C)
37 # C
38 AC_LANG_PUSH(C)
39 # C C
40 AC_LANG_PUSH(C++)
41 # C++ C C
42 AC_LANG(C++)
43 # C++ C C
44 AC_LANG_PUSH(Fortran 77)
45 # F77 C++ C C
46 AC_LANG_POP(Fortran 77)
47 # C++ C C
48 AC_LANG(C++)
49 # C++ C C
50 AC_LANG_POP(C++)
51 # C C
52 AC_LANG_POP(C)
53 # C
54 ]])
56 AT_CHECK_AUTOCONF
57 AT_CHECK([sed -n 's/^ac_ext=//p' configure], 0,
61 cpp
62 cpp
64 cpp
65 cpp
70 AT_CLEANUP
73 ## ---------------------- ##
74 ## AC_REQUIRE & AC_LANG.  ##
75 ## ---------------------- ##
77 AT_SETUP([AC_REQUIRE & AC_LANG])
79 AT_DATA([configure.ac],
80 [[AC_DEFUN([AC_F77_1],
81 [AC_LANG_PUSH([Fortran 77])
82 if test $ac_ext != f; then
83   AC_MSG_ERROR([F77_1: current shell language is $ac_ext, expected Fortran])
85 AC_LANG_POP
89 AC_DEFUN([AC_F77_2],
90 [AC_LANG_PUSH([Fortran 77])
91 AC_REQUIRE([AC_F77_1])
92 if test $ac_ext != f; then
93   AC_MSG_ERROR([F77_2: current shell language is $ac_ext, expected Fortran])
95 AC_LANG_POP
98 AC_INIT
99 AC_F77_2
100 AS_EXIT(0)
103 AT_CHECK_AUTOCONF
104 AT_CHECK_CONFIGURE
106 AT_CLEANUP
109 ## --------------- ##
110 ## AC_RUN_IFELSE.  ##
111 ## --------------- ##
113 AT_SETUP([AC_RUN_IFELSE])
115 AT_DATA([configure.ac],
116 [[AC_INIT
118 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0])],
119               [],
120               [AC_MSG_ERROR([saw `return 0' as a failure])])
122 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 2])],
123               [AC_MSG_ERROR([saw `return 2' as a success])],
124               [status=$?
125 test $status != 2 &&
126   AC_MSG_ERROR([did not get as 2 exit status: $status])])
128 # The old stinky one.
129 AC_TRY_RUN([int main () { return 3; }],
130            [AC_MSG_ERROR([saw `return 3' as a success])],
131            [status=$?
132 test $status != 3 &&
133   AC_MSG_ERROR([did not get 3 as exit status: $status])])
137 AT_CHECK_AUTOCONF
138 AT_CHECK_CONFIGURE([-q])
140 AT_CLEANUP
142 ## ------------------ ##
143 ## AC_TRY_LINK_FUNC.  ##
144 ## ------------------ ##
146 AT_CHECK_MACRO([AC_TRY_LINK_FUNC],
147 [AC_TRY_LINK_FUNC(printf,,
148                   [AC_MSG_ERROR([cannot find `printf'])])
149 AC_TRY_LINK_FUNC(Be_doomed_if_your_libc_has_a_function_named_like_this,
150                  [AC_MSG_ERROR([found a nonexistent function])])])