Merge branch 'fix-half-pr14760' into micro
[platform/upstream/automake.git] / t / silent-custom.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 # Check user extensibility of silent-rules mode.
18
19 . test-init.sh
20
21 cat >>configure.ac <<'EOF'
22 AC_CONFIG_FILES([sub/Makefile])
23 AC_OUTPUT
24 EOF
25
26 # We delegate all the work to the subdir makefile.  This is done
27 # to ensure any command-line setting of $(V) gets correctly passed
28 # down to recursive make invocations.
29 echo SUBDIRS = sub > Makefile.am
30
31 mkdir sub
32 cat > sub/Makefile.am <<'EOF'
33 AUTOMAKE_OPTIONS = -Wno-portability-recursive
34 my_verbose = $(my_verbose_$(V))
35 my_verbose_ = $(my_verbose_$(AM_DEFAULT_VERBOSITY))
36 my_verbose_0 = @echo " XGEN    $@";
37
38 all-local: foo gen-headers
39
40 list = 0 1 2
41 .PHONY: gen-headers
42 gen-headers:
43         @headers=`for i in $(list); do echo sub/$$i.h; done`; \
44         if $(AM_V_P); then set -x; else \
45           echo " GEN     [headers]"; \
46         fi; \
47         rm -f $$headers || exit 1; \
48 ## Only fake header generation.
49         : generate-header --flags $$headers
50
51 foo: foo.in
52         $(my_verbose)cp $(srcdir)/foo.in $@
53 EXTRA_DIST = foo.in
54 CLEANFILES = foo
55 EOF
56
57 : > sub/foo.in
58
59 $ACLOCAL
60 $AUTOMAKE --add-missing
61 $AUTOCONF
62
63 do_check ()
64 {
65   case ${1-} in
66     --silent) silent=:;;
67     --verbose) silent=false;;
68     *) fatal_ "do_check(): incorrect usage";;
69   esac
70   shift
71   $MAKE clean
72   run_make -M -- ${1+"$@"}
73   if $silent; then
74     $FGREP 'cp ' output && exit 1
75     $FGREP 'generate-header' output && exit 1
76     $FGREP 'rm -f' output && exit 1
77     grep '[012]\.h' output && exit 1
78     grep '^ XGEN    foo$' output
79     grep '^ GEN     \[headers\]$' output
80   else
81     $FGREP 'GEN ' output && exit 1
82     $FGREP 'cp ./foo.in foo' output
83     # Be prepared to handle "creative quoting" in the shell traces.
84     # See automake bug#14760.
85     ok=false
86     for q in '' \' \"; do
87       files="${q}sub/0.h${q} ${q}sub/1.h${q} ${q}sub/2.h${q}"
88       $FGREP "rm -f $files" output || continue
89       $FGREP "generate-header --flags $files" output || continue
90       ok=:
91       break
92     done
93     $ok || exit 1
94     unset ok
95   fi
96 }
97
98 ./configure --enable-silent-rules
99 do_check --silent
100 do_check --verbose V=1
101
102 $MAKE distclean
103
104 ./configure --disable-silent-rules
105 do_check --verbose
106 do_check --silent V=0
107
108 $MAKE distclean
109
110 :