tests: expose automake bug#13940
[platform/upstream/automake.git] / t / silent-cxx.sh
1 #!/bin/sh
2 # Copyright (C) 2010-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 silent-rules mode for C++, both with and without automatic
18 # dependency tracking.
19
20 required=c++
21 . test-init.sh
22
23 mkdir sub
24
25 cat >>configure.ac <<'EOF'
26 AC_PROG_CXX
27 AC_CONFIG_FILES([sub/Makefile])
28 AC_OUTPUT
29 EOF
30
31 cat > Makefile.am <<'EOF'
32 # Need generic and non-generic rules.
33 bin_PROGRAMS = foo1 foo2
34 foo1_SOURCES = foo.cpp baz.cxx quux.cc
35 foo2_SOURCES = $(foo1_SOURCES)
36 foo2_CXXFLAGS = $(AM_CXXFLAGS)
37 SUBDIRS = sub
38 EOF
39
40 cat > sub/Makefile.am <<'EOF'
41 AUTOMAKE_OPTIONS = subdir-objects
42 # Need generic and non-generic rules.
43 bin_PROGRAMS = bar1 bar2
44 bar1_SOURCES = bar.cpp
45 bar2_SOURCES = $(bar1_SOURCES)
46 bar2_CXXFLAGS = $(AM_CXXFLAGS)
47 EOF
48
49 cat > foo.cpp <<'EOF'
50 using namespace std; /* C compilers fail on this. */
51 int main (void) { return 0; }
52 EOF
53
54 # Let's try out other extensions too.
55 echo 'class Baz  { public: int i;  };' > baz.cxx
56 echo 'class Quux { public: bool b; };' > quux.cc
57
58 cp foo.cpp sub/bar.cpp
59
60 $ACLOCAL
61 $AUTOMAKE --add-missing
62 $AUTOCONF
63
64 # Sanity check: make sure the cache variable we force is really used
65 # by configure.
66 $FGREP am_cv_CXX_dependencies_compiler_type configure
67
68 # Force dependency tracking explicitly, so that slow dependency
69 # extractors are not rejected.  Try also with dependency tracking
70 # explicitly disabled.
71 for config_args in \
72   --enable-dependency-tracking --disable-dependency-tracking
73 do
74
75   ./configure $config_args --enable-silent-rules
76
77   run_make -O
78
79   $EGREP ' (-c|-o)' stdout && exit 1
80   grep 'mv ' stdout && exit 1
81
82   grep 'CXX .*foo\.'  stdout
83   grep 'CXX .*baz\.'  stdout
84   grep 'CXX .*quux\.' stdout
85   grep 'CXX .*bar\.'  stdout
86   grep 'CXXLD .*foo1' stdout
87   grep 'CXXLD .*bar1' stdout
88   grep 'CXXLD .*foo2' stdout
89   grep 'CXXLD .*bar2' stdout
90
91   # Ensure a clean rebuild.
92   $MAKE clean
93
94   run_make -O V=1
95
96   grep ' -c ' stdout
97   grep ' -o ' stdout
98
99   $EGREP '(CXX|LD) ' stdout && exit 1
100
101   # Ensure a clean reconfiguration/rebuild.
102   $MAKE clean
103   $MAKE maintainer-clean
104
105 done
106
107 :