]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* ltmain.in (installed): new variable defined within a .la file,
authorAlexandre Oliva <oliva@dcc.unicamp.br>
Thu, 19 Nov 1998 18:01:07 +0000 (18:01 +0000)
committerAlexandre Oliva <aoliva@redhat.com>
Thu, 19 Nov 1998 18:01:07 +0000 (18:01 +0000)
  so that libtool can now link already-installed libraries into a
program.
* NEWS: ditto
* doc/libtool.texi (Linking executables): document it

ChangeLog
NEWS
doc/libtool.texi
ltmain.in

index 2e9001e17935d131951e2389dccb6a8e5bdc4660..2db9420391161bc1c582ada555a7c37af0696522 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 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>
diff --git a/NEWS b/NEWS
index 49df135e167d8a42451f4aba568430448c0c18d3..79d0df6045cf23f81cc16de8becc436e1b08c9ab 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,9 @@
 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).
index ca425e84783e9847bf7988daa307bfb4e55a508d..6fc6b68999ea0767cc468a5fdc2444645c04a97d 100644 (file)
@@ -680,6 +680,39 @@ creating hell
 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
@@ -837,8 +870,9 @@ a23#
 @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:
 
index 82f3d9c6da5bb9515d7ee7699803adff0ac887b4..998d41171b45e31fe5a6624cd64e5406cf7f50e8 100644 (file)
--- a/ltmain.in
+++ b/ltmain.in
@@ -549,7 +549,7 @@ compiler."
 
     # 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
@@ -839,6 +839,10 @@ compiler."
           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 ;;
@@ -858,12 +862,17 @@ compiler."
 
         # 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.
@@ -2182,6 +2191,9 @@ current=$current
 age=$age
 revision=$revision
 
+# Is this an already installed library?
+installed=no
+
 # Directory that this library needs to be installed in:
 libdir='$install_libdir'\
 "
@@ -2431,8 +2443,14 @@ 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"