libtool
[Top][All Lists]
Advanced

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

using --tag=XXX in automake-generated rules (Was: Re: 'ccache gcc' as co


From: Alexandre Duret-Lutz
Subject: using --tag=XXX in automake-generated rules (Was: Re: 'ccache gcc' as compiler with libtool)
Date: Fri, 02 Jan 2004 19:41:18 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

>>> "Gary" == Gary V Vaughan <address@hidden> writes:
[...about Automake passing --tag=XXX to libtool...]
 Gary> Alexandre Duret-Lutz wrote:
 >> >> How can automake determine whether the version of libtool used in
 >> >> a package supports --tag ?
[...]
 Gary> _LT_AC_TAGCONFIG exists in branch-1-5 and HEAD.

Not quite.  branch-1-5 has _LT_AC_TAGCONFIG but HEAD has _LT_AC_TAG_CONFIG.

I prefer to rely on AC_LIBTOOL_TAGS, because this macro supplies
a list of supported tags (either the tags supplied by the users,
or the default list of tags).  Is this OK with you?

Below is the implementation I propose, it traces both
_LT_AC_TAG_CONFIG for Libtool 1.5 and AC_LIBTOOL_TAGS for newer
versions.

BTW currently the --tag option and the AC_LIBTOOL_TAGS macro are
not documented in the Libtool manual.


2004-01-02  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 are
        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        2 Jan 2004 18:37:17 -0000
@@ -1,5 +1,8 @@
 New in 1.8a:
 
+* Libtool tags are used with libtool versions that support it.
+  (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.1533
diff -u -r1.1533 automake.in
--- automake.in 1 Jan 2004 21:57:23 -0000       1.1533
+++ automake.in 2 Jan 2004 18:37:21 -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;
@@ -663,6 +669,7 @@
                   'linker' => 'LINK',
                   'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) 
$(LDFLAGS) -o $@',
                   'compile_flag' => '-c',
+                  'libtool_tag' => 'CC',
                   'extensions' => ['.c'],
                   '_finish' => \&lang_c_finish);
 
@@ -678,6 +685,7 @@
                   'compiler' => 'CXXCOMPILE',
                   'compile_flag' => '-c',
                   'output_flag' => '-o',
+                  'libtool_tag' => 'CXX',
                   'lder' => 'CXXLD',
                   'ld' => '$(CXX)',
                   'pure' => 1,
@@ -788,6 +796,7 @@
                   'compiler' => 'F77COMPILE',
                   'compile_flag' => '-c',
                   'output_flag' => '-o',
+                  'libtool_tag' => 'F77',
                   'lder' => 'F77LD',
                   'ld' => '$(F77)',
                   'pure' => 1,
@@ -820,6 +829,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']);
 
@@ -837,6 +847,7 @@
                   'compiler' => 'RCOMPILE',
                   'compile_flag' => '-c',
                   'output_flag' => '-o',
+                  'libtool_tag' => 'F77',
                   'pure' => 1,
                   'extensions' => ['.r']);
 
@@ -852,6 +863,7 @@
                   'compiler' => 'GCJCOMPILE',
                   'compile_flag' => '-c',
                   'output_flag' => '-o',
+                  'libtool_tag' => 'GCJ',
                   'lder' => 'GCJLD',
                   'ld' => '$(GCJ)',
                   'pure' => 1,
@@ -1148,7 +1160,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';
@@ -4465,6 +4484,9 @@
   my ($filename) = @_;
 
   # Macros to trace, with their minimal number of arguments.
+  #
+  # IMPORTANT: If you add a macro here, you should also list this macro
+  # =========  to Automake-preselection in autoconf/lib/autom4te.cfg.
   my %traced = (
                AC_CANONICAL_HOST => 0,
                AC_CANONICAL_SYSTEM => 0,
@@ -4474,6 +4496,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,
@@ -4485,6 +4508,7 @@
                m4_include => 1,
                m4_sinclude => 1,
                sinclude => 1,
+                _LT_AC_TAGCONFIG => 0,
              );
 
   my $traces = ($ENV{AUTOCONF} || 'autoconf') . " ";
@@ -4569,6 +4593,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
@@ -4645,6 +4677,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;
@@ -5433,8 +5478,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');
 }
 
@@ -5447,11 +5497,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 2 Jan 2004 18:37:21 -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  2 Jan 2004 18:37:21 -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]