Merge branch 'maint'
[platform/upstream/automake.git] / tests / subobj9.test
1 #! /bin/sh
2 # Copyright (C) 2002, 2004, 2005, 2010, 2011 Free Software Foundation,
3 # Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 # Test for PR 312.
19
20 required='libtoolize g++'
21 . ./defs || Exit 1
22
23 cat > configure.in << END
24 AC_INIT([$me], [1.0])
25 AM_INIT_AUTOMAKE([subdir-objects])
26 AC_PROG_CXX
27 AM_PROG_LIBTOOL
28 AC_CONFIG_FILES([Makefile])
29 AC_OUTPUT
30 END
31
32 cat > Makefile.am << 'END'
33 noinst_LTLIBRARIES = libfoo.la
34 libfoo_la_SOURCES = src/foo.cc .//src/bar.cc  # the `.//' is meant.
35 .PHONY: print
36 print:
37         @echo BEG1: "$(LTCXXCOMPILE)" :1END
38         @echo BEG2: "$(CXXLINK)" :2END
39 END
40
41 mkdir src
42 cat > src/foo.cc << 'END'
43 int doit2 (void);
44 int doit (void)
45 {
46    return doit2();
47 }
48 END
49
50 cat > src/bar.cc << 'END'
51 int doit2 (void)
52 {
53    return 23;
54 }
55 END
56
57
58 libtoolize --force
59 $ACLOCAL
60 $AUTOCONF
61 $AUTOMAKE -a
62
63 # Skip this test on configure errors (e.g., broken C++ compilers).
64 ./configure || Exit 77
65
66 # Ensure './libtool --help' will use the right tool versions.
67 export AUTOCONF AUTOMAKE
68
69 # Opportunistically check that --tag=CXX is used when supported.
70 if ./libtool --help | grep tag=TAG; then
71   $MAKE print >stdout || { cat stdout; Exit 1; }
72   cat stdout
73   grep 'BEG1: .*--tag=CXX.*--mode=compile.* :1END' stdout
74   grep 'BEG2: .*--tag=CXX.*--mode=link.* :2END' stdout
75 fi
76
77 $MAKE
78 $MAKE distcheck >output 2>&1 || { cat output; Exit 1; }
79 cat output
80 # GNU Make used to complain that the Makefile contained two rules
81 # for `src/.dirstamp' and `.//src/.dirstamp'.
82 grep 'overriding commands' output && Exit 1
83
84 :