* lib/autoconf/c.m4 (AC_PROG_GCC_TRADITIONAL, AC_C_CONST):
[autoconf/tsuna.git] / tests / compile.at
bloba7d61392242b97cc5c4bc01efb1ee9eabe65dd0b
1 #                                                       -*- Autotest -*-
3 AT_BANNER([Low level compiling/preprocessing macros.])
5 # Copyright (C) 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301, USA.
23 # Since the macros which compile are required by most tests, check
24 # them first.  But remember that looking for a compiler is even more
25 # primitive, so check those first.
28 ## ------------------------------------- ##
29 ## AC_LANG, AC_LANG_PUSH & AC_LANG_POP.  ##
30 ## ------------------------------------- ##
32 AT_SETUP([AC_LANG, AC_LANG_PUSH & AC_LANG_POP])
34 AT_DATA([configure.ac],
35 [[AC_INIT
36 # C
37 AC_LANG(C)
38 # C
39 AC_LANG_PUSH(C)
40 # C C
41 AC_LANG_PUSH(C++)
42 # C++ C C
43 AC_LANG(C++)
44 # C++ C C
45 AC_LANG_PUSH(Fortran 77)
46 # F77 C++ C C
47 AC_LANG_POP(Fortran 77)
48 # C++ C C
49 AC_LANG(C++)
50 # C++ C C
51 AC_LANG_POP(C++)
52 # C C
53 AC_LANG_POP(C)
54 # C
55 ]])
57 AT_CHECK_AUTOCONF
58 AT_CHECK([sed -n 's/^ac_ext=//p' configure], 0,
62 cpp
63 cpp
65 cpp
66 cpp
71 AT_CLEANUP
74 ## ---------------------- ##
75 ## AC_REQUIRE & AC_LANG.  ##
76 ## ---------------------- ##
78 AT_SETUP([AC_REQUIRE & AC_LANG])
80 AT_DATA([configure.ac],
81 [[AC_DEFUN([AC_F77_1],
82 [AC_LANG_PUSH([Fortran 77])
83 if test $ac_ext != f; then
84   AC_MSG_ERROR([F77_1: current shell language is $ac_ext, expected Fortran])
86 AC_LANG_POP
90 AC_DEFUN([AC_F77_2],
91 [AC_LANG_PUSH([Fortran 77])
92 AC_REQUIRE([AC_F77_1])
93 if test $ac_ext != f; then
94   AC_MSG_ERROR([F77_2: current shell language is $ac_ext, expected Fortran])
96 AC_LANG_POP
99 AC_INIT
100 AC_F77_2
101 AS_EXIT(0)
104 AT_CHECK_AUTOCONF
105 AT_CHECK_CONFIGURE
107 AT_CLEANUP
110 ## --------------- ##
111 ## AC_RUN_IFELSE.  ##
112 ## --------------- ##
114 AT_SETUP([AC_RUN_IFELSE])
116 AT_DATA([configure.ac],
117 [[AC_INIT
119 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0])],
120               [],
121               [AC_MSG_ERROR([saw `return 0' as a failure])])
123 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 2])],
124               [AC_MSG_ERROR([saw `return 2' as a success])],
125               [status=$?
126 test $status != 2 &&
127   AC_MSG_ERROR([did not get as 2 exit status: $status])])
129 # The old stinky one.
130 AC_TRY_RUN([int main () { return 3; }],
131            [AC_MSG_ERROR([saw `return 3' as a success])],
132            [status=$?
133 test $status != 3 &&
134   AC_MSG_ERROR([did not get 3 as exit status: $status])])
138 AT_CHECK_AUTOCONF
139 AT_CHECK_CONFIGURE([-q])
141 AT_CLEANUP
143 ## ------------------ ##
144 ## AC_TRY_LINK_FUNC.  ##
145 ## ------------------ ##
147 AT_CHECK_MACRO([AC_TRY_LINK_FUNC],
148 [AC_TRY_LINK_FUNC(printf,,
149                   [AC_MSG_ERROR([cannot find `printf'])])
150 AC_TRY_LINK_FUNC(Be_doomed_if_your_libc_has_a_function_named_like_this,
151                  [AC_MSG_ERROR([found a nonexistent function])])])