* tests/defs.in: Handle required=etags to work around
Exuberant Ctags.
diff --git a/ChangeLog b/ChangeLog
index 4c33f85..8463836 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2003-04-18  Alexandre Duret-Lutz  <adl@gnu.org>
 
+	* tests/defs.in: Handle required=etags to work around
+	Exuberant Ctags.
+
 	* lib/config.guess, lib/config.sub, lib/texinfo.tex: New upstream
 	versions.
 
diff --git a/automake.in b/automake.in
index 38e1855..81fde4f 100755
--- a/automake.in
+++ b/automake.in
@@ -2195,6 +2195,7 @@
         # into the current directory, unless the subdir-objects option
         # is in effect.
 
+	print "1. $_\n";
         # Split file name into base and extension.
         next if ! /^(?:(.*)\/)?([^\/]*)($KNOWN_EXTENSIONS_PATTERN)$/;
         my $full = $_;
@@ -2218,6 +2219,7 @@
 	my $aggregate = 'AM';
 
         $extension = &derive_suffix ($extension, $nonansi_obj);
+	print "2. $extension\n";
         my $lang;
         if ($extension_map{$extension} &&
             ($lang = $languages{$extension_map{$extension}}))
@@ -5923,6 +5925,9 @@
 {
   my ($source_ext, $obj) = @_;
 
+  print "3. @{[keys %{$suffix_rules->{$source_ext}}]}\n";
+  print "3. @{[$suffix_rules->{$source_ext}{$obj}]}\n";
+
   while (! $extension_map{$source_ext}
 	 && $source_ext ne $obj
 	 && exists $suffix_rules->{$source_ext}
@@ -7062,19 +7067,22 @@
       $suffix_rules->{$src} = { $dest => [ $dest, 1 ] };
     }
 
-  # If we know how to transform $dest in something else, then
-  # we know how to transform $src in that "something else".
-  if (exists $suffix_rules->{$dest})
+  # If we know how to transform any suffix of $dest into something else,
+  # then we know how to transform $src in that "something else".
+  foreach my $suffix (keys %$suffix_rules)
     {
-      for my $dest2 (keys %{$suffix_rules->{$dest}})
+      if ($dest =~ /\Q$suffix\E$/)
 	{
-	  my $dist = $suffix_rules->{$dest}{$dest2}[1] + 1;
-	  # Overwrite an existing $src->$dest2 path only if
-	  # the path via $dest which is shorter.
-	  if (! exists $suffix_rules->{$src}{$dest2}
-	      || $suffix_rules->{$src}{$dest2}[1] > $dist)
+	  for my $dest2 (keys %{$suffix_rules->{$suffix}})
 	    {
-	      $suffix_rules->{$src}{$dest2} = [ $dest, $dist ];
+	      my $dist = $suffix_rules->{$suffix}{$dest2}[1] + 1;
+	      # Overwrite an existing $src->$dest2 path only if
+	      # the path via $suffix which is shorter.
+	      if (! exists $suffix_rules->{$src}{$dest2}
+		  || $suffix_rules->{$src}{$dest2}[1] > $dist)
+		{
+		  $suffix_rules->{$src}{$dest2} = [ $suffix, $dist ];
+		}
 	    }
 	}
     }
@@ -7084,17 +7092,20 @@
   my @dest2 = keys %{$suffix_rules->{$src}};
   for my $src2 (keys %$suffix_rules)
     {
-      if (exists $suffix_rules->{$src2}{$src})
+      foreach my $suffix2 (keys %{$suffix_rules->{$src2}})
 	{
-	  for my $dest2 (@dest2)
+	  if ($suffix2 =~ /\Q$src\E$/)
 	    {
-	      my $dist = $suffix_rules->{$src}{$dest2} + 1;
-	      # Overwrite an existing $src2->$dest2 path only if
-	      # the path via $src is shorter.
-	      if (! exists $suffix_rules->{$src2}{$dest2}
-		  || $suffix_rules->{$src2}{$dest2}[1] > $dist)
+	      for my $dest2 (@dest2)
 		{
-		  $suffix_rules->{$src2}{$dest2} = [ $src, $dist ];
+		  my $dist = $suffix_rules->{$src}{$dest2} + 1;
+		  # Overwrite an existing $src2->$dest2 path only if
+		  # the path via $src is shorter.
+		  if (! exists $suffix_rules->{$src2}{$dest2}
+		      || $suffix_rules->{$src2}{$dest2}[1] > $dist)
+		    {
+		      $suffix_rules->{$src2}{$dest2} = [ $src, $dist ];
+		    }
 		}
 	    }
 	}
diff --git a/tests/defs.in b/tests/defs.in
index c056aad..1d0735a 100644
--- a/tests/defs.in
+++ b/tests/defs.in
@@ -71,6 +71,14 @@
 	echo "$me: running bison --version"
 	( bison --version ) || exit 77
 	;;
+      etags)
+	# Exuberant Ctags will create a TAGS file even
+	# when asked for --help or --version.  (Emacs's etags
+	# does not have such problem.)  Use -o /dev/null
+	# to make sure we do not pollute the tests/ directory.
+	echo "$me: running etags --version -o /dev/null"
+	( etags --version -o /dev/null ) || exit 77
+	;;
       GNUmake)
 	# Use --version and -v, because SGI Make doesn't fail on --version.
 	echo "$me: running $MAKE --version -v"
diff --git a/tests/suffix7.test b/tests/suffix7.test
index d5d82c8..d28ceb2 100755
--- a/tests/suffix7.test
+++ b/tests/suffix7.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2001, 2002  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003  Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -19,21 +19,40 @@
 # Boston, MA 02111-1307, USA.
 
 # Test to make sure Automake supports implicit rules "confusing"
-# extensions.  Inspired by a mail from Alex Hornby. 
+# extensions.  Inspired by a mail from Alex Hornby.
 
+required=gcc
 . ./defs || exit 1
 
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CXX
+AC_OUTPUT
+END
+
 cat > Makefile.am << 'END'
 SUFFIXES = .idl S.cpp C.h
 SUFFIXES += C.cpp S.h
 .idlC.cpp:
 	cp $< $@
+
+bin_PROGRAMS = foo
+foo_SOURCES = foo.idl
+
+echo:
+	@echo 'BEG: $(foo_OBJECTS) :END'
 END
 
 : > fooa
 
-$ACLOCAL || exit 1
-$AUTOMAKE || exit 1
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+OBJEXT=bar $MAKE -e echo >stdout
+cat stdout
+grep 'BEG: foo.bar :END' stdout
 
 # Make sure Automake has NOT recognized .cpp and .idlC as two new
 # extensions.