Merge branch 'maint'
[platform/upstream/automake.git] / t / silentcxx-gcc.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 requires the GNU C++ compiler; keep it in sync with sister
19 # test 'silentcxx.test', which should work with generic compilers.
20
21 required=g++
22 . ./defs || exit 1
23
24 mkdir sub
25
26 cat >>configure.ac <<'EOF'
27 AC_PROG_CXX
28 AC_CONFIG_FILES([sub/Makefile])
29 AC_OUTPUT
30 EOF
31
32 cat > Makefile.am <<'EOF'
33 # Need generic and non-generic rules.
34 bin_PROGRAMS = foo1 foo2
35 foo1_SOURCES = foo.cpp baz.cxx quux.cc
36 foo2_SOURCES = $(foo1_SOURCES)
37 foo2_CXXFLAGS = $(AM_CXXFLAGS)
38 SUBDIRS = sub
39 EOF
40
41 cat > sub/Makefile.am <<'EOF'
42 AUTOMAKE_OPTIONS = subdir-objects
43 # Need generic and non-generic rules.
44 bin_PROGRAMS = bar1 bar2
45 bar1_SOURCES = bar.cpp
46 bar2_SOURCES = $(bar1_SOURCES)
47 bar2_CXXFLAGS = $(AM_CXXFLAGS)
48 EOF
49
50 cat > foo.cpp <<'EOF'
51 using namespace std; /* C compilers fail on this. */
52 int main() { return 0; }
53 EOF
54
55 # Let's try out other extensions too.
56 echo 'class Baz  { public: int i;  };' > baz.cxx
57 echo 'class Quux { public: bool b; };' > quux.cc
58
59 cp foo.cpp sub/bar.cpp
60
61 $ACLOCAL
62 $AUTOMAKE --add-missing
63 $AUTOCONF
64
65 # Sanity check: make sure the cache variable we force is really used
66 # by configure.
67 $FGREP am_cv_CXX_dependencies_compiler_type configure
68
69 # Force gcc ("fast") depmode.
70 # This apparently useless "for" loop is here to simplify the syncing
71 # with sister test 'silentcxx.test'.
72 for config_args in \
73   am_cv_CXX_dependencies_compiler_type=gcc
74 do
75   ./configure $config_args --enable-silent-rules
76   $MAKE >stdout || { cat stdout; exit 1; }
77   cat stdout
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   $MAKE V=1 >stdout || { cat stdout; exit 1; }
95   cat stdout
96
97   grep ' -c ' stdout
98   grep ' -o ' stdout
99
100   $EGREP '(CC|CXX|LD) ' stdout && exit 1
101
102   # Ensure a clean reconfiguration/rebuild.
103   $MAKE clean
104   $MAKE maintainer-clean
105
106 done
107
108 :