test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / maintclean-vpath.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 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 # Make sure distclean and maintainer-clean erase the right files.
18 # This test is for VPATH builds; see sister test 'maintclean.sh'
19 # for in-tree builds.
20
21 . test-init.sh
22
23 cat >> configure.ac << 'END'
24 AC_CONFIG_FILES([bar sub/Makefile])
25 AC_OUTPUT
26 END
27
28 cat > Makefile.am <<'END'
29 SUBDIRS = sub
30 noinst_DATA = foo.c
31 foo.c:
32         touch foo.c
33 MAINTAINERCLEANFILES = foo.c
34 END
35
36 mkdir sub
37 cat > sub/Makefile.am <<'END'
38 noinst_SCRIPTS = zap
39 zap: zap.sh
40         cp $(srcdir)/zap.sh $@ && chmod a+x $@
41 MAINTAINERCLEANFILES = zap
42 END
43
44 : > bar.in
45 : > sub/zap.sh
46
47 $ACLOCAL
48 $AUTOCONF
49 $AUTOMAKE
50
51 # Users can disable autom4te.cache.
52 if test -d autom4te.cache; then
53   test_cache='test -d ../autom4te.cache'
54 else
55   test_cache=:
56 fi
57
58 mkdir build
59
60 chmod a-w . sub
61
62 cd build
63
64 ../configure
65 test -f bar
66
67 $MAKE
68 test -f foo.c
69 test -f sub/zap
70 $test_cache
71
72 $MAKE distclean
73 test ! -e bar
74 test ! -e Makefile
75 test ! -e sub/Makefile
76 test ! -e config.status
77 test -f foo.c
78 test -f sub/zap
79 test -f ../sub/zap.sh
80 $test_cache
81
82 ../configure
83 test -f bar
84
85 $MAKE foo.c
86 test -f foo.c
87 cd sub
88 $MAKE zap
89 test -f zap
90 cd ..
91
92 chmod u+w ..
93
94 $MAKE maintainer-clean
95 test -f ../sub/zap.sh
96 test ! -e bar
97 test ! -e foo.c
98 test ! -e sub/zap
99 test ! -e Makefile
100 test ! -e sub/Makefile
101 test ! -e config.status
102 test ! -e ../autom4te.cache
103
104 :