From c1aa7028b9127c3ecd3c4097d0846bc0ace4b690 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Wed, 7 Jan 2004 21:56:48 +0000 Subject: [PATCH] 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. --- ChangeLog | 12 +++++++++ NEWS | 3 +++ automake.in | 60 ++++++++++++++++++++++++++++++++++++++++++--- tests/libtool3.test | 10 ++++++++ tests/subobj9.test | 9 ++++++- 5 files changed, 90 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 004462a1..f6f71ca5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-01-07 Alexandre Duret-Lutz + + 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. + 2003-01-07 Eric Sunshine (tiny change) * lib/am/configure.am (am__CONFIG_DISTCLEAN_FILES): Add diff --git a/NEWS b/NEWS index 6090d461..9671ab21 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/automake.in b/automake.in index ccb6098a..bb4d8b13 100755 --- a/automake.in +++ b/automake.in @@ -76,6 +76,9 @@ struct (# Short name of the language (c, f77...). # (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 @@ my $seen_gettext_external = 0; # 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 @@ register_language ('name' => 'c', '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 @@ register_language ('name' => 'cxx', 'compiler' => 'CXXCOMPILE', 'compile_flag' => '-c', 'output_flag' => '-o', + 'libtool_tag' => 'CXX', 'lder' => 'CXXLD', 'ld' => '$(CXX)', 'pure' => 1, @@ -793,6 +801,7 @@ register_language ('name' => 'f77', 'compiler' => 'F77COMPILE', 'compile_flag' => '-c', 'output_flag' => '-o', + 'libtool_tag' => 'F77', 'lder' => 'F77LD', 'ld' => '$(F77)', 'pure' => 1, @@ -825,6 +834,7 @@ register_language ('name' => 'ppf77', '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 @@ register_language ('name' => 'ratfor', 'compiler' => 'RCOMPILE', 'compile_flag' => '-c', 'output_flag' => '-o', + 'libtool_tag' => 'F77', 'pure' => 1, 'extensions' => ['.r']); @@ -857,6 +868,7 @@ register_language ('name' => 'java', 'compiler' => 'GCJCOMPILE', 'compile_flag' => '-c', 'output_flag' => '-o', + 'libtool_tag' => 'GCJ', 'lder' => 'GCJLD', 'ld' => '$(GCJ)', 'pure' => 1, @@ -1153,7 +1165,14 @@ sub handle_languages 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 @@ sub scan_autoconf_traces ($) 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.in. my %traced = ( AC_CANONICAL_HOST => 0, AC_CANONICAL_SYSTEM => 0, @@ -4478,6 +4500,7 @@ sub scan_autoconf_traces ($) 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 @@ sub scan_autoconf_traces ($) m4_include => 1, m4_sinclude => 1, sinclude => 1, + _LT_AC_TAGCONFIG => 0, ); my $traces = ($ENV{AUTOCONF} || 'autoconf') . " "; @@ -4573,6 +4597,14 @@ sub scan_autoconf_traces ($) { $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 @@ sub scan_autoconf_traces ($) 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 @@ sub define_compiler_variable ($) 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 @@ sub define_linker_variable ($) 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); } diff --git a/tests/libtool3.test b/tests/libtool3.test index 183bdb68..a11e137b 100755 --- a/tests/libtool3.test +++ b/tests/libtool3.test @@ -88,5 +88,15 @@ $FGREP 'a.o:' Makefile.in && exit 1 $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 diff --git a/tests/subobj9.test b/tests/subobj9.test index accaeaf7..00fc1203 100755 --- a/tests/subobj9.test +++ b/tests/subobj9.test @@ -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 @@ $AUTOMAKE -a # 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 -- 2.43.5