]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Improve and extend tests `suffix*.test'.
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 15 Oct 2010 15:37:38 +0000 (17:37 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 23 Dec 2010 20:32:09 +0000 (21:32 +0100)
* tests/suffix.test: Check that suffix rules for C compilation are
only included once.  Try also with a static library.
* tests/suffix2.test: Add a new grep to help potential debugging.
Do not run automake with the `--add-missing' options, since we
already create all the needed auxiliary files.  Try also *without*
the `no-dependencies' automake option.
* tests/suffix4.test: Make grepping of Makefile.in stricter.
* tests/suffix3.test: Rewritten to run also autoconf, ./configure
and make.
* tests/suffix5.test: Likewise.
* tests/suffix6.test: Fix botched recipe indentation (eight spaces
were used instead of a tabulation character).  Extend to check
that `.obj' is handled like `.$(OBJEXT)' (as is done for `.o').
Improved parsing & grepping of generated Makefile.in.  Other minor
fixes and improvements.
* tests/suffix10.test: Move some checks in Makefile.am.  Also run
"make all".
* tests/suffix12.test: Likewise, and account for VPATH issues in
weaker make implementations.
* tests/suffix11.test: Likewise.  Also, run "make distcheck", for
completeness, and related changes.
* tests/suffix8.test: Likewise.  Also, do not put `gcc' anymore
in $required.
* tests/suffix13.test: Do not use the `--force-missing' automake
option unnecessarily.
* tests/suffix6b.test: New test, semantic sister of `suffix6.test'.
* tests/suffix6c.test: Likewise.
* tests/Makefile.am (TESTS): Updated.

16 files changed:
ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/suffix.test
tests/suffix10.test
tests/suffix11.test
tests/suffix12.test
tests/suffix13.test
tests/suffix2.test
tests/suffix3.test
tests/suffix4.test
tests/suffix5.test
tests/suffix6.test
tests/suffix6b.test [new file with mode: 0755]
tests/suffix6c.test [new file with mode: 0755]
tests/suffix8.test

index 224c3e014689a81861d08db6c2068b0ad22d4925..a3076fae3db79488f20a9f56035eba46c2440564 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2010-12-23  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       Improve and extend tests `suffix*.test'.
+       * tests/suffix.test: Check that suffix rules for C compilation are
+       only included once.  Try also with a static library.
+       * tests/suffix2.test: Add a new grep to help potential debugging.
+       Do not run automake with the `--add-missing' options, since we
+       already create all the needed auxiliary files.  Try also *without*
+       the `no-dependencies' automake option.
+       * tests/suffix4.test: Make grepping of Makefile.in stricter.
+       * tests/suffix3.test: Rewritten to run also autoconf, ./configure
+       and make.
+       * tests/suffix5.test: Likewise.
+       * tests/suffix6.test: Fix botched recipe indentation (eight spaces
+       were used instead of a tabulation character).  Extend to check
+       that `.obj' is handled like `.$(OBJEXT)' (as is done for `.o').
+       Improved parsing & grepping of generated Makefile.in.  Other minor
+       fixes and improvements.
+       * tests/suffix10.test: Move some checks in Makefile.am.  Also run
+       "make all".
+       * tests/suffix12.test: Likewise, and account for VPATH issues in
+       weaker make implementations.
+       * tests/suffix11.test: Likewise.  Also, run "make distcheck", for
+       completeness, and related changes.
+       * tests/suffix8.test: Likewise.  Also, do not put `gcc' anymore
+       in $required.
+       * tests/suffix13.test: Do not use the `--force-missing' automake
+       option unnecessarily.
+       * tests/suffix6b.test: New test, semantic sister of `suffix6.test'.
+       * tests/suffix6c.test: Likewise.
+       * tests/Makefile.am (TESTS): Updated.
+
 2010-12-23  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
            Stefano Lattarini  <stefano.lattarini@gmail.com>
 
index 8842be389434b98f79006dd0add01f48a1ca4616..7b0a65ad66be99fb5d41ecc8cba39c5c59bcb81e 100644 (file)
@@ -715,6 +715,8 @@ suffix3.test \
 suffix4.test \
 suffix5.test \
 suffix6.test \
+suffix6b.test \
+suffix6c.test \
 suffix7.test \
 suffix8.test \
 suffix9.test \
index a9d1fd10a12897ed0b4cbe5a03e57c26b872f3c7..bc92de1767fc68e4eb6e917155cd8036cafccb8c 100644 (file)
@@ -982,6 +982,8 @@ suffix3.test \
 suffix4.test \
 suffix5.test \
 suffix6.test \
+suffix6b.test \
+suffix6c.test \
 suffix7.test \
 suffix8.test \
 suffix9.test \
index c790c66a46605c6fc16e839e64c25e0192359970..4e81366096a6db2f5016b33d498c886171119ad7 100755 (executable)
@@ -14,7 +14,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Make sure a suffix rule for C compilation is produced.
+# Make sure proper suffix rules for C compilation are produced, and
+# only once.
+# See also related test `suffix2.test'.
 
 . ./defs || Exit 1
 
@@ -22,18 +24,24 @@ set -e
 
 cat >> configure.in << 'END'
 AC_PROG_CC
+AC_PROG_RANLIB
 END
 
 cat > Makefile.am << 'END'
 noinst_PROGRAMS = foo
+noinst_LIBRARIES = libbar.a
 END
 
 $ACLOCAL
 
 $AUTOMAKE -i
-grep '^\.c\.o' Makefile.in
+grep '^ *\.c' Makefile.in # for debugging
+test `grep -c '^\.c\.o:' Makefile.in` -eq 1
+test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
 
 $AUTOMAKE
-grep '^\.c\.o' Makefile.in
+grep '^ *\.c' Makefile.in # for debugging
+test `grep -c '^\.c\.o:' Makefile.in` -eq 1
+test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
 
 :
index 131359c8fc58eff6c365650de4a195777213b72c..0398d89d2ec5d2f2fc7864da5a2c4d486bf0d43a 100755 (executable)
@@ -29,16 +29,31 @@ AC_PROG_LIBTOOL
 AC_OUTPUT
 EOF
 
-
 cat >Makefile.am << 'END'
 lib_LTLIBRARIES = libfoo.la
 libfoo_la_SOURCES = foo.x_
-
 .x_.y:
-       cp $< $@
+       rm -f $@ $@-t
+## the leading `:;' works around a bug in bash <= 3.2
+       :; { echo '/* autogenerated */' \
+         && echo '%{' \
+         && echo 'int yylex () {return 0;}' \
+         && echo 'void yyerror (char *s) {}' \
+         && echo '%}' \
+         && echo '%%' \
+         && echo 'WORD: "foo";' \
+         && echo '%%' \
+## account for VPATH issues on weaker make implementations
+         && cat `test -f $< || echo $(srcdir)/`$<; \
+       } > $@-t
+       mv -f $@-t $@
+.PHONY: test
+test:
+       echo $(libfoo_la_OBJECTS) | grep '^foo\.lo$$'
+END
 
-print:
-       echo BEGIN: $(libfoo_la_OBJECTS) :END
+cat > foo.x_ << 'END'
+int foo (void) { return yyparse(); }
 END
 
 libtoolize --force
@@ -47,9 +62,7 @@ $AUTOCONF
 $AUTOMAKE --add-missing
 
 ./configure
-
-$MAKE print >stdout || { cat stdout; Exit 1; }
-cat stdout
-grep 'BEGIN: foo.lo :END' stdout
+$MAKE test
+$MAKE all
 
 :
index 91d2cf4d38b97e62f64567c8e76ca6538ce0e07e..ec4f5a19712c4489c11f06c76a250a08fab39cbb 100755 (executable)
@@ -32,18 +32,30 @@ bin_PROGRAMS = foo bar baz
 foo_SOURCES = foo.x_
 bar_SOURCES = bar.y-z
 baz_SOURCES = baz1.x_ baz2.y-z
+
 .y-z.c .x_.c:
-       cp $< $@
-  .z_.c   .w_.x_ :
-       cp $< $@
+## account for VPATH issues on weaker make implementations (e.g. IRIX 6.5)
+       sed 's/INTEGER/int/g' `test -f $< || echo $(srcdir)/`$< >$@
+
+CLEANFILES = foo.c bar.c baz1.c baz2.c
 
-.PHONY: print
-print:
-       @echo BEGIN: $(foo_OBJECTS) :END
-       @echo BEGIN: $(bar_OBJECTS) :END
-       @echo BEGIN: $(baz_OBJECTS) :END
+.PHONY: test-real test-fake
+test-fake:
+       echo $(foo_OBJECTS) | grep '^foo\.foo$$'
+       echo $(bar_OBJECTS) | grep '^bar\.foo$$'
+       echo $(baz_OBJECTS) | grep '^baz1\.foo baz2\.foo$$'
+test-real:
+       echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT)$$'
+       echo $(bar_OBJECTS) | grep '^bar\.$(OBJEXT)$$'
+       echo $(baz_OBJECTS) | grep '^baz1\.$(OBJEXT) baz2\.$(OBJEXT)$$'
+check-local: test-real
 END
 
+echo 'INTEGER main(void) { return 0; }' > foo.x_
+echo 'INTEGER main(void) { return 0; }' > bar.y-z
+echo 'INTEGER main(void) { INTEGER baz(void); return baz(); }' > baz1.x_
+echo 'INTEGER baz(void) { return 0; }' > baz2.y-z
+
 $ACLOCAL
 $AUTOCONF
 
@@ -56,10 +68,9 @@ $AUTOMAKE -a -Wno-portability
 
 ./configure
 
-OBJEXT=foo $MAKE -e print >stdout || { cat stdout; Exit 1; }
-cat stdout
-$FGREP 'BEGIN: foo.foo :END' stdout
-$FGREP 'BEGIN: bar.foo :END' stdout
-$FGREP 'BEGIN: baz1.foo baz2.foo :END' stdout
+OBJEXT=foo $MAKE -e test-fake
+$MAKE test-real
+$MAKE
+$MAKE distcheck
 
 :
index 21089a549db78272a3758cc9ee838217d59878f4..40f7b3fdfcf42c5a499fc1b3ee854ad6f81431d8 100755 (executable)
@@ -31,14 +31,17 @@ AUTOMAKE_OPTIONS = subdir-objects
 SUFFIXES = .baz .o
 # we fake here:
 .baz.o:
-       cp $< $@
+       ## account for VPATH issues on weaker make implementations
+       cp `test -f $< || echo $(srcdir)/`$< $@
 
 bin_PROGRAMS = foo
 foo_SOURCES = foo.c sub/bar.baz
 
-.PHONY: print
-print:
-       @echo BEGIN: $(foo_OBJECTS) :END
+.PHONY: test-fake test-real
+test-fake:
+       echo $(foo_OBJECTS) | grep '^foo\.quux sub/bar\.quux$$'
+test-real:
+       echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT) sub/bar\.$(OBJEXT)$$'
 END
 
 mkdir sub
@@ -48,9 +51,10 @@ mkdir sub
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
+
 ./configure
-OBJEXT=OBJ $MAKE -e print >stdout || { cat stdout; Exit 1; }
-cat stdout
-$FGREP 'BEGIN: foo.OBJ sub/bar.OBJ :END' stdout
+
+OBJEXT=quux $MAKE -e test-fake
+$MAKE test-real
 
 :
index aa5a3edbf75ebd1594821d7a8cd8f549a0b28cea..d37643a757629193c877914b4d6885a4c536dbb3 100755 (executable)
@@ -70,7 +70,7 @@ $MAKE distclean
 
 sed '/subdir-objects/d' < Makefile.am > t
 mv -f t Makefile.am
-$AUTOMAKE --force
+$AUTOMAKE
 ./configure
 $MAKE
 $MAKE distcheck
index 405ce90c5ad98d6cd5bad13d1b4a7a14367eefd6..e2fd663e4a2b35577488bbbab8e3a0924f76f7bd 100755 (executable)
@@ -15,7 +15,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test to make sure .c.o rule is only included once.
+# Make sure proper suffix rules for C compilation are produced,
+# and only once, even for libtool libraries.
+# See also related test `suffix.test'.
 required=libtoolize
 
 . ./defs || Exit 1
@@ -28,7 +30,6 @@ AC_PROG_LIBTOOL
 END
 
 cat > Makefile.am << 'END'
-AUTOMAKE_OPTIONS = no-dependencies
 lib_LTLIBRARIES = libltdl.la
 libltdl_la_SOURCES = ltdl.c ltdl.h
 END
@@ -41,8 +42,14 @@ END
 : > config.sub
 
 $ACLOCAL
-$AUTOMAKE -a
 
+$AUTOMAKE -i
+grep '^ *\.c' Makefile.in # for debugging
+test `grep -c '^\.c\.o:' Makefile.in` -eq 1
+test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
+
+$AUTOMAKE
+grep '^ *\.c' Makefile.in # for debugging
 test `grep -c '^\.c\.o:' Makefile.in` -eq 1
 test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
 
index fc445bf51519fd056c04d3398c1ae084f10fc287..0ec457ef45bc7554cd5997bd133d3fa403821beb 100755 (executable)
@@ -22,24 +22,55 @@ set -e
 
 cat >> configure.in << 'END'
 AC_PROG_CXX
+AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
 SUFFIXES = .zoo
 .zoo.cc:
-       convert-zoo whatever
+       sed 's/INTEGER/int/g' `test -f $< || echo $(srcdir)/`$< >$@
 bin_PROGRAMS = foo
 foo_SOURCES = foo.zoo
+# This is required by "make distcheck".  The useless indirection is
+# reequired to avoid false positives by the grepping checks below.
+FOO = foo
+CLEANFILES = $(FOO).cc
 END
 
 $ACLOCAL
 $AUTOMAKE
 
 # The foo.cc intermediate step is implicit, it's a mistake if
-# Automake requires this file somewhere.
-$FGREP foo.cc Makefile.in && Exit 1
+# Automake requires this file somewhere.  Also, Automake should
+# not require the file `foo.c' anywhere.
+$FGREP foo.c Makefile.in && Exit 1
 # However Automake must figure that foo.zoo is eventually
 # transformed into foo.o, and use this latter file (to link foo).
 $FGREP 'foo.$(OBJEXT)' Makefile.in
 
+$AUTOCONF
+./configure
+
+# This is deliberately valid C++, but invalid C.
+cat > foo.zoo <<'END'
+#include <iostream>
+using namespace std;
+INTEGER main(void)
+{
+  return 0;
+}
+END
+
+$MAKE
+# FIXME: should we check that intermediate file `foo.cc' has
+# been removed?  Or is this requiring too much from the make
+# implementation?
+
+# Intermediate files should not be distributed.
+$MAKE distdir
+test ! -r $me-1.0/foo.cc
+
+# Check the distribution.
+$MAKE distcheck
+
 :
index e95228315df784fa7976482e8a8d7f7c653faf76..b83c28097027c05515a9d13f0f111005ada9e1a2 100755 (executable)
@@ -34,6 +34,8 @@ END
 
 $ACLOCAL
 $AUTOMAKE
-grep '.SUFFIXES:.*\.k' Makefile.in
+grep '^\.SUFFIXES:' Makefile.in | sed -e 's/$/ /' > suffixes
+cat suffixes
+$FGREP ' .k ' suffixes
 
 :
index b3b36aaea5fbf657250acdcb3909359cf2df4ae8..f661620d86f9a932c2d76f7f8dae9a96499fe7ba 100755 (executable)
@@ -24,23 +24,41 @@ required=libtool
 set -e
 
 cat >> configure.in << 'END'
+AC_SUBST([LINK], [:])
 AC_PROG_LIBTOOL
+AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
 .k.lo:
-       echo $< > $@
+## account for VPATH issues on weaker make implementations
+       (echo $< && cat `test -f $< || echo $(srcdir)/`$<) > $@
 
 noinst_LTLIBRARIES = libfoo.la
 libfoo_la_SOURCES = foo.k
+
+.PHONY: test
+test: all
+       grep '^=GREP=ME=$$' foo.lo
+## weaker regex to account for VPATH issues
+       grep 'foo\.k$$' foo.lo
+check-local: test
 END
 
 : > ltmain.sh
-: > config.guess
-: > config.sub
+
+cp "$testsrcdir/../lib/config.guess" "$testsrcdir/../lib/config.sub" .
 
 $ACLOCAL
 $AUTOMAKE
 grep '_OBJECTS.*foo\.lo' Makefile.in
 
+$AUTOCONF
+./configure
+
+echo '=GREP=ME=' > foo.k
+
+$MAKE test
+$MAKE distcheck
+
 :
index ab7cf645976f6ff042c6882121d11c1c886e59da..7bfabb34195c889e2fad4ae80ff0eb8b2374d087 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test to make sure Automake supports implicit rules with dot-less
-# extensions.  Also make sure that `.o' is handled like `.$(OBJEXT)'.
+# extensions.  Also make sure that `.o' and `.obj' are handled like
+# `.$(OBJEXT)'.  See also related "semantic" tests suffix6b.test
+# and suffix6c.test.
 
 . ./defs || Exit 1
 
 set -e
 
 cat > Makefile.am << 'END'
-SUFFIXES = a b .$(OBJEXT) c .o
+SUFFIXES = a b .$(OBJEXT) c .o .obj
 bin_PROGRAMS = foo
-foo_SOURCES = fooa fuc
+foo_SOURCES = fooa barc bazc
 ab:
-        cp $< $@
+       dummy action 1
 b.$(OBJEXT):
-       cp $< $@
+       dummy action 2
 c.o:
-       cp $< $@
+       dummy action C
+c.obj:
+       dummy action C
 END
 
 $ACLOCAL
 $AUTOMAKE
 
+sed -n -e '/foo_OBJECTS *=.*\\$/ {
+  :loop
+  p
+  n
+  t clear
+  :clear
+  s/\\$/\\/
+  t loop
+  p
+  n
+}' -e 's/$/ /' -e 's/^.*foo_OBJECTS *= */ /p' Makefile.in > foo-objects
+cat foo-objects
+
 # Automake must figure that fooa translates to foo.$(OBJEXT) and
 # foo.$(OBJEXT) using the following rules:
 #  fooa --[ab]--> foob --[b.$(OBJEXT)]--> foo.$(OBJEXT)
-grep '_OBJECTS.* foo\.\$(OBJEXT)' Makefile.in
-#  fuc --[c.o]--> fu.$(OBJEXT)  ## This is really meant !
-grep '_OBJECTS.* fu\.\$(OBJEXT)' Makefile.in
+$FGREP ' foo.$(OBJEXT) ' foo-objects
+#  barc --[c.o]--> bar.$(OBJEXT)    ## This is really meant !
+$FGREP ' bar.$(OBJEXT) ' foo-objects
+#  bazc --[c.obj]--> baz.$(OBJEXT)  ## This is really meant !
+$FGREP ' baz.$(OBJEXT) ' foo-objects
 
 :
diff --git a/tests/suffix6b.test b/tests/suffix6b.test
new file mode 100755 (executable)
index 0000000..a96c941
--- /dev/null
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2001, 2002, 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test to make sure Automake supports implicit rules with dot-less
+# extensions.  Se also related "grepping" test suffix6.test.
+
+required=GNUmake # other makes might not grok dot-less suffix rules
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+# $(LINK) is not defined automatically by Automake, since the *_SOURCES
+# variables don't contain any known extension (.c, .cc, .f ...),
+# So we need this hack -- but since such an hack can also serve as a
+# mild stress test, that's ok.
+AC_SUBST([LINK], ['cat >$@'])
+AC_SUBST([OBJEXT], [oOo])
+AC_SUBST([EXEEXT], [.XxX])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUFFIXES = a b c .$(OBJEXT)
+bin_PROGRAMS = foo
+foo_SOURCES = fooa
+ab:
+       { echo '=ab=' && cat $<; } >$@
+bc:
+       { echo '=bc=' && cat $<; } >$@
+c.$(OBJEXT):
+       { echo '=b.obj=' && cat $<; } >$@
+test:
+       : for debugging
+       ls -l
+       : implicit intermediate files should be removed by GNU make
+       test ! -r foob
+       test ! -r fooc
+       : but object files should not
+       cat foo.$(OBJEXT)
+       : for debugging
+       cat foo.XxX
+       : now check that the chain of implicit rules has been executed
+       : completely and in the correct order
+       (echo =b.obj= && echo =bc= && echo =ab= && echo =src=) > exp
+       diff exp foo.XxX
+       rm -f exp
+.PHONY: test
+check-local: test
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+echo =src= > fooa
+
+$MAKE
+$MAKE test
+$MAKE distcheck
+
+:
diff --git a/tests/suffix6c.test b/tests/suffix6c.test
new file mode 100755 (executable)
index 0000000..e4b84cc
--- /dev/null
@@ -0,0 +1,92 @@
+#! /bin/sh
+# Copyright (C) 2001, 2002, 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test to make sure that `.o' and `.obj' are handled like `.$(OBJEXT)'.
+# See also related "grepping" test suffix6.test.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+# $(LINK) is not defined automatically by Automake, since the *_SOURCES
+# variables don't contain any known extension (.c, .cc, .f ...),
+# So we need this hack -- but since such an hack can also serve as a
+# mild stress test, that's ok.
+OBJEXT=${OBJEXT-oOo}
+AC_SUBST([LINK], ['cat >$@'])
+AC_SUBST([EXEEXT], [.XxX])
+AC_SUBST([OBJEXT])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUFFIXES = .zoo .o .obj .@OBJEXT@
+
+bin_PROGRAMS = foo
+foo_SOURCES = foo.zoo
+
+.zoo.o:
+       { echo '=.zoo.o=' && cat $<; } >$@
+.zoo.obj:
+       { echo '=.zoo.obj=' && cat $<; } >$@
+.zoo.@OBJEXT@:
+       { echo '=.zoo.@OBJEXT@=' && cat $<; } >$@
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+cat > foo.exp <<'END'
+=.zoo.oOo=
+%ONE%
+END
+echo %ONE% > foo.zoo
+$MAKE
+cat foo.oOo
+cat foo.XxX
+diff foo.XxX foo.exp
+
+rm -f foo.* exp
+
+cat > foo.exp <<'END'
+=.zoo.o=
+%TWO%
+END
+echo %TWO% > foo.zoo
+OBJEXT=o $MAKE -e
+cat foo.o
+cat foo.XxX
+diff foo.XxX foo.exp
+
+rm -f foo.* exp
+
+cat > foo.exp <<'END'
+=.zoo.obj=
+%THREE%
+END
+echo %THREE% > foo.zoo
+OBJEXT=obj $MAKE -e
+cat foo.obj
+cat foo.XxX
+diff foo.XxX foo.exp
+
+rm -f foo.* exp
+
+:
index 70ff3a5906e281c526a1b7c24789cff71104701b..8760d7bd28f9e98b67d1055d39294e6971883e73 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test to make sure Automake supports multiple derivations for the same suffix.
-# PR/37
+# Test to make sure Automake supports multiple derivations for the
+# same suffix.
+# From PR/37.
 
-required='gcc libtoolize'
+required=libtoolize
 . ./defs || Exit 1
 
 set -e
@@ -28,41 +29,48 @@ AC_OUTPUT
 END
 
 cat >Makefile.am << 'END'
+# $(LINK) is not defined automatically by Automake, since the *_SOURCES
+# variables don't contain any known extension (.c, .cc, .f ...),
+# So we need this hack.
+LINK = :
+
 bin_PROGRAMS = foo
 lib_LTLIBRARIES = libfoo.la
 
 foo_SOURCES = foo.x_
 libfoo_la_SOURCES = bar.x_
 
+# The elaborate cp commands below account for VPATH issues on
+# weaker make implementations (e.g. IRIX 6.5).
 .x_.y_:
-       cp $< $@
-
+       cp `test -f $< || echo $(srcdir)/`$< $@
 .y_.o:
-       cp $< $@
-
+       cp `test -f $< || echo $(srcdir)/`$< $@
 .y_.z_:
-       cp $< $@
-
+       cp `test -f $< || echo $(srcdir)/`$< $@
 .z_.lo:
-       cp $< $@
-
-# Add explicit dependencies to help make implementations that
-# don't otherwise chain implicit rules (e.g., Sun make).
-foo.$(OBJEXT): foo.y_
-bar.lo: bar.z_
-bar.z_: bar.y_
-
-print:
-       @echo BEGIN: $(foo_OBJECTS) :END
-       @echo BEGIN: $(libfoo_la_OBJECTS) :END
-
-test: $(foo_OBJECTS) $(libfoo_la_OBJECTS)
+       cp `test -f $< || echo $(srcdir)/`$< $@
+
+# Some make implementations don't remove intermediate files
+# automatically, thus causing "make distcheck" to fail if
+# this is not added.
+MOSTLYCLEANFILES = *.y_ *.z_
+
+.PHONY: test0 test1 test2
+test0:
+       echo $(foo_OBJECTS) | grep '^foo\.foo$$'
+       echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
+test1:
+       echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT)$$'
+       echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
+test2: $(foo_OBJECTS) $(libfoo_la_OBJECTS)
        test -f foo.$(OBJEXT)
        test -f bar.lo
+check-local: test1 test2
 END
 
-echo 'int main() { return 0; }' > foo.x_
-cp foo.x_ bar.x_
+echo 'int main(void) { return 0; }' > foo.x_
+echo 'int bar(void) { return 0; }' > bar.x_
 
 libtoolize
 $ACLOCAL
@@ -71,11 +79,10 @@ $AUTOMAKE -a
 
 ./configure
 
-OBJEXT=foo $MAKE -e print >stdout || { cat stdout; Exit 1; }
-cat stdout
-$FGREP 'BEGIN: foo.foo :END' stdout
-$FGREP 'BEGIN: bar.lo :END' stdout
-
-$MAKE test
+OBJEXT=foo $MAKE -e test0
+$MAKE test1
+$MAKE test2
+$MAKE all
+$MAKE distcheck
 
 :