test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / backcompat6.sh
blob1fbeb859acaa0be4e7cb56f2200f889e4adbff77
1 #! /bin/sh
2 # Copyright (C) 2010-2024 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 <https://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 # and 'configure.in' as autconf input file.
20 # This script can also serve as mild stress-testing for Automake.
21 # See also the similar test 'backcompat5.test'.
23 required=cc
24 am_create_testdir=empty
25 . test-init.sh
27 # Anyone doing something like this in a real-life package probably
28 # deserves to be killed.
29 cat > configure.ac <<'END'
30 dnl: Everything here is *deliberately* underquoted!
31 AC_INIT(quux.c)
32 PACKAGE=nonesuch-zardoz
33 VERSION=nonesuch-0.1
34 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
35 AC_SUBST(one,1)
36 two=2
37 AC_SUBST(two, $two)
38 three=3
39 AC_SUBST(three)
40 AC_PROG_CC
41 AM_CONFIG_HEADER(config.h:config.hin)
42 AM_CONDITIONAL(CROSS_COMPILING, test "$cross_compiling" = yes)
43 AC_OUTPUT(Makefile foo.got:foo1.in:foo2.in:foo3.in)
44 END
46 echo @one@ > foo1.in
47 echo @two@ > foo2.in
48 echo @three@ > foo3.in
50 cat >config.hin <<'END'
51 #undef PACKAGE
52 #undef VERSION
53 END
55 cat >> Makefile.am <<'END'
56 bin_PROGRAMS = foo
57 foo_SOURCES = quux.c
58 check-local:
59 test x'$(PACKAGE)' = x'nonesuch-zardoz'
60 test x'$(VERSION)' = x'nonesuch-0.1'
61 if ! CROSS_COMPILING
62 ./foo
63 ## Do not anchor the regexps w.r.t. the end of line, because on
64 ## MinGW/MSYS, grep may assume LF line endings only, while our
65 ## 'foo' program may generate CRLF line endings.
66 ./foo | grep '^PACKAGE = nonesuch-zardoz!'
67 ./foo | echo '^VERSION = nonesuch-0\.1!'
68 endif
69 END
71 cat > quux.c <<'END'
72 #include <config.h>
73 #include <stdio.h>
74 int main (void)
76 printf("PACKAGE = %s!\nVERSION = %s!\n", PACKAGE, VERSION);
77 return 0;
79 END
81 $ACLOCAL -Wno-obsolete
82 $AUTOMAKE -Wno-obsolete --add-missing
83 $AUTOCONF
85 ./configure
87 cat >foo.exp <<'END'
91 END
93 diff foo.exp foo.got
95 $MAKE
96 $MAKE check
98 distdir=nonesuch-zardoz-nonesuch-0.1
99 $MAKE distdir
100 test -f $distdir/quux.c
101 test ! -f $distdir/foo.got
103 $MAKE distcheck