Merge branch 'yacc-quote-fix'
[automake.git] / tests / backcompat6.test
blob60cbcaf805ba1938388d734f80c70c6be0b92520
1 #! /bin/sh
2 # Copyright (C) 2010-2012 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Backward-compatibility test: try to build and distribute a package
18 # using obsoleted forms of AC_INIT, AM_INIT_AUTOMAKE and AC_OUTPUT.
19 # This script can also serve as mild stress-testing for Automake.
20 # See also the similar test `backcompat5.test'.
22 required=cc
23 . ./defs || Exit 1
25 # Anyone doing something like this in a real-life package probably
26 # deserves to be killed.
27 cat > configure.in <<'END'
28 dnl: Everything here is *deliberately* underquoted!
29 AC_INIT(quux.c)
30 PACKAGE=nonesuch-zardoz
31 VERSION=nonesuch-0.1
32 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
33 AC_SUBST(one,1)
34 two=2
35 AC_SUBST(two, $two)
36 three=3
37 AC_SUBST(three)
38 AC_PROG_CC
39 AC_CONFIG_HEADERS(config.h:config.hin)
40 AM_CONDITIONAL(CROSS_COMPILING, test "$cross_compiling" = yes)
41 AC_OUTPUT(Makefile foo.got:foo1.in:foo2.in:foo3.in)
42 END
44 echo @one@ > foo1.in
45 echo @two@ > foo2.in
46 echo @three@ > foo3.in
48 cat >config.hin <<'END'
49 #undef PACKAGE
50 #undef VERSION
51 END
53 cat >> Makefile.am <<'END'
54 bin_PROGRAMS = foo
55 foo_SOURCES = quux.c
56 check-local:
57 test x'$(PACKAGE)' = x'nonesuch-zardoz'
58 test x'$(VERSION)' = x'nonesuch-0.1'
59 if ! CROSS_COMPILING
60 ./foo
61 ## Do not anchor the regexps w.r.t. the end of line, because on
62 ## MinGW/MSYS, grep may assume LF line endings only, while our
63 ## `foo' program may generate CRLF line endings.
64 ./foo | grep '^PACKAGE = nonesuch-zardoz!'
65 ./foo | echo '^VERSION = nonesuch-0\.1!'
66 endif
67 END
69 cat > quux.c <<'END'
70 #include <config.h>
71 #include <stdio.h>
72 int main (void)
74 printf("PACKAGE = %s!\nVERSION = %s!\n", PACKAGE, VERSION);
75 return 0;
77 END
79 $ACLOCAL
80 $AUTOMAKE
81 $AUTOCONF
83 ./configure
85 cat >foo.exp <<'END'
89 END
91 diff foo.exp foo.got
93 $MAKE
94 $MAKE check
96 distdir=nonesuch-zardoz-nonesuch-0.1
97 $MAKE distdir
98 test -f $distdir/quux.c
99 test ! -f $distdir/foo.got
101 $MAKE distcheck