Improve documentation of config.h.in template rules.
[autoconf/ericb.git] / tests / compile.at
blob715fde880c1cc6cb111ef5165497c515b0b03eba
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 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 ## AC_LANG, AC_LANG_PUSH & AC_LANG_POP.  ##
31 ## ------------------------------------- ##
33 AT_SETUP([[AC_LANG, AC_LANG_PUSH & AC_LANG_POP]])
35 AT_DATA([configure.ac],
36 [[AC_INIT
37 # C
38 AC_LANG(C)
39 # C
40 AC_LANG_PUSH(C)
41 # C C
42 AC_LANG_PUSH(C++)
43 # C++ C C
44 AC_LANG(C++)
45 # C++ C C
46 AC_LANG_PUSH(Fortran 77)
47 # F77 C++ C C
48 AC_LANG_POP(Fortran 77)
49 # C++ C C
50 AC_LANG(C++)
51 # C++ C C
52 AC_LANG_POP(C++)
53 # C C
54 AC_LANG_POP(C)
55 # C
56 ]])
58 AT_CHECK_AUTOCONF
59 AT_CHECK([sed -n 's/^ac_ext=//p' configure], 0,
63 cpp
64 cpp
66 cpp
67 cpp
72 AT_CLEANUP
75 ## ---------------------- ##
76 ## AC_REQUIRE & AC_LANG.  ##
77 ## ---------------------- ##
79 AT_SETUP([AC_REQUIRE & AC_LANG])
81 AT_DATA([configure.ac],
82 [[AC_DEFUN([AC_F77_1],
83 [AC_LANG_PUSH([Fortran 77])
84 if test $ac_ext != f; then
85   AC_MSG_ERROR([F77_1: current shell language is $ac_ext, expected Fortran])
87 AC_LANG_POP
91 AC_DEFUN([AC_F77_2],
92 [AC_LANG_PUSH([Fortran 77])
93 AC_REQUIRE([AC_F77_1])
94 if test $ac_ext != f; then
95   AC_MSG_ERROR([F77_2: current shell language is $ac_ext, expected Fortran])
97 AC_LANG_POP
100 AC_INIT
101 AC_F77_2
102 AS_EXIT(0)
105 AT_CHECK_AUTOCONF
106 AT_CHECK_CONFIGURE
108 AT_CLEANUP
111 ## --------------- ##
112 ## AC_RUN_IFELSE.  ##
113 ## --------------- ##
115 AT_SETUP([AC_RUN_IFELSE])
117 AT_DATA([configure.ac],
118 [[AC_INIT
120 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0])],
121               [],
122               [AC_MSG_ERROR([saw `return 0' as a failure])])
124 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 2])],
125               [AC_MSG_ERROR([saw `return 2' as a success])],
126               [status=$?
127 test $status != 2 &&
128   AC_MSG_ERROR([did not get as 2 exit status: $status])])
130 # The old stinky one.
131 AC_TRY_RUN([int main () { return 3; }],
132            [AC_MSG_ERROR([saw `return 3' as a success])],
133            [status=$?
134 test $status != 3 &&
135   AC_MSG_ERROR([did not get 3 as exit status: $status])])
139 AT_CHECK_AUTOCONF
140 AT_CHECK_CONFIGURE([-q])
142 AT_CLEANUP
144 ## ------------------ ##
145 ## AC_TRY_LINK_FUNC.  ##
146 ## ------------------ ##
148 AT_CHECK_MACRO([AC_TRY_LINK_FUNC],
149 [AC_TRY_LINK_FUNC(printf,,
150                   [AC_MSG_ERROR([cannot find `printf'])])
151 AC_TRY_LINK_FUNC(Be_doomed_if_your_libc_has_a_function_named_like_this,
152                  [AC_MSG_ERROR([found a nonexistent function])])])