tests: never source test-defs.sh directly, source test-lib.sh instead
[automake.git] / t / backcompat6.sh
blobf7e8937622622c38f88911796075654e1e5c8d7a
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 am_create_testdir=empty
24 . ./defs || exit 1
26 # Anyone doing something like this in a real-life package probably
27 # deserves to be killed.
28 cat > configure.in <<'END'
29 dnl: Everything here is *deliberately* underquoted!
30 AC_INIT(quux.c)
31 PACKAGE=nonesuch-zardoz
32 VERSION=nonesuch-0.1
33 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
34 AC_SUBST(one,1)
35 two=2
36 AC_SUBST(two, $two)
37 three=3
38 AC_SUBST(three)
39 AC_PROG_CC
40 AC_CONFIG_HEADERS(config.h:config.hin)
41 AM_CONDITIONAL(CROSS_COMPILING, test "$cross_compiling" = yes)
42 AC_OUTPUT(Makefile foo.got:foo1.in:foo2.in:foo3.in)
43 END
45 echo @one@ > foo1.in
46 echo @two@ > foo2.in
47 echo @three@ > foo3.in
49 cat >config.hin <<'END'
50 #undef PACKAGE
51 #undef VERSION
52 END
54 cat >> Makefile.am <<'END'
55 bin_PROGRAMS = foo
56 foo_SOURCES = quux.c
57 check-local:
58 test x'$(PACKAGE)' = x'nonesuch-zardoz'
59 test x'$(VERSION)' = x'nonesuch-0.1'
60 if ! CROSS_COMPILING
61 ./foo
62 ## Do not anchor the regexps w.r.t. the end of line, because on
63 ## MinGW/MSYS, grep may assume LF line endings only, while our
64 ## 'foo' program may generate CRLF line endings.
65 ./foo | grep '^PACKAGE = nonesuch-zardoz!'
66 ./foo | echo '^VERSION = nonesuch-0\.1!'
67 endif
68 END
70 cat > quux.c <<'END'
71 #include <config.h>
72 #include <stdio.h>
73 int main (void)
75 printf("PACKAGE = %s!\nVERSION = %s!\n", PACKAGE, VERSION);
76 return 0;
78 END
80 $ACLOCAL
81 $AUTOMAKE -Wno-obsolete --add-missing
82 $AUTOCONF
84 ./configure
86 cat >foo.exp <<'END'
90 END
92 diff foo.exp foo.got
94 $MAKE
95 $MAKE check
97 distdir=nonesuch-zardoz-nonesuch-0.1
98 $MAKE distdir
99 test -f $distdir/quux.c
100 test ! -e $distdir/foo.got
102 $MAKE distcheck