Subject: bug#16972: [PATCH] Relink check in --install mode broken

From: Thilo Schulz <[email-masked]>
Date: Tue, 11 Mar 2014 15:41:40 +0100

Hi,

> Hi Thilo,
> 
> I seriously doubt that this change is correct. The code has been the way
> it is since it was added 10+ years ago (commit d2c4f8f8fc). Well, the test
> was written as
> 
> 	if test "$inst_prefix_dir" = "$destdir"; then
> 	  $echo ...
> 	  exit
> 	fi
> 
> way back when, but that's equivalent to the current code.

You're right. I had a more thorough look at the script as opposed to the 
cursory glance before, and I now understand what's actually happening.

With the sed command:

          inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`

it searches for the trailing path, and replaces it with nothing. If that 
trailing path is identical, inst_prefix_dir will be unequal to the original 
destdir, so equality actually _is_ the error condition.

It didn't work in my case though, because in --link mode, the -rpath argument 
had a trailing / and libtool removes the trailing slash from the installation 
directory argument in --install mode.

So here is a second patch that only fixes this failure of the check. Maybe you 
want to strip libdir of trailing slashes in --link mode already, but that's 
the libtool maintainer's choice.

--- libtool.orig        2014-03-11 15:27:51.541596775 +0100
+++ libtool     2014-03-11 15:27:30.417597689 +0100
@@ -3393,8 +3393,11 @@
        dir+="$objdir"
 
        if test -n "$relink_command"; then
+         # $destdir has trailing slashes stripped, so must strip slashes from 
$libdir as well
+         func_stripname '' '/' "$libdir"
+
          # Determine the prefix the user has applied to our future dir.
-         inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
+         inst_prefix_dir=`$ECHO "$destdir" | $SED -e 
"s%$func_stripname_result\$%%"`
 
          # Don't allow the user to place us outside of our expected
          # location b/c this prevents finding dependent libraries that

-- 
Beste Grüße,
Thilo Schulz