test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / subdir-distclean.sh
1 #! /bin/sh
2 # Copyright (C) 2012-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 # Check that "./configure && make && make distclean" is actually a
18 # no-op, even when conditional SUBDIRS are involved.
19
20 . test-init.sh
21
22 cat >> configure.ac << 'END'
23 AC_CONFIG_FILES([sub1/Makefile sub2/Makefile sub1/subsub/Makefile])
24 AM_CONDITIONAL([COND], [false])
25 AC_SUBST([extra_subdirs], [''])
26 AC_OUTPUT
27 END
28
29 mkdir sub1 sub2 sub1/subsub
30
31 cat > Makefile.am << 'END'
32 SUBDIRS = sub1
33 if COND
34 SUBDIRS += sub2
35 endif
36 END
37
38 cat > sub1/Makefile.am << 'END'
39 all-local:
40         : > run
41 CLEANFILES = run
42 SUBDIRS = @extra_subdirs@
43 DIST_SUBDIRS = subsub
44 END
45
46 cat > sub2/Makefile.am << 'END'
47 all-local:
48         @echo "Should not run in `pwd`!"
49         exit 1
50 DISTCLEANFILES = oops
51 END
52 cp sub2/Makefile.am sub1/subsub/Makefile.am
53
54 $ACLOCAL
55 $AUTOCONF
56 $AUTOMAKE -c --add-missing
57
58 ./configure
59
60 test -f sub1/Makefile
61 test -f sub2/Makefile
62 test -f sub1/subsub/Makefile
63
64 $MAKE
65 test -f sub1/run
66 touch sub2/oops sub1/subsub/oops
67
68 $MAKE distclean
69 test ! -e sub1/run
70 test ! -e sub2/oops
71 test ! -e sub1/subsub/oops
72 test ! -e sub1/Makefile
73 test ! -e sub2/Makefile
74 test ! -e sub1/subsub/Makefile
75
76 mkdir build
77 cd build
78
79 ../configure
80
81 $MAKE
82
83 test -f sub1/Makefile
84 test -f sub2/Makefile
85 test -f sub1/subsub/Makefile
86
87 test -f sub1/run
88 touch sub2/oops sub1/subsub/oops
89
90 $MAKE maintainer-clean
91 test ! -e sub1/run
92 test ! -e sub2/oops
93 test ! -e sub1/subsub/oops
94 test ! -e sub1/Makefile
95 test ! -e sub2/Makefile
96 test ! -e sub1/subsub/Makefile
97
98 cd ..
99
100 ./configure
101 $MAKE distclean
102
103 :