*.$libext|*.so)
# An archive or an explicit shared library.
func_append deplibs " $arg"
- func_append old_deplibs " $arg"
continue
;;
if test conv = "$pass"; then
deplibs="$deplib $deplibs"
continue
+ else
+ func_append old_deplibs " $deplib"
fi
case $linkmode in
lib)
# Now set the variables for building old libraries.
build_libtool_libs=no
oldlibs=$output
- func_append objs "$old_deplibs"
;;
lib)
build_libtool_libs=no
;;
*)
- oldobjs="$old_deplibs $non_pic_objects"
+ oldobjs=$non_pic_objects
+ # This is not correct to add old_deplibs creating an archive
+ # so append them only when creating an executable or a shared
+ # library.
+ test yes != "$build_old_libs" && oldobjs="$oldobjs $old_deplibs"
$preload && test -f "$symfileobj" \
&& func_append oldobjs " $symfileobj"
addlibs=$old_convenience
done
dlprefiles=$newdlprefiles
fi
+
+ # Forward old library dependencies only when no shared
+ # library is being built. When building the shared library,
+ # the linker uses $deplibs to link the archives into it, but
+ # then we don't want to add it as transitive dependency.
+ if test -z "$library_names"; then
+ for lib in $old_deplibs; do
+ case $lib in
+ [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
+ *) abs=`pwd`"/$lib" ;;
+ esac
+ func_append dependency_libs " $abs"
+ done
+ fi
$RM $output
# place dlname in correct position for cygwin
# In fact, it would be nice if we could use this code for all target
AT_SETUP([static library contains static library])
AT_KEYWORDS([libtool])
-# This test passes with MS lib.
-AT_XFAIL_IF([case $AR in ar-lib\ * | *[[/\\]]ar-lib\ *) false;; *) :;; esac])
-
AT_DATA([foo.c],
[
int foo() { return 1;}
AT_CHECK([$LIBTOOL --mode=install cp libbar.la $thisdir], [], [ignore], [ignore])
eval `$EGREP '^(old_library)=' < libbar.la`
libbar=$old_library
+# The old library (libfoo.a) must NOT be nested inside libbar.a.
AT_CHECK([$AR -t $libbar | $GREP $libfoo],[1],[ignore],[ignore])
-AT_CHECK([$AR -t $libbar | $GREP foo.$OBJEXT],[],[ignore],[ignore])
+# Objects from libfoo must NOT be extracted into libbar.a either.
+AT_CHECK([$AR -t $libbar | $GREP foo.$OBJEXT],[1],[ignore],[ignore])
+# bar's own object must still be present.
AT_CHECK([$AR -t $libbar | $GREP bar.$OBJEXT],[],[ignore],[ignore])
AT_CLEANUP