Merge branch 'master' into testsuite-work
[platform/upstream/automake.git] / tests / suffix8.tap
1 #! /bin/sh
2 # Copyright (C) 2002, 2003, 2010, 2011 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 to make sure Automake supports multiple derivations for the
18 # same suffix.
19 # From PR/37.
20
21 required='cc libtoolize'
22 . ./defs || Exit 1
23
24 plan_ 10
25
26 cat >>configure.in <<'END'
27 AM_PROG_AR
28 AM_PROG_LIBTOOL
29 AC_OUTPUT
30 END
31
32 cat >Makefile.am << 'END'
33 # $(LINK) is not defined automatically by Automake, since the *_SOURCES
34 # variables don't contain any known extension (.c, .cc, .f ...),
35 # So we need this hack.
36 LINK = :
37
38 bin_PROGRAMS = foo
39 lib_LTLIBRARIES = libfoo.la
40
41 foo_SOURCES = foo.x_
42 libfoo_la_SOURCES = bar.x_
43
44 # The elaborate cp commands below account for VPATH issues on
45 # weaker make implementations (e.g. IRIX 6.5).
46 .x_.y_:
47         cp `test -f '$<' || echo $(srcdir)/`$< $@
48 .y_.o:
49         cp `test -f '$<' || echo $(srcdir)/`$< $@
50 .y_.z_:
51         cp `test -f '$<' || echo $(srcdir)/`$< $@
52 .z_.lo:
53         cp `test -f '$<' || echo $(srcdir)/`$< $@
54
55 # Some make implementations don't remove intermediate files
56 # automatically, thus causing "make distcheck" to fail if
57 # this is not added.
58 MOSTLYCLEANFILES = *.y_ *.z_
59
60 .PHONY: test0 test1 test2
61 test0:
62         echo $(foo_OBJECTS) | grep '^foo\.foo$$'
63         echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
64 test1:
65         echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT)$$'
66         echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
67 test2: $(foo_OBJECTS) $(libfoo_la_OBJECTS)
68         test -f foo.$(OBJEXT)
69         test -f bar.lo
70 check-local: test1 test2
71 END
72
73 echo 'int main (void) { return 0; }' > foo.x_
74 echo 'int bar (void) { return 0; }' > bar.x_
75
76 command_ok_ "libtoolize" libtoolize
77 command_ok_ "aclocal"    $ACLOCAL
78 command_ok_ "autoconf"   $AUTOCONF
79 command_ok_ "automake"   $AUTOMAKE -a
80 command_ok_ "configure"  ./configure
81 command_ok_ "make test0" env OBJEXT=foo $MAKE -e test0
82 command_ok_ "make test1" $MAKE test1
83
84 directive=''; make_can_chain_suffix_rules || directive=TODO
85
86 for target in test2 all distcheck; do
87   command_ok_ "make $target"  \
88               -D "$directive" -r "suffix rules not chained" \
89               $MAKE $target
90 done
91
92 :