]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
*** empty log message ***
authorGordon Matzigkeit <gord@gnu.ai.mit.edu>
Tue, 26 Aug 1997 18:44:05 +0000 (18:44 +0000)
committerGordon Matzigkeit <gord@gnu.org>
Tue, 26 Aug 1997 18:44:05 +0000 (18:44 +0000)
ChangeLog
Makefile.am
NEWS
TODO
doc/libtool.texi
ltmain.sh.in

index 2c02f32adc2d54867bf00a34e0c063e78c23f8d2..9bc9a7349a132c1f340c31f6a8b0bb4ed263d14b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+Mon Aug 25 10:54:14 1997  Gordon Matzigkeit  <gord@gnu.ai.mit.edu>
+
+       * ltmain.sh.in: Change quoting procedure because some shells
+       cannot handle `]' in scan sets.  From Ian Dall.
+
+Fri Aug 22 11:00:58 1997  Gordon Matzigkeit  <gord@gnu.ai.mit.edu>
+
+       * ltmain.sh.in (execute): Added -dlopen flag handling.  Suggested
+       by Alexandre Oliva.
+
+Thu Aug 21 00:40:45 1997  Gordon Matzigkeit  <gord@gnu.ai.mit.edu>
+
+       * ltmain.sh.in (link): Change executable wrapper to fix up value
+       of thisdir, as well as progdir, if the $0 path doesn't work.  This
+       guarantees that shlibpath_var is set correctly.  Add support for
+       execute mode.
+
+       * ltmain.sh.in (execute): New mode to automatically set
+       shlibpath_var, which allows easy debugging of uninstalled
+       executables and libraries.  Suggested by Kenneth Albanowski.
+
 Wed Aug 20 10:51:02 1997  Gordon Matzigkeit  <gord@gnu.ai.mit.edu>
 
        * Makefile.am ($(srcdir)/ltconfig): Use lineno.
index d9d9e6d9be81109b2dad4e9dde85ea42cbba6099..69f99c9db16c1f39338476ef5de208aaec0fe7e5 100644 (file)
@@ -11,7 +11,7 @@ aclocal_macros = libtool.m4
 
 noinst_SCRIPTS = lineno
 EXTRA_DIST = $(aclocal_macros) libtoolize.in ltconfig.in ltmain.sh.in \
-       libtool.spec libtool.prj
+       libtool.spec libtool.prj $(noinst_SCRIPTS)
 CLEANFILES = libtool libtoolize
 MAINTAINERCLEANFILES = ltconfig ltmain.sh
 
diff --git a/NEWS b/NEWS
index 2fa15215a1999796a70e609126b29a185a31d9d6..f6d50183143d762916964d3216b2d38f5ffd42bb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,20 +2,21 @@ NEWS - list of user-visible changes between releases of GNU libtool.
 
 New in 1.0b:
 * Bug fixes.
-* Full support for broken collect2 on AIX 3.  Now, shared libraries
-  can be built with all working versions of GCC.
-* New rules for AM_PROG_LD to use gcc's -print-prog-name flag in order
-  to find ld, if possible.
+* Suppress duplicate compiler output during `compile' mode.
+* New `execute' mode to support debugging uninstalled libtool
+  libraries and executables.
 * Deleted `dlname' mode.  Dlopen applications should only use the
   runtime search method described in (libtool)Finding the dlname.
 * Experimental support for dynamically loaded modules, even on
-  static-only platforms, via new `-dlopen' and `-pre-dlopen' link
+  static-only platforms, via new `-dlopen' and `-dlpreopen' link
   flags.
-* New tests for a BSD-compatible `nm' program, required for dlopened
-  modules.
+* New rules for AM_PROG_LD to use gcc's -print-prog-name flag in order
+  to find ld, if possible.
+* Full support for broken collect2 on AIX 3.  Shared libraries
+  can now be built with all working versions of GCC.
 * Allow configure.in to change the defaults for AM_PROG_LIBTOOL's
-  `--enable-{shared,static}' by setting `enable_{shared,static}=no'.
-* Suppress duplicate compiler output during `compile' mode.
+  `--enable-shared' and `--enable-static' flags by setting
+  the `enable_shared' or `enable_static' shell variables to `no'.
 \f
 New in 1.0:
 * Bug fixes.
diff --git a/TODO b/TODO
index 72fae7df13cd2bc00c051f5682f6202818fd3ef4..1e8ede8b3c5544aa61a284b321021d616e97f76c 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,26 +1,40 @@
 For next public release:
 ************************
 
-* Kenneth Albanowski suggests an `execute' mode, where the paths from
-libtool libraries are extracted and put into shlibpath_var, then a
-command is executed with the wrapped binary as argument.
+* Document `execute' mode, and the experimental nature of -dlopen and
+-dlpreopen.
 
- KA> And 'libtool --mode=execute java test Java/libJavaPisock.la
- KA> libsock/libpisock.la' turns into:
+* Some packages, such as GIMP, choose to put a note about
+`--disable-shared' in their README:
 
- KA> LD_LIBRARY_PATH="libsock/.libs:Java/.libs" java test
+----------------------------------------------------------------------
+The GIMP uses GNU libtool in order to build shared libraries on a
+variety of systems. While this is very nice for making usable
+binaries, it can be a pain when trying to debug a program. For that
+reason, compilation of shared libraries can be turned off by
+specifying the "--disable-shared" option to "configure".
+----------------------------------------------------------------------
+Simply invoke configure in the top-level directory.  Besides the usual
+GNU configure options, there are the following SANE specific options:
 
-I think this is a good idea, but the nonobvious behaviour with libtool
-library arguments should be enabled by a flag, such as -dlopen LIB.
-Maybe -dlpreopen LIB should put these libraries in LD_PRELOAD.
+ --disable-shared
+       Don't use shared libraries.  Useful for debugging or when there
+       is a problem building shared libraries.
+----------------------------------------------------------------------
 
-Use *db | *dbx as triggers for this mode.
+Perhaps a similar note could be added to ABOUT-NLS.
 
-* Document `execute' mode.
+I'll add a suggestion to the libtool documentation, so that other
+maintainers add this kind of note to their package documentation.
 
 In the future:
 **************
 
+* Eliminate broken handling of single-quotes in arguments to
+ltmain.sh.  I've decided that we should backslashify `"', `$' and `\'.
+Then, if there are any other metacharacters in the argument, surround
+it with double quotes.
+
 * Implement full multi-language support.  Currently, this is only for
 C++, but there are beginnings of this in the manual (Other Languages).
 This includes writing libtool not to be so dependent on the compiler
index 9ac33addde30e9677cd8f4fa72ce97ff6d3cd266..d9b8ce654de92f4de65861b1ee85cc9ed1739727 100644 (file)
@@ -1963,10 +1963,10 @@ aborts the program before it runs.
 @item
 Dlopening a module, so that the application can resolve its own,
 dynamically-computed references.  If there is an error opening the
-module, then the application can
+module, or the module is not found, then the application can recover
+without crashing.
 @end enumerate
 
-
 @node Finding the dlname
 @section Finding the correct name to dlopen
 @cindex Names of dynamic modules
@@ -1976,8 +1976,9 @@ After a library has been linked with @samp{-export-dynamic}, it can be
 dlopened.  Unfortunately, because of the variation in library names,
 your package needs to determine the correct file to dlopen.
 
-The basic implementation is to determine the name at runtime, by finding
-the installed @samp{.la} file, and searching it for the following lines:
+The most straightforward and flexible implementation is to determine the
+name at runtime, by finding the installed @samp{.la} file, and searching
+it for the following lines:
 
 @example
 # The name that we can @code{dlopen(3)}.
index 257cf84a6962faea5489bc8543d3f9f793593b62..21a9be8fe0eefa0f6df60ee772c90f9fc794d261 100644 (file)
 # configuration script generated by Autoconf, you may include it under
 # the same distribution terms that you use for the rest of that program.
 
+# WARNING: An implicit problem with writing libtool as a shell script
+# is that arguments with embedded whitespace probably will cause
+# problems, and arguments with embedded single quotes *definitely*
+# will cause problems.
+
+# It would take a serious effort to fix the problems with whitespace.
+# These occur because we use space-separated arguments to "for"
+# commands.  It is nearly impossible to fix the problems with single
+# quotes, because we use them to do quoting in strings that we "eval".
+
 # The name of this program.
 progname=`echo "$0" | sed 's%^.*/%%'`
 
@@ -66,6 +76,7 @@ prevopt=
 run=
 show=echo
 show_help=
+execute_dlfiles=
 
 # Parse our command line options once, thoroughly.
 while test $# -gt 0
@@ -80,7 +91,15 @@ do
 
   # If the previous option needs an argument, assign it.
   if test -n "$prev"; then
-    eval "$prev=\$arg"
+    case "$prev" in
+    execute_dlfiles)
+      eval "$prev=\"\$$prev \$arg\""
+      ;;
+    *)
+      eval "$prev=\$arg"
+      ;;
+    esac
+
     prev=
     prevopt=
     continue
@@ -125,6 +144,11 @@ do
     show=:
     ;;
 
+  -dlopen)
+    prevopt="-dlopen"
+    prev=execute_dlfiles
+    ;;
+
   -*)
     echo "$progname: unrecognized option \`$arg'" 1>&2
     echo "$help" 1>&2
@@ -138,14 +162,12 @@ do
   esac
 done
 
-
 if test -n "$prevopt"; then
   echo "$progname: option \`$prevopt' requires an argument" 1>&2
   echo "$help" 1>&2
   exit 1
 fi
 
-
 if test -z "$show_help"; then
 
   # Infer the operation mode.
@@ -163,6 +185,9 @@ if test -z "$show_help"; then
         esac
       done
       ;;
+    *db | *dbx)
+      mode=execute
+      ;;
     *install*|cp)
       mode=install
       ;;
@@ -170,6 +195,9 @@ if test -z "$show_help"; then
       mode=uninstall
       ;;
     *)
+      # If we have no mode, but dlfiles were specified, then do execute mode.
+      test -n "$execute_dlfiles" && mode=execute
+
       # Just use the default operation mode.
       if test -z "$mode"; then
         if test -n "$nonopt"; then
@@ -182,6 +210,13 @@ if test -z "$show_help"; then
     esac
   fi
 
+  # Only execute mode is allowed to have -dlopen flags.
+  if test -n "$execute_dlfiles" && test "$mode" != execute; then
+    echo "$progname: unrecognized option \`-dlopen'" 1>&2
+    echo "$help" 1>&2
+    exit 1
+  fi
+
   # Change the help message to a mode-specific one.
   generic_help="$help"
   help="Try \`$progname --help --mode=$mode' for more information."
@@ -200,10 +235,15 @@ if test -z "$show_help"; then
     for arg
     do
       # Quote any args containing shell metacharacters.
+      # Many Bourne shells cannot handle close brackets correctly in scan
+      # sets, so we specify it separately.
       case "$arg" in
-      *" "*|*"  "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*|*\"*)
-         quote_arg="'$arg'" ;;
-      *) quote_arg="$arg" ;;
+      *[[~#$^\&*\(\){}\\\|\;\<\>?\ \   \"]*|*]*)
+       quote_arg="'$arg'"
+       ;;
+      *)
+       quote_arg="$arg"
+       ;;
       esac
 
       base_compile="$base_compile$lastarg"
@@ -445,7 +485,7 @@ if test -z "$show_help"; then
         # Find the relevant object directory and library name.
         file=`echo "$arg" | sed 's%^.*/%%'`
         dir=`echo "$arg" | sed 's%/[^/]*$%/%'`
-        test "$dir" = "$arg" && dir=
+        test "X$dir" = "X$arg" && dir=
 
         # Standard archive.
         objs="$objs $arg"
@@ -512,7 +552,7 @@ if test -z "$show_help"; then
         # Find the relevant object directory and library name.
         name=`echo "$arg" | sed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'`
         dir=`echo "$arg" | sed 's%/[^/]*$%%'`
-        if test "$dir" = "$arg"; then
+        if test "X$dir" = "X$arg"; then
           dir="$objdir"
         else
           dir="$dir/$objdir"
@@ -1187,9 +1227,12 @@ if test "\$libtool_install_magic" = "$magic"; then
   link_against_libtool_libs='$link_against_libtool_libs'
   finalize_command='$finalize_command'
 else
+  # When we are sourced in execute mode, \$file is already set.
+  test "\$libtool_execute_magic" = "$magic" || file="\$0"
+
   # Find the directory that this script lives in.
-  thisdir=\`echo \$0 | sed 's%/[^/]*$%%'\`
-  test "x\$thisdir" = "x\$0" && thisdir=.
+  thisdir=\`echo "\$file" | sed 's%/[^/]*$%%'\`
+  test "x\$thisdir" = "x\$file" && thisdir=.
 
   # Try to get the absolute directory name.
   absdir=\`cd "\$thisdir" && pwd\`
@@ -1198,27 +1241,20 @@ else
   progdir="\$thisdir/$objdir"
   program='$output'
 
-  # If the \$0 dir failed (maybe due to symlink), try a hardcoded dir.
-  test -f "\$progdir/\$program" || progdir='`pwd`/$objdir'
+  # If the \$file dir failed (maybe due to symlink), try a hardcoded dir.
+  oprogdir="\$progdir"
+  if test -f "\$progdir/\$program"; then :
+  else
+    thisdir='`pwd`'
+    progdir="\$thisdir/$objdir"
+  fi
 
   if test -f "\$progdir/\$program"; then
-    # Run the actual program with our arguments.
-    args=
-    for arg
-    do
-      # Quote arguments (to preserve shell metacharacters).
-      args="\$args '\$arg'"
-    done
-
-    # Export the path to the program.
-    PATH="\$progdir:\$PATH"
-    export PATH
 EOF
 
         # Export our shlibpath_var if we have one.
         if test -n "$shlibpath_var" && test -n "$temp_rpath"; then
           cat >> $output <<EOF
-
     # Add our own library path to $shlibpath_var
     $shlibpath_var="$temp_rpath\$$shlibpath_var"
 
@@ -1226,18 +1262,32 @@ EOF
     $shlibpath_var=\`echo \$$shlibpath_var | sed -e 's/:*\$//'\`
 
     export $shlibpath_var
+
 EOF
         fi
 
         cat >> $output <<EOF
+    if test "\$libtool_execute_magic" != "$magic"; then
+      # Run the actual program with our arguments.
+      args=
+      for arg
+      do
+        # Quote arguments (to preserve shell metacharacters).
+        args="\$args '\$arg'"
+      done
 
-    eval "exec \$program \$args"
+      # Export the path to the program.
+      PATH="\$progdir:\$PATH"
+      export PATH
 
-    echo "\$0: cannot exec \$program \$args"
-    exit 1
+      eval "exec \$program \$args"
+
+      echo "\$0: cannot exec \$program \$args"
+      exit 1
+    fi
   else
     # The program doesn't exist.
-    echo "\$0: error: neither \$thisdir/$objdir/\$program nor \$progdir/\$program exists" 1>&2
+    echo "\$0: error: neither \$oprogdir/\$program nor \$progdir/\$program exists" 1>&2
     echo "This script is just a wrapper for \$program." 1>&2
     echo "See the $PACKAGE documentation for more information." 1>&2
     exit 1
@@ -1400,7 +1450,7 @@ EOF
       destname=
     else
       destdir=`echo "$dest" | sed 's%/[^/]*$%%'`
-      test "$destdir" = "$dest" && destdir=.
+      test "X$destdir" = "X$dest" && destdir=.
       destname=`echo "$dest" | sed 's%^.*/%%'`
 
       # Not a directory, so check to see that there is only one file specified.
@@ -1427,6 +1477,10 @@ EOF
       ;;
     esac
 
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
     staticlibs=
     future_libdirs=
     current_libdirs=
@@ -1457,7 +1511,7 @@ EOF
         esac
 
         # Add the libdir to current_libdirs if it is the destination.
-        if test "$destdir" = "$libdir"; then
+        if test "X$destdir" = "X$libdir"; then
           case "$current_libdirs " in
           "* $libdir *") ;;
           *) current_libdirs="$current_libdirs $libdir" ;;
@@ -1471,7 +1525,7 @@ EOF
         fi
 
         dir="`echo "$file" | sed 's%/[^/]*$%%'`/"
-        test "$dir" = "$file/" && dir=
+        test "X$dir" = "X$file/" && dir=
         dir="$dir$objdir"
 
         # See the names of the shared library.
@@ -1588,10 +1642,7 @@ EOF
 
       *)
         # Do a test to see if this is really a libtool program.
-        if egrep "^# Generated by ltmain.sh" $file >/dev/null 2>&1; then
-          # This variable tells wrapper scripts just to set variables rather
-          # than running their programs.
-          libtool_install_magic="$magic"
+        if egrep '^# Generated by ltmain.sh' $file >/dev/null 2>&1; then
           link_against_libtool_libs=
           finalize_command=
 
@@ -1643,12 +1694,7 @@ EOF
             fi
           else
             # Install the binary that we compiled earlier.
-            dir=`echo "$file" | sed 's%/[^/]*$%%'`
-            if test "$file" = "$dir"; then
-              file="$objdir/$file"
-            else
-              file="$dir/$objdir/`echo "$file" | sed 's%^.*/%%'`"
-            fi
+           file=`echo "$file" | sed "s%\([^/]*\)$%$objdir/\1%"`
           fi
         fi
 
@@ -1734,6 +1780,135 @@ EOF
     exit 0
     ;;
 
+  # libtool execute mode
+  execute)
+    progname="$progname: execute"
+
+    # The first argument is the command name.
+    cmd="$nonopt"
+    if test -z "$cmd"; then
+      echo "$progname: you must specify a COMMAND" 1>&2
+      echo "$help"
+      exit 1
+    fi
+
+    # Handle -dlopen flags immediately.
+    for file in $execute_dlfiles; do
+      if test -f "$file"; then :
+      else
+       echo "$progname: \`$file' is not a file" 1>&2
+       echo "$help" 1>&2
+       exit 1
+      fi
+
+      dir=
+      case "$file" in
+      *.la)
+        # Check to see that this really is a libtool archive.
+        if egrep "^# Generated by ltmain.sh" $file >/dev/null 2>&1; then :
+        else
+          echo "$progname: \`$lib' is not a valid libtool archive" 1>&2
+          echo "$help" 1>&2
+          exit 1
+        fi
+
+       # Read the libtool library.
+       dlname=
+       library_names=
+
+        # If there is no directory component, then add one.
+       case "$file" in
+       */*) . $file ;;
+        *) . ./$file ;;
+       esac
+
+       # Skip this library if it cannot be dlopened.
+       if test -z "$dlname"; then
+         # Warn if it was a shared library.
+         test -n "$library_names" && echo "$progname: warning: \`$file' was not linked with \`-export-dynamic'"
+         continue
+       fi
+
+       dir=`echo "$file" | sed 's%/[^/]*$%%'`
+       test "X$dir" = "X$file" && dir=.
+
+       if test -f "$dir/$objdir/$dlname"; then
+         dir="$dir/$objdir"
+       else
+         echo "$progname: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
+         exit 1
+       fi
+       ;;
+
+      *.lo)
+       # Just add the directory containing the .lo file.
+       dir=`echo "$file" | sed 's%/[^/]*$%%'`
+       test "X$dir" = "X$file" && dir=.
+       ;;
+
+      *)
+       echo "$progname: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
+        continue
+       ;;
+      esac
+
+      # Get the absolute pathname.
+      absdir=`cd "$dir" && pwd`
+      test -n "$absdir" && dir="$absdir"
+
+      # Now add the directory to shlibpath_var.
+      if eval "test -z \"\$$shlibpath_var\""; then
+       eval "$shlibpath_var=\"\$dir\""
+      else
+       eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+      fi
+    done
+
+    # This variable tells wrapper scripts just to set shlibpath_var
+    # rather than running their programs.
+    libtool_execute_magic="$magic"
+
+    # Check if any of the arguments is a wrapper script.
+    args=
+    for file
+    do
+      case "$file" in
+      -*) ;;
+      *)
+       if egrep '^# Generated by ltmain.sh' $file >/dev/null 2>&1; then
+         # If there is no directory component, then add one.
+         case "$file" in
+         */*) . $file ;;
+         *) . ./$file ;;
+         esac
+
+         # Transform arg to wrapped name.
+         file="$progdir/$program"
+       fi
+        ;;
+      esac
+      # Quote arguments (to preserve shell metacharacters).
+      args="$args '$file'"
+    done
+
+    if test -z "$run"; then
+      # Export the shlibpath_var.
+      eval "export $shlibpath_var"
+
+      # Now actually exec the command.
+      eval "exec '$cmd'$args"
+
+      echo "$progname: cannot exec '$cmd'$args"
+      exit 1
+    else
+      # Display what would be done.
+      eval "echo \"\$shlibpath_var=\$$shlibpath_var\""
+      echo "export $shlibpath_var"
+      echo "'$cmd'$args"
+      exit 0
+    fi
+    ;;
+
   # libtool uninstall mode
   uninstall)
     progname="$progname: uninstall"
@@ -1756,7 +1931,7 @@ EOF
 
     for file in $files; do
       dir=`echo "$file" | sed -e 's%/[^/]*$%%'`
-      test "$dir" = "$file" && dir=.
+      test "X$dir" = "X$file" && dir=.
       name=`echo "$file" | sed -e 's%^.*/%%'`
 
       rmfiles="$file"
@@ -1824,6 +1999,7 @@ Provide generalized library-building support services.
 MODE must be one of the following:
 
       compile         compile a source file into a libtool object
+      execute         automatically set library path, then run a program
       finish          complete the installation of libtool libraries
       install         install libraries or executables
       link            create a library or an executable
@@ -1849,6 +2025,27 @@ library object suffix, \`.lo'.
 EOF
   ;;
 
+execute)
+  cat <<EOF
+Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+  -dlopen FILE      add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments.
+EOF
+  ;;
+
 finish)
   cat <<EOF
 Usage: $progname [OPTION]... --mode=finish [LIBDIR]...