bug#30126: Do not require “ltmain.sh” for out-of-tree libtool

2018-02-20 Thread Mathieu Lirzin
Hello,

Mathieu Lirzin  writes:

> Mathieu Lirzin  writes:
>
From a936b7d4cf8583ace0be6756b4b066a2c1aebe18 Mon Sep 17 00:00:00 2001
>> From: Paolo Bonzini 
>> Date: Mon, 31 Oct 2016 13:30:50 +0100
>> Subject: [PATCH] automake: Do not require ltmain.sh for out-of-tree libtool
>>
>> 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.
>>
>> * bin/automake.in ($libtool_bundled): New variable.
>> (handle_libtool): Do not require libtool files if libtool is not being
>> bundled.
>> (scan_autoconf_traces): Set $libtool_bundled.  Trace AC_PROG_LIBTOOL.
>> ---
>
> Would you have some time to allocate on a test for this patch in the
> following days/weeks?  I would like to be able to merge it before
> releasing Automake 1.16?

I have implemented the test myself, however I still don't understand how
the following scenario could reasonably happen.  So could you explain me
how such configuration could happen so that I can include it as a
rationale describing the test?

Thanks.

>From 196fc03864028e022b7a590b50c5711c6754e42b Mon Sep 17 00:00:00 2001
From: Mathieu Lirzin 
Date: Tue, 20 Feb 2018 11:14:54 +0100
Subject: [PATCH] =?UTF-8?q?tests:=20Add=20=E2=80=9Ct/libtool-when-required?=
 =?UTF-8?q?.sh=E2=80=9D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* t/libtool-when-required.sh: New failing test for bug#30126.
* t/list-of-tests.mk (handwritten_TESTS, XFAIL_TESTS): Add it.
---
 t/libtool-when-required.sh | 36 
 t/list-of-tests.mk |  2 ++
 2 files changed, 38 insertions(+)
 create mode 100644 t/libtool-when-required.sh

diff --git a/t/libtool-when-required.sh b/t/libtool-when-required.sh
new file mode 100644
index 0..d5f93814f
--- /dev/null
+++ b/t/libtool-when-required.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Copyright (C) 2018 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+# Make sure Automake does not require libtool files when no libtool macros are
+# used.
+
+. test-init.sh
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_SUBST([LIBTOOL], [libtool])
+AM_PROG_AR
+AC_OUTPUT
+END
+
+cat >> Makefile.am <<'END'
+lib_LTLIBRARIES = libfoo.la
+END
+
+$ACLOCAL
+AUTOMAKE_run -d 'should not complain about missing ltmain.sh' -- --add-missing
+
+:
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 271bfb573..8fdd076aa 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -38,6 +38,7 @@ t/override-conditional-pr13940.sh \
 t/dist-pr109765.sh \
 t/instdir-cond2.sh \
 t/java-nobase.sh \
+t/libtool-when-required.sh \
 t/objext-pr10128.sh \
 t/remake-timing-bug-pr8365.sh \
 t/lex-subobj-nodep.sh \
@@ -638,6 +639,7 @@ t/libtool8.sh \
 t/libtool9.sh \
 t/libtoo10.sh \
 t/libtoo11.sh \
+t/libtool-when-required.sh \
 t/license.sh \
 t/license2.sh \
 t/link_c_cxx.sh \
-- 
2.16.1


-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37


bug#30126: Do not require “ltmain.sh” for out-of-tree libtool

2018-01-15 Thread Mathieu Lirzin
Hello Paolo,

Mathieu Lirzin  writes:

>>From a936b7d4cf8583ace0be6756b4b066a2c1aebe18 Mon Sep 17 00:00:00 2001
> From: Paolo Bonzini 
> Date: Mon, 31 Oct 2016 13:30:50 +0100
> Subject: [PATCH] automake: Do not require ltmain.sh for out-of-tree libtool
>
> 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.
>
> * bin/automake.in ($libtool_bundled): New variable.
> (handle_libtool): Do not require libtool files if libtool is not being
> bundled.
> (scan_autoconf_traces): Set $libtool_bundled.  Trace AC_PROG_LIBTOOL.
> ---

Would you have some time to allocate on a test for this patch in the
following days/weeks?  I would like to be able to merge it before
releasing Automake 1.16?

Thanks.

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37





bug#30126: Do not require “ltmain.sh” for out-of-tree libtool

2018-01-15 Thread Mathieu Lirzin
I am opening a bug to keep track of this.

Mathieu Lirzin  writes:

> Paolo Bonzini  writes:
>
>> On 31/10/2016 13:30, Paolo Bonzini wrote:
>>> 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.
>>
>> This patch was never applied.
>>
>> Paolo
>>
>>> 2016-10-31  Paolo Bonzini  
>>> 
>>> * 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 
>>> ---
>>> 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(-)
>
> I haven't tested this, and I am not a Libtool expert so I trust your
> analysis.
>
> What do you think of adding a test ensuring that ltmain.sh is not
> required when no Libtool macro is found?
>
> I have attached a updated patch with trivial formatting and comment
> changes.

Here is the current version of the patch which needs a test to be
merged.

>From a936b7d4cf8583ace0be6756b4b066a2c1aebe18 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini 
Date: Mon, 31 Oct 2016 13:30:50 +0100
Subject: [PATCH] automake: Do not require ltmain.sh for out-of-tree libtool

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.

* bin/automake.in ($libtool_bundled): New variable.
(handle_libtool): Do not require libtool files if libtool is not being
bundled.
(scan_autoconf_traces): Set $libtool_bundled.  Trace AC_PROG_LIBTOOL.
---
 bin/automake.in | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/bin/automake.in b/bin/automake.in
index 5e36c0f..b7fbe96 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -344,6 +344,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;
@@ -2524,7 +2526,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)
@@ -5239,6 +5241,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,
@@ -5482,10 +5485,17 @@ EOF
 		if $mtime > $configure_deps_greatest_timestamp;
 	}
 	}
+  elsif ($macro eq 'AC_PROG_LIBTOOL')
+	{
+	  # Detect bundling of really old Libtool up to 1.4 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')
 	{
@@ -5498,6 +5508,7 @@ EOF
 	  # Hardcode the tags supported by Libtool 1.5.
 	  %libtool_tags = (CC => 1, CXX => 1, GCJ => 1, F77 => 1);
 	}
+	  $libtool_bundled = 1;
 	}
 }
 
-- 
2.9.5


-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37