1998-11-19 Alexandre Oliva <oliva@dcc.unicamp.br>
+ * ltmain.in (installed): new variable defined within a .la file,
+ so that libtool can now link already-installed libraries into a
+ program.
+ * NEWS: ditto
+ * doc/libtool.texi (Linking executables): document it
+
* ltmain.in (output_objdir): compute it from $output, not $arg
1998-11-18 Alexandre Oliva <oliva@dcc.unicamp.br>
NEWS - list of user-visible changes between releases of GNU Libtool
New in 1.2c - 1998-XX-XX:
+* libtool will correctly link already-installed libraries into programs.
* New -module flag, to create loadable modules.
-# New libltdl, a small library for portable dynamic loading of modules.
+* New libltdl, a small library for portable dynamic loading of modules.
* Inter-library dependencies patch finally integrated, but there's
still much porting to do. See PORTING for details (some plans for the
future in mail/deplibs in the CVS tree).
burger$
@end example
+@cindex linking with installed libtool libraries
+
+Now assume @file{libhello.la} had already been installed, and you want
+to link a new program with it. You could figure out where it lives by
+yourself, then run:
+
+@example
+burger$ @kbd{gcc -g -O -o test test.o -L/usr/local/lib -lhello}
+@end example
+
+However, unless @file{/usr/local/lib} is in the standard library search
+path, you won't be able to run @code{test}. However, if you use libtool
+to link the already-installed libtool library, it will do The Right
+Thing (TM) for you:
+
+@example
+burger$ @kbd{libtool gcc -g -O -o test test.o /usr/local/lib/libhello.la}
+gcc -g -O -o @value{objdir}/test test.o -Wl,--rpath -Wl,/usr/local/lib /usr/local/lib/libhello.la -lm
+creating test
+burger$
+@end example
+
+Note that libtool added the necessary run-time path flag, as well as
+@samp{-lm}, the library libhello.la depended upon. Nice, huh?
+
+Since libtool created a wrapper script, you should use libtool to
+install it and debug it too. However, since the program does not depend
+on any uninstalled libtool library, it is probably usable even without
+the wrapper script. Libtool could probably be made smarter to avoid the
+creation of the wrapper script in this case, but this is left as an
+exercise for the reader.
+
+
@cindex wrapper scripts for programs
@cindex program wrapper scripts
Notice that the executable, @code{hell}, was actually created in the
@end example
Note that the libtool library @file{libhello.la} is also installed, to
-help libtool with uninstallation (@pxref{Uninstall mode}) and to help
-programs with dlopening (@pxref{Dlopened modules}).
+help libtool with uninstallation (@pxref{Uninstall mode}) and linking
+(@pxref{Linking executables}) and to help programs with dlopening
+(@pxref{Dlopened modules}).
Here is the shared library example:
# Unlock the critical section if it was locked
if test "$need_locks" != no; then
- rm -f "$lockfile"
+ $rm "$lockfile"
fi
# Create an invalid libtool object if no PIC, so that we do not
exit 1
fi
+ # If the library was installed with an old release of libtool,
+ # it will not redefine variable installed.
+ installed=yes
+
# If there is no directory component, then add one.
case "$arg" in
*/* | *\\*) . $arg ;;
# Find the relevant object directory and library name.
name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'`
- dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$dir" = "X$arg"; then
- dir="$objdir"
- else
- dir="$dir/$objdir"
- fi
+
+ if test "X$installed" = Xyes; then
+ dir="$libdir"
+ else
+ dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$dir" = "X$arg"; then
+ dir="$objdir"
+ else
+ dir="$dir/$objdir"
+ fi
+ fi
if test -z "$libdir"; then
# It is a libtool convenience library, so add in its objects.
age=$age
revision=$revision
+# Is this an already installed library?
+installed=no
+
# Directory that this library needs to be installed in:
libdir='$install_libdir'\
"
# Install the pseudo-library for information purposes.
name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- $show "$install_prog $file $destdir/$name"
- $run eval "$install_prog $file $destdir/$name" || exit $?
+ instname="$dir/$name"i
+ $show "Creating $instname"
+ $rm "$instname"
+ sed 's/^installed=no$/installed=yes/' "$file" > "$instname"
+ $show "$install_prog $instname $destdir/$name"
+ $run eval "$install_prog $instname $destdir/$name" || exit $?
+ $show "$rm $instname"
+ $rm "$instname"
# Maybe install the static library, too.
test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"