* automake.in (handle_single_transform_list): Pass $nonansi_obj to
authorAlexandre Duret-Lutz <adl@gnu.org>
Mon, 5 Nov 2001 17:32:09 +0000 (17:32 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Mon, 5 Nov 2001 17:32:09 +0000 (17:32 +0000)
derive_suffix.  Don't use an hardcoded 'o' for object extensions.
(derive_suffix): Accept $OBJ as a second argument, don't
hardcode 'o'.
* tests/suffix5.test: New test.
* tests/Makefile.am (TESTS): Add suffix5.test.
Reported by Arkadiusz Miskiewicz <misiek@pld.ORG.PL>.

ChangeLog
THANKS
automake.in
tests/Makefile.am
tests/suffix5.test [new file with mode: 0755]

index 5afc796..c6cbab5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,14 @@
-2001-11-01  Alexandre Duret-Lutz  <duret_g@epita.fr>
+2001-11-05  Alexandre Duret-Lutz  <duret_g@epita.fr>
+
+       * automake.in (handle_single_transform_list): Pass $nonansi_obj to
+       derive_suffix.  Don't use an hardcoded 'o' for object extensions.
+       (derive_suffix): Accept $OBJ as a second argument, don't
+       hardcode 'o'.
+       * tests/suffix5.test: New test.
+       * tests/Makefile.am (TESTS): Add suffix5.test.
+       Reported by Arkadiusz Miskiewicz <misiek@pld.ORG.PL>.
+
+2001-11-05  Alexandre Duret-Lutz  <duret_g@epita.fr>
 
        * automake.in (handle_single_transform_list): Don't call
        $lang->target_hook for undefinied langages.
diff --git a/THANKS b/THANKS
index 3198aee..9027422 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -14,6 +14,7 @@ Andreas Schwab                schwab@lamothe.informatik.uni-dortmund.de
 Andrew Cagney          cagney@tpgi.com.au
 Andris Pavenis         pavenis@lanet.lv
 Anthony Green          green@cygnus.com
+Arkadiusz Miskiewicz   misiek@pld.ORG.PL
 Assar Westerlund       assar@sics.se
 Axel Belinfante                Axel.Belinfante@cs.utwente.nl
 Bernard Urban          Bernard.Urban@meteo.fr
index b436e63..d248e8c 100755 (executable)
@@ -590,6 +590,9 @@ my %de_ansi_files;
 
 # This maps the source extension of a suffix rule to its
 # corresponding output extension.
+# FIXME: because this hash maps one input extension to one output
+# extension, Automake cannot handle two suffix rules with the same
+# input extension.
 my %suffix_rules;
 
 # This is the name of the redirect `all' target to use.
@@ -1744,7 +1747,7 @@ sub handle_single_transform_list ($$$$@)
        # language function.
        my $aggregate = 'AM';
 
-        $extension = &derive_suffix ($extension);
+        $extension = &derive_suffix ($extension, $nonansi_obj);
         my $lang;
         if ($extension_map{$extension} &&
             ($lang = $languages{$extension_map{$extension}}))
@@ -1865,12 +1868,11 @@ sub handle_single_transform_list ($$$$@)
                 push (@{$lang_specific_files{$lang->name}}, $val);
             }
         }
-        elsif ($extension eq 'o')
+        elsif (".$extension" eq $nonansi_obj)
         {
             # This is probably the result of a direct suffix rule.
-            # In this case we just accept the rewrite.  FIXME:
-            # this fails if we want libtool objects.
-            $object = $base . '.' . $extension;
+            # In this case we just accept the rewrite.
+            $object = "$base.$extension";
             $linker = '';
         }
         else
@@ -1984,7 +1986,7 @@ sub handle_single_transform_list ($$$$@)
 #   $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but
 #   work done to determine the linker will be).
 #   $ONE_FILE is the canonical (transformed) name of object to build
-#   $OBJ is the object extension (ie either `.o' or `$o'.
+#   $OBJ is the object extension (ie either `.o' or `.lo').
 #   $PARENT is the variable in which $VAR is used, or $VAR if not applicable.
 #   $TOPPARENT is the _SOURCES variable being processed.
 #
@@ -2014,9 +2016,10 @@ sub define_objects_from_sources ($$$$$$$)
        my @result;
        foreach my $val (&variable_value_as_list ($var, $cond, $parent))
        {
+           # If $val is a variable (i.e. ${foo} or $(bar), not a filename),
+           # handle the sub variable recursively.
            if ($val =~ /^\$\{([^}]*)\}$/ || $val =~ /^\$\(([^)]*)\)$/)
            {
-               # Handle a sub variable
                my $subvar = $1;
 
                # If the user uses a losing variable name, just ignore it.
@@ -2046,7 +2049,7 @@ sub define_objects_from_sources ($$$$$$$)
                pop @substfroms;
                pop @substtos;
            }
-           else
+           else # $var is a filename
            {
                my $substnum=$#substfroms;
                while ($substnum >= 0)
@@ -5333,16 +5336,16 @@ sub register_language (%)
     $languages{$lang->name} = $lang;
 }
 
-# This function is used to find a path from a user-specified suffix to
-# `o' or to some other suffix we recognize internally, eg `cc'.
-sub derive_suffix
+# derive_suffix ($EXT, $OBJ)
+# ==========================
+# This function is used to find a path from a user-specified suffix $EXT
+# to $OBJ or to some other suffix we recognize internally, eg `cc'.
+sub derive_suffix ($$)
 {
-    my ($source_ext) = @_;
+    my ($source_ext, $obj) = @_;
 
-    # FIXME: hard-coding `o' is a mistake.  Doing something
-    # intelligent is harder.
     while (! $extension_map{$source_ext}
-          && $source_ext ne 'o'
+          && ".$source_ext" ne $obj
           && defined $suffix_rules{$source_ext})
     {
        $source_ext = $suffix_rules{$source_ext};
index c195075..62ef097 100644 (file)
@@ -289,6 +289,7 @@ suffix.test \
 suffix2.test \
 suffix3.test \
 suffix4.test \
+suffix5.test \
 symlink.test \
 symlink2.test \
 symlink3.test \
diff --git a/tests/suffix5.test b/tests/suffix5.test
new file mode 100755 (executable)
index 0000000..5196c38
--- /dev/null
@@ -0,0 +1,28 @@
+#! /bin/sh
+
+# Test to make sure Automake include libtool objects resulting
+# from user-defined implicit rules.
+# Based on a report from Arkadiusz Miskiewicz <misiek@pld.ORG.PL>.
+
+. $srcdir/defs || exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_LIBTOOL
+END
+
+cat > Makefile.am << 'END'
+.k.lo:
+       echo $< > $@
+
+noinst_LTLIBRARIES = libfoo.la
+libfoo_la_SOURCES = foo.k
+END
+
+: > ltmain.sh
+: > config.guess
+: > config.sub
+
+$ACLOCAL || exit 1
+$AUTOMAKE --Wno-error || exit 1
+grep '_OBJECTS.*foo.lo' Makefile.in || exit 1
+exit 0