tests: make 'lzip.test' executable
[automake.git] / tests / silentcxx.test
blob40fc92e61fbd776a19c7a5ebd560f8d3fb7d0c8d
1 #!/bin/sh
2 # Copyright (C) 2010 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Check silent-rules mode for C++.
19 required='g++' # FIXME: any decent C++ compiler should be OK
20 . ./defs || Exit 1
22 set -e
24 mkdir sub
26 cat >>configure.in <<'EOF'
27 AM_SILENT_RULES
28 AC_PROG_CXX
29 AC_CONFIG_FILES([sub/Makefile])
30 AC_OUTPUT
31 EOF
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
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
51 cat > foo.cpp <<'EOF'
52 using namespace std; /* C compilers fail on this */
53 int main() { return 0; }
54 EOF
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
60 cp foo.cpp sub/bar.cpp
62 $ACLOCAL
63 $AUTOMAKE --add-missing
64 $AUTOCONF
66 # configure once for fastdep, once for non-fastdep, once for nodep
67 for config_args in \
68 '' \
69 am_cv_CC_dependencies_compiler_type=gcc \
70 --disable-dependency-tracking
72 ./configure $config_args --enable-silent-rules
73 $MAKE >stdout || { cat stdout; Exit 1; }
74 cat stdout
76 $EGREP ' (-c|-o)' stdout && Exit 1
77 grep 'mv ' stdout && Exit 1
79 grep 'CXX .*foo\.' stdout
80 grep 'CXX .*baz\.' stdout
81 grep 'CXX .*quux\.' stdout
82 grep 'CXX .*bar\.' stdout
83 grep 'CXXLD .*foo1' stdout
84 grep 'CXXLD .*bar1' stdout
85 grep 'CXXLD .*foo2' stdout
86 grep 'CXXLD .*bar2' stdout
88 # Ensure a clean rebuild.
89 $MAKE clean
91 $MAKE V=1 >stdout || { cat stdout; Exit 1; }
92 cat stdout
94 grep ' -c ' stdout
95 grep ' -o ' stdout
97 $EGREP '(CC|CXX|LD) ' stdout && Exit 1
99 # Ensure a clean reconfiguration/rebuild.
100 $MAKE clean
101 $MAKE maintainer-clean
103 done