[PATCH] automake: do not require ltmain.sh for out-of-tree libtool

Paolo Bonzini <[email protected]>
Newsgroups gmane.comp.sysutils.automake.patches
Message-ID <[email protected]>
If Automake does not see LT_SUPPORTED_TAG, it assumes an old libtool
that does not know about AC_REQUIRE_AUX_FILE.  However, if the program
does not use Libtool's configure.ac macros this check gets a
false positive.  Do not require ltmain.sh if no Libtool macro is
found in configure.ac.

Libtools that are not stone-age are already covered by LT_SUPPORTED_TAG
and _LT_AC_TAGCONFIG, but add AC_PROG_LIBTOOL just in case for Libtool
up to 1.4.

2016-10-31  Paolo Bonzini  <[email protected]>

	* bin/automake.in ($libtool_bundled): New.
	(handle_libtool): Do not require libtool files if libtool is
	not being bundled.
	(scan_autoconf_traces): Set $libtool_bundled.  Trace
	AC_PROG_LIBTOOL too.

Signed-off-by: Paolo Bonzini <[email protected]>
---
	If the patch is accepted I will send an Autoconf patch to
	preselect AC_PROG_LIBTOOL.

	Since this is a bug, it would be nice to add it at least to
	the 1.16 branch.

 bin/automake.in | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/bin/automake.in b/bin/automake.in
index 3abee49..cb2a480 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -274,6 +274,8 @@ my @extra_recursive_targets = ();
 
 # Lists of tags supported by Libtool.
 my %libtool_tags = ();
+# 1 if Libtool is being bundled, so ltmain.sh is required.
+my $libtool_bundled = 0;
 # 1 if Libtool uses LT_SUPPORTED_TAG.  If it does, then it also
 # uses AC_REQUIRE_AUX_FILE.
 my $libtool_new_api = 0;
@@ -2304,7 +2306,7 @@ sub handle_libtool ()
   # (Starting with Libtool 2.0 we do not have to bother.  These
   # requirements are done with AC_REQUIRE_AUX_FILE.)
   require_conf_file_with_macro (TRUE, 'LIBTOOL', FOREIGN, @libtool_files)
-    if $relative_dir eq '.' && ! $libtool_new_api;
+    if $relative_dir eq '.' && $libtool_bundled && ! $libtool_new_api;
 
   my @libtool_rms;
   foreach my $item (sort keys %libtool_clean_directories)
@@ -4952,6 +4954,7 @@ sub scan_autoconf_traces
 		_AM_COND_IF => 1,
 		_AM_COND_ELSE => 1,
 		_AM_COND_ENDIF => 1,
+		AC_PROG_LIBTOOL => 0,
 		LT_SUPPORTED_TAG => 1,
 		_LT_AC_TAGCONFIG => 0,
 		m4_include => 1,
@@ -5185,10 +5188,16 @@ sub scan_autoconf_traces
 		if $mtime > $configure_deps_greatest_timestamp;
 	    }
 	}
+      elsif ($macro eq 'AC_PROG_LIBTOOL')
+	{
+	  # Detect bundling of really old Libtool that does not support tags.
+	  $libtool_bundled = 1;
+	}
       elsif ($macro eq 'LT_SUPPORTED_TAG')
 	{
 	  $libtool_tags{$args[1]} = 1;
 	  $libtool_new_api = 1;
+	  $libtool_bundled = 1;
 	}
       elsif ($macro eq '_LT_AC_TAGCONFIG')
 	{
@@ -5201,6 +5210,7 @@ sub scan_autoconf_traces
 	      # Hardcode the tags supported by Libtool 1.5.
 	      %libtool_tags = (CC => 1, CXX => 1, GCJ => 1, F77 => 1);
 	    }
+	  $libtool_bundled = 1;
 	}
     }
 
-- 
2.7.4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.