libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

abs-bindir Was: bindir for libtool


From: Roumen Petrov
Subject: abs-bindir Was: bindir for libtool
Date: Mon, 02 Nov 2009 23:57:28 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.23) Gecko/20090907 SeaMonkey/1.1.18

Ralf Wildenhues wrote:
Hi Charles,
[SNIP]

I agree.

I'd suggest, perhaps, adding a *different* libtool option, e.g.
-abs-bindir, that works semantically as Roumen desires. Then, later, gcc
may choose to use either -bindir or -abs-bindir, whatever seems best to
them. I'm probably overlooking something with this suggestion, but I'd
prefer if, rather than extending this thread and delaying #1 above any
longer, we postpone discussion of how what I've just said is all wrong
until after #1, and we're into the discussion of #2.

We can think about -abs-bindir.  #1 is waiting to be committed to GNU
Libtool only for the finishing of DaveK's copyright papers; then I will
commit it (along with a couple of fixes, one of which has shown up in
GCC already and the other is in Libtool testsuite-only code).

Just updated to master, but without tests - I don't have time to write them , may be next month :(

Regards
diff --git a/ChangeLog b/ChangeLog
index caf125a..ebabba8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-09-28  Roumen Petrov  <address@hidden>
+
+       Control where to place shared libraries for system without
+       shared library path variable different from PATH.
+       * libltdl/config/ltmain.m4sh (func_mode_help):
+       Document "-abs-bindir".
+       (func_mode_link, func_mode_install, func_mode_uninstall):
+       Accept new "-abs-bindir" option and use it, if supplied.
+       * libltdl/m4/libtool.m4: support absolute path for DLLs.
+       Pass environment variable DESTDIR to post{un}install commands.
+       * libltdl/ltdl.c: support absolute path for dynamic module.
+       * NEWS: Update.
+
 2009-11-01  Ralf Wildenhues  <address@hidden>
 
        Fix func_normal_abspath sed script for Solaris.
diff --git a/NEWS b/NEWS
index 80f0413..d0b88a1 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,8 @@ New in 2.2.8 2009-??-??: git version 2.2.7a, Libtool team:
     runs on Windows with popup windows in the middle, and `check-interactive'
     for the complement set of tests.
   - New link mode flag -bindir to specify the location for installed PE DLLs.
+  - New flag -abs-bindir for modes link,install,uninstall to specify the
+    absolute location for installed PE DLLs.
 
 * Changes in supported systems or compilers:
 
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 91d0800..0a17a41 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -1112,7 +1112,9 @@ The following components of INSTALL-COMMAND are treated 
specially:
   -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for 
installation
 
 The rest of the components are interpreted as arguments to that command (only
-BSD-compatible install options are recognized)."
+BSD-compatible install options are recognized). Exception is argument
+\`-abs-bindir'. This argument specify where to place shared libraries(DLLs)
+for system without shared library path variable different from PATH."
         ;;
 
       link)
@@ -1131,6 +1133,11 @@ The following components of LINK-COMMAND are treated 
specially:
   -avoid-version    do not add a version suffix if possible
   -bindir BINDIR    specify path to binaries directory (for systems where
                     libraries must be found in the PATH setting at runtime)
+  -abs-bindir ABS_BINDIR
+                    specify path to binaries directory (for system without
+                    shared library path variable different from PATH).
+                    Symilar to -bindir but without internal relative path
+                    calculation.
   -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
@@ -1191,6 +1198,12 @@ Remove libraries from an installation directory.
 RM is the name of the program to use to delete files associated with each FILE
 (typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
 to RM.
+The following components of RM-OPTIONS are treated specially:
+
+  -abs-bindir ABS_BINDIR
+              Use ABS_BINDIR to find shared libraries (DLLs) for system without
+              shared library path variable different from PATH. Used only if
+              FILE is a libtool library.
 
 If FILE is a libtool library, all the files associated with it are deleted.
 Otherwise, only FILE itself is deleted using RM."
@@ -1451,6 +1464,9 @@ test "$mode" = finish && func_mode_finish ${1+"$@"}
 # func_mode_install arg...
 func_mode_install ()
 {
+    inst_destdir=
+    test -n "$DESTDIR" && inst_destdir=$DESTDIR
+
     $opt_debug
     # There may be an optional sh(1) argument at the beginning of
     # install_prog (especially on Windows NT).
@@ -1477,6 +1493,10 @@ func_mode_install ()
       *) install_cp=false ;;
     esac
 
+    # heuristic location of shared libraries for system without
+    # shared library path variable different from PATH
+    dlbindir=../bin
+
     # We need to accept at least all the BSD install flags.
     dest=
     files=
@@ -1509,16 +1529,29 @@ func_mode_install ()
        stripme=" -s"
        continue
        ;;
+      -abs-bindir)
+       prev=abs_bindir
+       continue
+       ;;
       -*)
        ;;
       *)
        # If the previous option needed an argument, then skip it.
        if test -n "$prev"; then
+         case "$prev" in
+           abs_bindir)
+             dlbindir="$arg"
+             prev=
+             continue
+           ;;
+           *)
          if test "x$prev" = x-m && test -n "$install_override_mode"; then
            arg2=$install_override_mode
            no_mode=false
          fi
          prev=
+           ;;
+         esac
        else
          dest=$arg
          continue
@@ -1698,7 +1731,7 @@ func_mode_install ()
 
          # Do each command in the postinstall commands.
          lib="$destdir/$realname"
-         func_execute_cmds "$postinstall_cmds" 'exit $?'
+         func_execute_cmds 
"inst_destdir=$inst_destdir~dlbindir=$dlbindir~$postinstall_cmds" 'exit $?'
        fi
 
        # Install the pseudo-library for information purposes.
@@ -3666,6 +3699,9 @@ func_mode_link ()
 
     avoid_version=no
     bindir=
+    # heuristic location of shared libraries for system without
+    # shared library path variable different from PATH
+    dlbindir=../bin
     dlfiles=
     dlprefiles=
     dlself=no
@@ -3763,6 +3799,11 @@ func_mode_link ()
          prev=
          continue
          ;;
+       abs_bindir)
+         dlbindir="$arg"
+         prev=
+         continue
+         ;;
        dlfiles|dlprefiles)
          if test "$preload" = no; then
            # Add the symbol object into the linking commands.
@@ -4029,6 +4070,11 @@ func_mode_link ()
        continue
        ;;
 
+      -abs-bindir)
+       prev=abs_bindir
+       continue
+       ;;
+
       -dlopen)
        prev=dlfiles
        continue
@@ -7738,8 +7784,7 @@ EOF
                func_relative_path "$install_libdir" "$bindir"
                tdlname=$func_relative_path_result$dlname
              else
-               # Otherwise fall back on heuristic.
-               tdlname=../bin/$dlname
+               tdlname=$dlbindir/$dlname
              fi
              ;;
          esac
@@ -7813,16 +7858,36 @@ func_mode_uninstall ()
     rmforce=
     exit_status=0
 
+    inst_destdir=
+    test -n "$DESTDIR" && inst_destdir=$DESTDIR
+
+    # heuristic location of shared libraries for system without
+    # shared library path variable different from PATH
+    dlbindir=../bin
+
     # This variable tells wrapper scripts just to set variables rather
     # than running their programs.
     libtool_install_magic="$magic"
 
+    prev=
     for arg
     do
       case $arg in
+      -abs-bindir)
+        prev=abs_bindir
+        continue
+        ;;
       -f) RM="$RM $arg"; rmforce=yes ;;
       -*) RM="$RM $arg" ;;
-      *) files="$files $arg" ;;
+      *)
+        case $prev in
+          abs_bindir)
+            dlbindir="$arg"
+            prev=
+            continue
+            ;;
+        esac
+        files="$files $arg" ;;
       esac
     done
 
@@ -7890,7 +7955,7 @@ func_mode_uninstall ()
          uninstall)
            if test -n "$library_names"; then
              # Do each command in the postuninstall commands.
-             func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || 
exit_status=1'
+             func_execute_cmds 
"inst_destdir=$inst_destdir~dlbindir=$dlbindir~$postuninstall_cmds" 'test 
"$rmforce" = yes || exit_status=1'
            fi
 
            if test -n "$old_library"; then
diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c
index 80b5675..20d2f14 100644
--- a/libltdl/ltdl.c
+++ b/libltdl/ltdl.c
@@ -480,7 +480,7 @@ tryall_dlopen_module (lt_dlhandle *handle, const char 
*prefix,
   int      error       = 0;
   char     *filename   = 0;
   size_t   filename_len        = 0;
-  size_t   dirname_len = LT_STRLEN (dirname);
+  size_t   dirname_len;
 
   assert (handle);
   assert (dirname);
@@ -491,10 +491,16 @@ tryall_dlopen_module (lt_dlhandle *handle, const char 
*prefix,
   assert (strchr (dirname, LT_DIRSEP_CHAR) == 0);
 #endif
 
-  if (dirname_len > 0)
-    if (dirname[dirname_len -1] == '/')
-      --dirname_len;
-  filename_len = dirname_len + 1 + LT_STRLEN (dlname);
+  if (*dlname == '/')
+    filename_len = LT_STRLEN (dlname);
+  else
+    {
+      dirname_len = LT_STRLEN (dirname);
+      if (dirname_len > 0)
+        if (dirname[dirname_len -1] == '/')
+          --dirname_len;
+      filename_len = dirname_len + 1 + LT_STRLEN (dlname);
+    }
 
   /* Allocate memory, and combine DIRNAME and MODULENAME into it.
      The PREFIX (if any) is handled below.  */
@@ -502,7 +508,10 @@ tryall_dlopen_module (lt_dlhandle *handle, const char 
*prefix,
   if (!filename)
     return 1;
 
-  sprintf (filename, "%.*s/%s", (int) dirname_len, dirname, dlname);
+  if (*dlname == '/')
+    strncpy (filename, dlname, filename_len + 1);
+  else
+    sprintf (filename, "%.*s/%s", (int) dirname_len, dirname, dlname);
 
   /* Now that we have combined DIRNAME and MODULENAME, if there is
      also a PREFIX to contend with, simply recurse with the arguments
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 02b49c9..229a41b 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -2200,10 +2200,15 @@ cygwin* | mingw* | pw32* | cegcc*)
   case $GCC,$host_os in
   yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
     library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    # Install DLL into specified location if path is absolute.
+    # Use -abs-bindir command line argument to set it.
     postinstall_cmds='base_file=`basename \${file}`~
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo 
\$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
+      dldir=`dirname \$dlpath`~
+      case \$dldir in
+        /*) dldir=\$inst_destdir\$dlbindir;;
+        *)  dldir=\$destdir;;
+      esac~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
       chmod a+x \$dldir/$dlname~
@@ -2211,7 +2216,11 @@ cygwin* | mingw* | pw32* | cegcc*)
         eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
       fi'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
+      case \$dldll in
+        /*) base_file=`basename \${dldll}`;
+            dlpath=\$inst_destdir\$dlbindir/\$base_file;;
+        *)  dlpath=$dir/\$dldll;;
+      esac~
        $RM \$dlpath'
     shlibpath_overrides_runpath=yes
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]