maint: run "make update-copyright"
[platform/upstream/automake.git] / tests / backcompat5.test
1 #! /bin/sh
2 # Copyright (C) 2010-2012 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 <http://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 # This script can also serve as mild stress-testing for Automake.
20 # See also the similar test `backcompat6.test'.
21
22 am_parallel_tests=no
23 . ./defs || Exit 1
24
25 # Yuck!
26 cat > configure.in <<'END'
27 dnl: Everything here is *deliberately* underquoted!
28 AC_INIT(src/foo.input)
29 AM_INIT_AUTOMAKE(foo, 1.0)
30 AC_CONFIG_FILES(Makefile:mkfile.in)
31 AC_OUTPUT(hacky/Makefile src/Makefile data/Makefile tests/Makefile)
32 END
33
34 distdir=foo-1.0
35
36 cat > mkfile.am <<'END'
37 SUBDIRS = src data tests hacky
38 installcheck-local:
39         grep DataDataData $(DESTDIR)$(prefix)/data/$(PACKAGE)-$(VERSION)/bar
40 END
41
42 mkdir hacky src tests data
43
44 echo 'This is a dummy package' > README
45
46 cat > src/foo.input <<'END'
47 #!sh
48 echo Zardoz
49 END
50
51 cat > tests/a.test <<'END'
52 #!/bin/sh
53 "$srcdir/../src/foo" | grep Zardoz
54 END
55 chmod a+x tests/a.test
56
57 cat > data/bar <<'END'
58 line1
59 line2
60 line3
61 END
62
63 cat >hacky/Makefile.am <<'END'
64 dist-hook:
65         find $(top_distdir) -print
66         chmod a+rx $(top_distdir)/tests/*.test
67 END
68
69 cat > src/Makefile.am <<'END'
70 dist_bin_SCRIPTS = foo
71 foo: foo.input
72         sed '1s,^#!.*$$,#!/bin/sh,' $(srcdir)/foo.input >$@
73         chmod a+x $@
74 EXTRA_DIST = foo.input
75 DISTCLEANFILES = foo
76 END
77
78 cat > data/Makefile.am <<'END'
79 nodist_data_DATA = bar
80 datadir = $(prefix)/data/$(PACKAGE)-$(VERSION)
81 bar:
82         echo DataDataData >$@
83 distclean-local:
84         rm -f bar
85 END
86
87 cat > tests/Makefile.am <<'END'
88 TESTS = a.test
89 EXTRA_DIST = $(TESTS)
90 END
91
92 $ACLOCAL
93 $AUTOCONF
94 $AUTOMAKE
95
96 ./configure
97 ls -l . hacky src data tests # For debugging.
98 test ! -f mkfile
99 $MAKE
100 $MAKE distdir
101 test ! -f $distdir/Makefile.in
102 test ! -f $distdir/data/bar
103 test -f $distdir/src/foo
104 diff README $distdir/README
105 diff mkfile.in $distdir/mkfile.in
106 diff tests/a.test $distdir/tests/a.test
107 diff src/foo.input $distdir/src/foo.input
108
109 $MAKE check
110 $MAKE distcheck
111
112 test -f $distdir.tar.gz
113
114 chmod a-x tests/a.test
115 # dist-hook should take care of making test files executables.
116 $MAKE distcheck
117
118 :