test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / suffix8.tap
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 to make sure Automake supports multiple derivations for the
18 # same suffix.
19 # From PR/37.
20
21 required='cc libtoolize'
22 . test-init.sh
23
24 plan_ 10
25
26 cat >>configure.ac <<'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_.obj:
51         cp `test -f '$<' || echo $(srcdir)/`$< $@
52 .y_.z_:
53         cp `test -f '$<' || echo $(srcdir)/`$< $@
54 .z_.lo:
55         cp `test -f '$<' || echo $(srcdir)/`$< $@
56
57 # Some make implementations don't remove intermediate files
58 # automatically, thus causing "make distcheck" to fail if
59 # this is not added.
60 MOSTLYCLEANFILES = *.y_ *.z_
61
62 .PHONY: test0 test1 test2
63 test0:
64         echo $(foo_OBJECTS) | grep '^foo\.foo$$'
65         echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
66 test1:
67         echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT)$$'
68         echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
69 test2: $(foo_OBJECTS) $(libfoo_la_OBJECTS)
70         test -f foo.$(OBJEXT)
71         test -f bar.lo
72 check-local: test1 test2
73 END
74
75 echo 'int main (void) { return 0; }' > foo.x_
76 echo 'int bar (void) { return 0; }' > bar.x_
77
78 # We must protect the TAP driver from the output of configure, since
79 # that might output a stray "ok" on a line of its own (due to a
80 # libtool bug on Mac OS X), thus causing a spurious test result to
81 # be seen.  See automake bug#11897.
82 protect_output ()
83 {
84   st=0; "$@" >output 2>&1 || st=1
85   sed 's/^/  /' output
86   test $st -eq 0
87 }
88
89 command_ok_ "libtoolize" libtoolize
90 command_ok_ "aclocal"    $ACLOCAL
91 command_ok_ "autoconf"   $AUTOCONF
92 command_ok_ "automake"   $AUTOMAKE -a
93 command_ok_ "configure"  protect_output ./configure
94 command_ok_ "make test0" run_make OBJEXT=foo test0
95 command_ok_ "make test1" $MAKE test1
96
97 directive=''; make_can_chain_suffix_rules || directive=TODO
98
99 for target in test2 all distcheck; do
100   command_ok_ "make $target"  \
101               -D "$directive" -r "suffix rules not chained" \
102               protect_output $MAKE $target
103 done
104
105 :