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