'noinst', 'lib', 'pkglib', 'check');
return if ! @liblist;
- my %instdirs;
my @prefix = am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
'noinst', 'check');
$var->requires_variables ('Libtool library used', 'LIBTOOL');
}
+ my %instdirs = ();
+ 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 $var = rvar ($key . '_LTLIBRARIES');
- for my $pair ($var->value_as_list_recursive (location => 1))
- {
- my ($where, $lib) = @$pair;
- # We reject libraries which are installed in several places,
- # because we don't handle this in the rules (think `-rpath').
- #
- # However, we allow the same library to be listed many times
- # for the same directory. This is for users who need setups
- # like
- # if COND1
- # lib_LTLIBRARIES = libfoo.la
- # endif
- # if COND2
- # lib_LTLIBRARIES = libfoo.la
- # endif
- #
- # Actually this will also allow
- # lib_LTLIBRARIES = libfoo.la libfoo.la
- # Diagnosing this case doesn't seem worth the plain (we'd
- # have to fill $instdirs on a per-condition basis, check
- # implied conditions, etc.)
- if (defined $instdirs{$lib} && $instdirs{$lib} ne $dir)
- {
- error ($where, "`$lib' is already going to be installed in "
- . "`$instdirs{$lib}'", partial => 1);
- error ($liblocations{$lib}, "`$lib' previously declared here");
- }
- else
- {
- $instdirs{$lib} = $dir;
- $liblocations{$lib} = $where->clone;
- }
- }
+
+ # We reject libraries which are installed in several places
+ # in the same condition, because we can only specify one
+ # `-rpath' option.
+ $var->traverse_recursively
+ (sub
+ {
+ my ($var, $val, $cond, $full_cond) = @_;
+ my $hcond = $full_cond->human;
+ my $where = $var->rdef ($cond)->location;
+ # A library cannot be installed in different directory
+ # in overlapping conditions.
+ if (exists $instconds{$val})
+ {
+ my ($msg, $acond) =
+ $instconds{$val}->ambiguous_p ($val, $full_cond);
+
+ if ($msg)
+ {
+ error ($where, $msg, partial => 1);
+
+ my $dirtxt = "installed in `$dir'";
+ $dirtxt = "built for `$dir'"
+ if $dir eq 'EXTRA' || $dir eq 'noinst' || $dir eq 'check';
+ my $dircond =
+ $full_cond->true ? "" : " in condition $hcond";
+
+ error ($where, "`$val' should be $dirtxt$dircond ...",
+ partial => 1);
+
+ my $hacond = $acond->human;
+ my $adir = $instdirs{$val}{$acond};
+ my $adirtxt = "installed in `$adir'";
+ $adirtxt = "built for `$adir'"
+ if ($adir eq 'EXTRA' || $adir eq 'noinst'
+ || $adir eq 'check');
+ my $adircond = $acond->true ? "" : " in condition $hacond";
+
+ my $onlyone = ($dir ne $adir) ?
+ ("\nLibtool libraries can be built for only one "
+ . "destination.") : "";
+
+ error ($liblocations{$val}{$acond},
+ "... and should also be $adirtxt$adircond.$onlyone");
+ return;
+ }
+ }
+ else
+ {
+ $instconds{$val} = new Automake::DisjConditions;
+ }
+ $instdirs{$val}{$full_cond} = $dir;
+ $liblocations{$val}{$full_cond} = $where;
+ $instconds{$val} = $instconds{$val}->merge ($full_cond);
+ },
+ sub
+ {
+ return ();
+ },
+ skip_ac_subst => 1);
}
foreach my $pair (@liblist)
$xlink = $linker ? $linker : 'LINK';
}
- my $rpath;
- if ($instdirs{$onelib} eq 'EXTRA'
- || $instdirs{$onelib} eq 'noinst'
- || $instdirs{$onelib} eq 'check')
- {
- # It's an EXTRA_ library, so we can't specify -rpath,
- # because we don't know where the library will end up.
- # The user probably knows, but generally speaking automake
- # doesn't -- and in fact configure could decide
- # dynamically between two different locations.
- $rpath = '';
- }
- else
- {
- $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
+ my $rpathvar = "am_${xlib}_rpath";
+ my $rpath = "\$($rpathvar)";
+ foreach my $rcond ($instconds{$onelib}->conds)
+ {
+ my $val;
+ if ($instdirs{$onelib}{$rcond} eq 'EXTRA'
+ || $instdirs{$onelib}{$rcond} eq 'noinst'
+ || $instdirs{$onelib}{$rcond} eq 'check')
+ {
+ # It's an EXTRA_ library, so we can't specify -rpath,
+ # because we don't know where the library will end up.
+ # The user probably knows, but generally speaking automake
+ # doesn't -- and in fact configure could decide
+ # dynamically between two different locations.
+ $val = '';
+ }
+ else
+ {
+ $val = ('-rpath $(' . $instdirs{$onelib}{$rcond} . 'dir)');
+ }
+ if ($rcond->true)
+ {
+ # If $rcond is true there is only one condition and
+ # there is no point defining an helper variable.
+ $rpath = $val;
+ }
+ else
+ {
+ define_pretty_variable ($rpathvar, $rcond, INTERNAL, $val);
+ }
}
# If the resulting library lies into a subdirectory,
-# Copyright (C) 1997, 2001, 2002, 2003 Free Software Foundation, Inc.
+# Copyright (C) 1997, 2001, 2002, 2003, 2004 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
# "(COND1 and !COND2) or (!COND3)"
my $str = $set->human;
+ # Merge (OR) several DisjConditions.
+ my $all = $set->merge($set2, $set3, ...)
+
# Invert a DisjConditions, i.e., create a new DisjConditions
# that complements $set.
my $inv = $set->invert;
}
+=item C<$newcond = $cond-E<gt>merge (@otherconds)>
+
+Return a new C<DisjConditions> which is the disjunction of
+C<$cond> and C<@otherconds>. Items in C<@otherconds> can be
+@C<Condition>s or C<DisjConditions>.
+
+=cut
+
+sub merge ($@)
+{
+ my ($self, @otherconds) = @_;
+ new Automake::DisjConditions (
+ map { $_->isa ("Automake::DisjConditions") ? $_->conds : $_ }
+ ($self, @otherconds));
+}
+
+
=item C<$prod = $set1-E<gt>multiply ($set2)>
Multiply two conditional sets.
--- /dev/null
+#!/bin/sh
+# Copyright (C) 2004 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 Automake; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Make sure Automake diagnoses conflicting installations.
+
+required='libtoolize'
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<'END'
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [false])
+AC_PROG_CC
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+if COND1
+ lib_LTLIBRARIES = liba.la
+ EXTRA_LTLIBRARIES = libc.la libc.la libb.la
+else
+ lib_LTLIBRARIES = libb.la
+endif
+if COND2
+if COND1
+ pkglib_LTLIBRARIES = liba.la
+endif
+endif
+END
+
+libtoolize
+$ACLOCAL
+AUTOMAKE_fails --add-missing
+grep libb stderr && exit 1
+grep 'Makefile.am:3:.*libc.la.*multiply defined' stderr
+grep 'Makefile.am:9:.*`pkglib' stderr
+grep 'Makefile.am:2:.*`lib' stderr