test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / silent-gen.sh
1 #!/bin/sh
2 # Copyright (C) 2009-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 # Silent rules: use of pre-defined variables $(AM_V_GEN) and $(AM_V_at).
18 # Incidentally, also check that silent rules are disabled by default.
19
20 . test-init.sh
21
22 echo AC_OUTPUT >> configure.ac
23
24 cat > Makefile.am <<'EOF'
25 all-local: foo
26
27 ## And here's how you should do it in your own code:
28 foo: foo.in
29         $(AM_V_GEN)cp $(srcdir)/foo.in $@
30         $(AM_V_at)echo more >> $@
31
32 EXTRA_DIST = foo.in
33 CLEANFILES = foo
34 EOF
35
36 : >foo.in
37
38 $ACLOCAL
39 $AUTOMAKE --add-missing
40 $AUTOCONF
41
42 # Silent rules are disabled by default, since we haven't called
43 # "AM_SILENT_RULES([yes])" explicitly.
44 ./configure
45 run_make -O
46 grep 'GEN ' stdout && exit 1
47 grep 'cp ' stdout
48 grep 'echo ' stdout
49
50 $MAKE clean
51 run_make -O V=1
52 grep 'GEN ' stdout && exit 1
53 grep 'cp ' stdout
54 grep 'echo ' stdout
55
56 $MAKE clean
57 run_make -O V=0
58 grep 'GEN .*foo' stdout
59 grep 'cp ' stdout && exit 1
60 grep 'echo ' stdout && exit 1
61
62 $MAKE distclean
63
64 ./configure --enable-silent-rules
65 run_make -O
66 grep 'GEN .*foo' stdout
67 grep 'cp ' stdout && exit 1
68 grep 'echo ' stdout && exit 1
69
70 $MAKE clean
71 run_make -O V=0
72 grep 'GEN .*foo' stdout
73 grep 'cp ' stdout && exit 1
74 grep 'echo ' stdout && exit 1
75
76 $MAKE clean
77 run_make -O V=1
78 grep 'GEN ' stdout && exit 1
79 grep 'cp ' stdout
80 grep 'echo ' stdout
81
82 :