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