tests: avoid a spurious failure on MSYS
[platform/upstream/automake.git] / t / subobj9.sh
1 #! /bin/sh
2 # Copyright (C) 2002-2013 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 # Test for PR 312.
18 #
19 # == Report ==
20 # When using non-recursive make to build a libtoolize-library from
21 # sources in a subdirectory, 'make distcheck' fails because of incomplete
22 # cleanup. "make clean" tries to remove '*.o' and '.../<file>.lo' but
23 # forgets '.../<file>.o'.
24
25 required='c++ libtoolize'
26 . test-init.sh
27
28 cat > configure.ac << END
29 AC_INIT([$me], [1.0])
30 AM_INIT_AUTOMAKE([subdir-objects])
31 AC_PROG_CXX
32 AM_PROG_AR
33 AM_PROG_LIBTOOL
34 AC_CONFIG_FILES([Makefile])
35 AC_OUTPUT
36 END
37
38 cat > Makefile.am << 'END'
39 noinst_LTLIBRARIES = libfoo.la
40 libfoo_la_SOURCES = src/foo.cc .//src/bar.cc  # The './/' is meant.
41 .PHONY: print
42 print:
43         @echo BEG1: "$(LTCXXCOMPILE)" :1END
44         @echo BEG2: "$(CXXLINK)" :2END
45 END
46
47 mkdir src
48 cat > src/foo.cc << 'END'
49 int doit2 (void);
50 int doit (void)
51 {
52    return doit2();
53 }
54 END
55
56 cat > src/bar.cc << 'END'
57 int doit2 (void)
58 {
59    return 23;
60 }
61 END
62
63
64 libtoolize --force
65 $ACLOCAL
66 $AUTOCONF
67 $AUTOMAKE -a
68
69 ./configure
70
71 # Ensure './libtool --help' will use the right tool versions.
72 export AUTOCONF AUTOMAKE
73
74 # Opportunistically check that --tag=CXX is used when supported.
75 if ./libtool --help | grep tag=TAG; then
76   run_make -O print
77   grep 'BEG1: .*--tag=CXX.*--mode=compile.* :1END' stdout
78   grep 'BEG2: .*--tag=CXX.*--mode=link.* :2END' stdout
79 fi
80
81 $MAKE
82 run_make -M distcheck
83 # GNU Make used to complain that the Makefile contained two rules
84 # for 'src/.dirstamp' and './/src/.dirstamp'.
85 grep 'overriding commands' output && exit 1
86
87 :