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