1#! /bin/sh
2# Copyright (C) 2010-2021 Free Software Foundation, Inc.
3#
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.
8#
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.
13#
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/>.
16
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'.
22
23required=cc
24am_create_testdir=empty
25. test-init.sh
26
27# Anyone doing something like this in a real-life package probably
28# deserves to be killed.
29cat > configure.ac <<'END'
30dnl: Everything here is *deliberately* underquoted!
31AC_INIT(quux.c)
32PACKAGE=nonesuch-zardoz
33VERSION=nonesuch-0.1
34AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
35AC_SUBST(one,1)
36two=2
37AC_SUBST(two, $two)
38three=3
39AC_SUBST(three)
40AC_PROG_CC
41AM_CONFIG_HEADER(config.h:config.hin)
42AM_CONDITIONAL(CROSS_COMPILING, test "$cross_compiling" = yes)
43AC_OUTPUT(Makefile foo.got:foo1.in:foo2.in:foo3.in)
44END
45
46echo @one@ > foo1.in
47echo @two@ > foo2.in
48echo @three@ > foo3.in
49
50cat >config.hin <<'END'
51#undef PACKAGE
52#undef VERSION
53END
54
55cat >> Makefile.am <<'END'
56bin_PROGRAMS = foo
57foo_SOURCES = quux.c
58check-local:
59	test x'$(PACKAGE)' = x'nonesuch-zardoz'
60	test x'$(VERSION)' = x'nonesuch-0.1'
61if ! 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!'
68endif
69END
70
71cat > quux.c <<'END'
72#include <config.h>
73#include <stdio.h>
74int main (void)
75{
76  printf("PACKAGE = %s!\nVERSION = %s!\n", PACKAGE, VERSION);
77  return 0;
78}
79END
80
81$ACLOCAL -Wno-obsolete
82$AUTOMAKE -Wno-obsolete --add-missing
83$AUTOCONF
84
85./configure
86
87cat >foo.exp <<'END'
881
892
903
91END
92
93diff foo.exp foo.got
94
95$MAKE
96$MAKE check
97
98distdir=nonesuch-zardoz-nonesuch-0.1
99$MAKE distdir
100test -f $distdir/quux.c
101test ! -f $distdir/foo.got
102
103$MAKE distcheck
104
105:
106