automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: libtool --tag support (PR/289)


From: Alexandre Duret-Lutz
Subject: FYI: libtool --tag support (PR/289)
Date: Wed, 07 Jan 2004 22:56:34 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

I'm checking this in.

2004-01-07  Alexandre Duret-Lutz  <address@hidden>

        Fix for PR automake/289:
        * automake.in (Automake::Struct::libtool_tag): New attribute.  Define
        it for the language that have a Libtool tag.
        (%libtool_tags): New variable.
        (handle_languages, define_compiler_variable)
        (define_linker_variable): Pass --tag=XXX to libtool if supported.
        (scan_autoconf_traces): Scan for _LT_AC_TAGCONFIG and AC_LIBTOOL_TAGS.
        * tests/libtool3.test, tests/subobj9.test: Check that --tag=XXX is
        output.

Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.260
diff -u -r1.260 NEWS
--- NEWS        1 Jan 2004 18:54:20 -0000       1.260
+++ NEWS        7 Jan 2004 21:53:03 -0000
@@ -1,5 +1,8 @@
 New in 1.8a:
 
+* Libtool tags are used with libtool versions that support them.
+  (I.e., with Libtool 1.5 or greater.)
+
 * Makefile.in bloat reduction.
 
   - Inference rules are used to compile sources in subdirectories when
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1536
diff -u -r1.1536 automake.in
--- automake.in 5 Jan 2004 09:02:05 -0000       1.1536
+++ automake.in 7 Jan 2004 21:53:06 -0000
@@ -76,6 +76,9 @@
        # (defaults to [])
         'flags' => "@",
 
+       # Any tag to pass to libtool while compiling.
+       'libtool_tag' => "\$",
+
        # The file to use when generating rules for this language.
        # The default is 'depend2'.
        'rule_file' => "\$",
@@ -332,6 +335,9 @@
 # Where AM_GNU_GETTEXT appears.
 my $ac_gettext_location;
 
+# Lists of tags supported by Libtool.
+my %libtool_tags = ();
+
 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM).
 my $seen_canonical = 0;
 my $canonical_location;
@@ -668,6 +674,7 @@
                   'linker' => 'LINK',
                   'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) 
$(LDFLAGS) -o $@',
                   'compile_flag' => '-c',
+                  'libtool_tag' => 'CC',
                   'extensions' => ['.c'],
                   '_finish' => \&lang_c_finish);
 
@@ -683,6 +690,7 @@
                   'compiler' => 'CXXCOMPILE',
                   'compile_flag' => '-c',
                   'output_flag' => '-o',
+                  'libtool_tag' => 'CXX',
                   'lder' => 'CXXLD',
                   'ld' => '$(CXX)',
                   'pure' => 1,
@@ -793,6 +801,7 @@
                   'compiler' => 'F77COMPILE',
                   'compile_flag' => '-c',
                   'output_flag' => '-o',
+                  'libtool_tag' => 'F77',
                   'lder' => 'F77LD',
                   'ld' => '$(F77)',
                   'pure' => 1,
@@ -825,6 +834,7 @@
                   'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
                   'compile_flag' => '-c',
                   'output_flag' => '-o',
+                  'libtool_tag' => 'F77',
                   'pure' => 1,
                   'extensions' => ['.F']);
 
@@ -842,6 +852,7 @@
                   'compiler' => 'RCOMPILE',
                   'compile_flag' => '-c',
                   'output_flag' => '-o',
+                  'libtool_tag' => 'F77',
                   'pure' => 1,
                   'extensions' => ['.r']);
 
@@ -857,6 +868,7 @@
                   'compiler' => 'GCJCOMPILE',
                   'compile_flag' => '-c',
                   'output_flag' => '-o',
+                  'libtool_tag' => 'GCJ',
                   'lder' => 'GCJLD',
                   'ld' => '$(GCJ)',
                   'pure' => 1,
@@ -1153,7 +1165,14 @@
                  if set_seen ($val);
              }
 
-           my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
+           my $libtool_tag = '';
+           if ($lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag})
+             {
+               $libtool_tag = '--tag=' . $lang->libtool_tag . ' '
+             }
+
+           my $obj_ltcompile =
+             '$(LIBTOOL) --mode=compile ' . $libtool_tag . $obj_compile;
 
            # We _need_ `-o' for per object rules.
            my $output_flag = $lang->output_flag || '-o';
@@ -4469,6 +4488,9 @@
   my ($filename) = @_;
 
   # Macros to trace, with their minimal number of arguments.
+  #
+  # IMPORTANT: If you add a macro here, you should also add this macro
+  # =========  to Automake-preselection in autoconf/lib/autom4te.cfg.
   my %traced = (
                AC_CANONICAL_HOST => 0,
                AC_CANONICAL_SYSTEM => 0,
@@ -4478,6 +4500,7 @@
                AC_CONFIG_LINKS => 1,
                AC_INIT => 0,
                AC_LIBSOURCE => 1,
+               AC_LIBTOOL_TAGS => 1,
                AC_SUBST => 1,
                AM_AUTOMAKE_VERSION => 1,
                AM_CONDITIONAL => 2,
@@ -4489,6 +4512,7 @@
                m4_include => 1,
                m4_sinclude => 1,
                sinclude => 1,
+               _LT_AC_TAGCONFIG => 0,
              );
 
   my $traces = ($ENV{AUTOCONF} || 'autoconf') . " ";
@@ -4573,6 +4597,14 @@
        {
          $libsources{$args[1]} = $here;
        }
+      elsif ($macro eq 'AC_LIBTOOL_TAGS')
+       {
+          # Reset %libtool_tags, in case AC_LIBTOOL_TAGS is
+          # expansed after _LT_AC_TAGCONFIG.  We want to ignore
+         # _LT_AC_TAGCONFIG if AC_LIBTOOL_TAGS is called.
+          %libtool_tags = (CC => 1);
+          $libtool_tags{$_} = 1 foreach split (' ', $args[1]);
+       }
       elsif ($macro eq 'AC_SUBST')
        {
          # Just check for alphanumeric in AC_SUBST.  If you do
@@ -4649,6 +4681,19 @@
                if $mtime > $configure_deps_greatest_timestamp;
            }
        }
+      elsif ($macro eq '_LT_AC_TAGCONFIG')
+       {
+         # _LT_AC_TAGCONFIG is an old macro present in Libtool 1.5.
+         # We use it to detect whether tags are supported.  Our prefered
+         # interface is AC_LIBTOOL_TAGS, but it was introduced in
+         # Libtool 1.6.  Ignore _LT_AC_TAGCONFIG if AC_LIBTOOL_TAGS has
+         # been called.
+         if (0 == keys %libtool_tags)
+           {
+             # Hardcode the tags supported by Libtool 1.5.
+             %libtool_tags = (CC => 1, CXX => 1, GCJ => 1, F77 => 1);
+           }
+       }
     }
 
   $tracefh->close;
@@ -5437,8 +5482,13 @@
     my ($lang) = @_;
 
     my ($var, $value) = ($lang->compiler, $lang->compile);
+    my $libtool_tag = '';
+    $libtool_tag = '--tag=' . $lang->libtool_tag . ' '
+      if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
     &define_variable ($var, $value, INTERNAL);
-    &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value", INTERNAL)
+    &define_variable ("LT$var",
+                     "\$(LIBTOOL) --mode=compile $libtool_tag$value",
+                     INTERNAL)
       if var ('LIBTOOL');
 }
 
@@ -5451,11 +5501,15 @@
     my ($lang) = @_;
 
     my ($var, $value) = ($lang->lder, $lang->ld);
+    my $libtool_tag = '';
+    $libtool_tag = '--tag=' . $lang->libtool_tag . ' '
+      if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
     # CCLD = $(CC).
     &define_variable ($lang->lder, $lang->ld, INTERNAL);
     # CCLINK = $(CCLD) blah blah...
     &define_variable ($lang->linker,
-                     ((var ('LIBTOOL') ? '$(LIBTOOL) --mode=link ' : '')
+                     ((var ('LIBTOOL') ?
+                       '$(LIBTOOL) --mode=link ' . $libtool_tag  : '')
                       . $lang->link),
                      INTERNAL);
 }
Index: tests/libtool3.test
===================================================================
RCS file: /cvs/automake/automake/tests/libtool3.test,v
retrieving revision 1.5
diff -u -r1.5 libtool3.test
--- tests/libtool3.test 1 Jan 2004 18:54:20 -0000       1.5
+++ tests/libtool3.test 7 Jan 2004 21:53:09 -0000
@@ -88,5 +88,15 @@
 $FGREP 'a.lo:' Makefile.in
 
 ./configure
+
+# opportunistically check that --tag=CC is used when supported
+if test -n "`./libtool --help | grep tag=TAG`"; then
+  grep 'LTCOMPILE.*mode=compile --tag=CC' Makefile.in
+  grep 'LINK.*mode=link --tag=CC' Makefile.in
+  # We also expect --tag=CC to appear twice in the explicit rule a.lo.
+  # (The first time if am__fastdepCC is true, the second if it is not.)
+  test 2 = `grep 'am__fastdepCC.*mode=compile --tag=CC' Makefile.in | wc -l`
+fi
+
 $MAKE
 $MAKE distcheck
Index: tests/subobj9.test
===================================================================
RCS file: /cvs/automake/automake/tests/subobj9.test,v
retrieving revision 1.6
diff -u -r1.6 subobj9.test
--- tests/subobj9.test  14 Nov 2003 21:26:01 -0000      1.6
+++ tests/subobj9.test  7 Jan 2004 21:53:09 -0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2002  Free Software Foundation, Inc.
+# Copyright (C) 2002, 2004  Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -56,5 +56,12 @@
 
 # Skip this test on configure errors (e.g., broken C++ compilers).
 ./configure || exit 77
+
+# opportunistically check that --tag=CXX is used when supported
+if test -n "`./libtool --help | grep tag=TAG`"; then
+  grep 'LTCXXCOMPILE.*mode=compile --tag=CXX' Makefile.in
+  grep 'CXXLINK.*mode=link --tag=CXX' Makefile.in
+fi
+
 $MAKE
 $MAKE distcheck

-- 
Alexandre Duret-Lutz





reply via email to

[Prev in Thread] Current Thread [Next in Thread]