libtool-patches
[Top][All Lists]
Advanced

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

Re: [PATCH, take 4][cygwin|mingw] Control where win32 DLLs get installed


From: Roumen Petrov
Subject: Re: [PATCH, take 4][cygwin|mingw] Control where win32 DLLs get installed.
Date: Fri, 21 Aug 2009 00:41:15 +0300
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.22) Gecko/20090624 SeaMonkey/1.1.17

Hi Charles,

Charles Wilson wrote:
Roumen Petrov wrote:

[SNIP]

If you can come up with a mechanism to use absolute paths in dlname,
which does not break any of the known installation modes, works whether
the installation tree(s) are pre-created or NOT, and whether the final
installation tree contains symlinks or NOT, AND solves the issue with
getting DLLs on w32 into the correct directory AND that the installed
.la file correctly describes its location...

Then please show us the code. And the test results. On as many systems
as Dave has, especially including mingw, cygwin, linux, and various
cross environments.

Please find attached file "libtool-origin-bindir.patch" with my
idea for absolute path in la-file.

[SNIP]
--
Chuck


Roumen
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index d8c5749..381bef5 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -1129,6 +1129,8 @@ The following components of LINK-COMMAND are treated 
specially:
 
   -all-static       do not do any dynamic linking at all
   -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)
   -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)
@@ -1631,10 +1633,10 @@ func_mode_install ()
        dir="$func_dirname_result"
        dir="$dir$objdir"
 
-       if test -n "$relink_command"; then
-         # Determine the prefix the user has applied to our future dir.
-         inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
+       # Determine the prefix the user has applied to our future dir.
+       inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
 
+       if test -n "$relink_command"; then
          # Don't allow the user to place us outside of our expected
          # location b/c this prevents finding dependent libraries that
          # are installed to the same prefix.
@@ -1696,7 +1698,7 @@ func_mode_install ()
 
          # Do each command in the postinstall commands.
          lib="$destdir/$realname"
-         func_execute_cmds "$postinstall_cmds" 'exit $?'
+         func_execute_cmds 
"inst_prefix_dir=$inst_prefix_dir~$postinstall_cmds" 'exit $?'
        fi
 
        # Install the pseudo-library for information purposes.
@@ -3674,6 +3676,9 @@ func_mode_link ()
     new_inherited_linker_flags=
 
     avoid_version=no
+    # heuristic location of shared libraries for system without
+    # shared library path variable different from PATH
+    dlbindir=../bin
     dlfiles=
     dlprefiles=
     dlself=no
@@ -3766,6 +3771,11 @@ func_mode_link ()
        esac
 
        case $prev in
+       bindir)
+         dlbindir="$arg"
+         prev=
+         continue
+         ;;
        dlfiles|dlprefiles)
          if test "$preload" = no; then
            # Add the symbol object into the linking commands.
@@ -4027,6 +4037,11 @@ func_mode_link ()
        continue
        ;;
 
+      -bindir)
+       prev=bindir
+       continue
+       ;;
+
       -dlopen)
        prev=dlfiles
        continue
@@ -7721,7 +7736,8 @@ EOF
          # place dlname in correct position for cygwin
          tdlname=$dlname
          case $host,$output,$installed,$module,$dlname in
-           *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | 
*cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
+           *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | 
*cegcc*,*lai,yes,no,*.dll)
+             tdlname=$dlbindir/$dlname;;
          esac
          $ECHO > $output "\
 # $outputname - a libtool library file
diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c
index 80b5675..ea5d51f 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 = (*dlname == '/') ? (size_t)0: LT_STRLEN (dirname);
 
   assert (handle);
   assert (dirname);
@@ -494,7 +494,7 @@ tryall_dlopen_module (lt_dlhandle *handle, const char 
*prefix,
   if (dirname_len > 0)
     if (dirname[dirname_len -1] == '/')
       --dirname_len;
-  filename_len = dirname_len + 1 + LT_STRLEN (dlname);
+  filename_len = (*dlname == '/' ? (size_t)0 : (dirname_len + 1)) + LT_STRLEN 
(dlname);
 
   /* Allocate memory, and combine DIRNAME and MODULENAME into it.
      The PREFIX (if any) is handled below.  */
@@ -502,7 +502,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 3a65ec4..18710b0 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -2163,10 +2163,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 -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_prefix_dir\$dldir;;
+        *)  dldir=\$destdir/\$dldir;;
+      esac~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
       chmod a+x \$dldir/$dlname~

reply via email to

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