Let's start fixing the issues I noted last weekend: * Ralf Wildenhues wrote on Sun, Sep 14, 2008 at 03:23:45PM CEST: > While writing a test case for this, I noticed that nobase_ is broken > for LTLIBRARIES in more ways, and before the install changes: > > * -rpath is not adjusted to point to the subdir. What's worse, > libtool even doesn't warn about it.
Fixed thusly. The "installed below `DIR'" is a cheap cop-out of mine to avoid computing the subdir component in the error message. I hope users will understand it well enough. Cheers, Ralf Fix -rpath arguments for nobase_*_LTLIBRARIES. * automake.in (handle_ltlibraries): New hash %instsubdirs to track the dirname of nobase ltlibraries, and tack it onto the end of the -rpath argument. Also, fix the warning about ltlibs installed in multiple locations to fit a bit better. * tests/pr300-ltlib.test: Expose this bug here. * tests/ltinstloc.test: New test. * tests/Makefile.am: Update. * NEWS: Update. diff --git a/NEWS b/NEWS index dac6a9e..9c4dc91 100644 --- a/NEWS +++ b/NEWS @@ -81,6 +81,9 @@ Bugs fixed in 1.10a: - Fix aix dependency tracking for libtool objects. + - For nobase_*_LTLIBRARIES with nonempty directory components, the + correct `-rpath' argument is used now. + * Bugs introduced by 1.10: - Fix output of dummy dependency files in presence of post-processed diff --git a/automake.in b/automake.in index baaac96..54f6865 100755 --- a/automake.in +++ b/automake.in @@ -2626,13 +2626,20 @@ sub handle_ltlibraries } my %instdirs = (); + my %instsubdirs = (); my %instconds = (); my %liblocations = (); # Location (in Makefile.am) of each library. foreach my $key (@prefix) { # Get the installation directory of each library. - (my $dir = $key) =~ s/^nobase_//; + my $dir = $key; + my $strip_subdir = 1; + if ($dir =~ /^nobase_/) + { + $dir =~ s/^nobase_//; + $strip_subdir = 0; + } my $var = rvar ($key . '_LTLIBRARIES'); # We reject libraries which are installed in several places @@ -2644,6 +2651,9 @@ sub handle_ltlibraries my ($var, $val, $cond, $full_cond) = @_; my $hcond = $full_cond->human; my $where = $var->rdef ($cond)->location; + my $ldir = ''; + $ldir = '/' . dirname ($val) + if (!$strip_subdir); # A library cannot be installed in different directory # in overlapping conditions. if (exists $instconds{$val}) @@ -2654,8 +2664,7 @@ sub handle_ltlibraries if ($msg) { error ($where, $msg, partial => 1); - - my $dirtxt = "installed in `$dir'"; + my $dirtxt = "installed " . ($strip_subdir ? "in" : "below") . " `$dir'"; $dirtxt = "built for `$dir'" if $dir eq 'EXTRA' || $dir eq 'noinst' || $dir eq 'check'; my $dircond = @@ -2686,6 +2695,7 @@ sub handle_ltlibraries $instconds{$val} = new Automake::DisjConditions; } $instdirs{$val}{$full_cond} = $dir; + $instsubdirs{$val}{$full_cond} = $ldir; $liblocations{$val}{$full_cond} = $where; $instconds{$val} = $instconds{$val}->merge ($full_cond); }, @@ -2789,6 +2799,8 @@ sub handle_ltlibraries else { $val = ('-rpath $(' . $instdirs{$onelib}{$rcond} . 'dir)'); + $val .= $instsubdirs{$onelib}{$rcond} + if defined $instsubdirs{$onelib}{$rcond}; } if ($rcond->true) { diff --git a/tests/Makefile.am b/tests/Makefile.am index 7146770..4445c40 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -376,6 +376,7 @@ ltcond.test \ ltcond2.test \ ltconv.test \ ltdeps.test \ +ltinstloc.test \ ltlibobjs.test \ ltlibsrc.test \ lzma.test \ diff --git a/tests/ltinstloc.test b/tests/ltinstloc.test new file mode 100755 index 0000000..d6122fd --- /dev/null +++ b/tests/ltinstloc.test @@ -0,0 +1,65 @@ +#!/bin/sh +# Copyright (C) 2008 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 3, 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 <http://www.gnu.org/licenses/>. + +# Test for libtool errors for multiple install locations, esp. with nobase. + + +required='libtoolize' +. ./defs || Exit 1 + +set -e + +cat >>configure.in <<'END' +AC_PROG_CC +AC_PROG_LIBTOOL +AM_CONDITIONAL([COND], [:]) +AC_OUTPUT +END + +cat >Makefile.am <<'END' +if COND +lib_LTLIBRARIES = liba1.la sub/liba2.la +#else +pkglib_LTLIBRARIES = liba1.la +nobase_lib_LTLIBRARIES = sub/liba2.la +endif +END + +libtoolize +$ACLOCAL +$AUTOCONF +AUTOMAKE_fails --add-missing + +cat >expected <<'END' +configure.in:5: installing `./config.guess' +configure.in:5: installing `./config.sub' +Makefile.am:5: sub/liba2.la multiply defined in condition COND +Makefile.am:5: `sub/liba2.la' should be installed below `lib' in condition COND ... +Makefile.am:2: ... and should also be installed in `lib' in condition COND. +Makefile.am:4: liba1.la multiply defined in condition COND +Makefile.am:4: `liba1.la' should be installed in `pkglib' in condition COND ... +Makefile.am:2: ... and should also be installed in `lib' in condition COND. +Makefile.am:2: Libtool libraries can be built for only one destination. +END + +diff stderr expected + +sed 's/#//' < Makefile.am > t +mv -f t Makefile.am + +$AUTOMAKE +grep ' -rpath \$(libdir)/sub' Makefile.in +: diff --git a/tests/pr300-ltlib.test b/tests/pr300-ltlib.test index c864d44..99c03da 100755 --- a/tests/pr300-ltlib.test +++ b/tests/pr300-ltlib.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002, 2007 Free Software Foundation, Inc. +# Copyright (C) 2002, 2007, 2008 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 @@ -48,12 +48,19 @@ $ACLOCAL $AUTOCONF $AUTOMAKE --copy --add-missing ./configure --prefix "`pwd`/inst" -$MAKE +$MAKE >stdout +cat stdout + +grep 'liba.la .*-rpath .*lib' stdout +grep 'liba.la .*-rpath .*lib/subdir' stdout && Exit 1 +grep 'libb.la .*-rpath .*lib/subdir' stdout test -f subdir/liba.la test -f subdir/libb.la -$MAKE install +$MAKE install 2>stderr +cat stderr >&2 +grep 'remember.*--finish' stderr && Exit 1 test -f inst/lib/liba.la test -f inst/lib/subdir/libb.la