]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Makefile.am (libgomp_la_LDFLAGS): Add -bindir flag.
authorDave Korn <dave.korn.cygwin@gmail.com>
Thu, 20 Aug 2009 11:11:34 +0000 (11:11 +0000)
committerDave Korn <davek@gcc.gnu.org>
Thu, 20 Aug 2009 11:11:34 +0000 (11:11 +0000)
libgomp/ChangeLog:

* Makefile.am (libgomp_la_LDFLAGS): Add -bindir flag.
* Makefile.in: Regenerate.

ChangeLog:

* ltmain.sh (func_normal_abspath): New function.
(func_relative_path): Likewise.
(func_mode_help): Document new -bindir option for link mode.
(func_mode_link): Add new -bindir option, and use it to place
output DLL if specified.

libgfortran/ChangeLog:

* Makefile.am (LTLDFLAGS): Add -bindir flag.
* Makefile.in: Regenerate.

libssp/ChangeLog:

* Makefile.am (libssp_la_LDFLAGS): Add -bindir flag.
* Makefile.in: Regenerate.

libjava/libltdl/ChangeLog:

* Makefile.am (libltdl_la_LDFLAGS): Add -bindir flag.
* Makefile.in: Regenerate.

libjava/classpath/ChangeLog:

* ltmain.sh (func_normal_abspath): New function.
(func_relative_path): Likewise.
(func_mode_help): Document new -bindir option for link mode.
(func_mode_link): Add new -bindir option, and use it to place
output DLL if specified.

From-SVN: r150960

16 files changed:
ChangeLog
libgfortran/ChangeLog
libgfortran/Makefile.am
libgfortran/Makefile.in
libgomp/ChangeLog
libgomp/Makefile.am
libgomp/Makefile.in
libjava/classpath/ChangeLog
libjava/classpath/ltmain.sh
libjava/libltdl/ChangeLog
libjava/libltdl/Makefile.am
libjava/libltdl/Makefile.in
libssp/ChangeLog
libssp/Makefile.am
libssp/Makefile.in
ltmain.sh

index 98bcd08c685ca70a126db9c2782e0939474f389f..fb79190010850fcdd6659758fa5d3db16bfd38b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-08-20  Dave Korn  <dave.korn.cygwin@gmail.com>
+
+       * ltmain.sh (func_normal_abspath): New function.
+       (func_relative_path): Likewise.
+       (func_mode_help): Document new -bindir option for link mode.
+       (func_mode_link): Add new -bindir option, and use it to place
+       output DLL if specified.
+
 2009-08-19  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * configure.ac: Call AC_DISABLE_OPTION_CHECKING.
index abeac8a9525e64c3e193531adcb29135ab2d4d4a..7a0f056c9c987bb3cbb5d95462675b30c7769eff 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-20  Dave Korn  <dave.korn.cygwin@gmail.com>
+
+       * Makefile.am (LTLDFLAGS): Add -bindir flag.
+       * Makefile.in: Regenerate.
+
 2009-08-17  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/41075
index 26565a2daea7181f131fb0fac147a6c62f90f1a1..35e0a3d138f7159865d2fdb6908eb4cb6033e872 100644 (file)
@@ -14,7 +14,7 @@ version_arg =
 endif
 
 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) \
-           -no-undefined
+           -no-undefined -bindir "$(bindir)"
 
 toolexeclib_LTLIBRARIES = libgfortran.la
 libgfortran_la_LINK = $(LINK)
index b724ee3b4783edb27bc4401b63714f61cd507a7c..ca995f72c7544db6e3638930bf36294168a7857d 100644 (file)
@@ -958,7 +958,7 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 @LIBGFOR_USE_SYMVER_FALSE@version_arg = 
 @LIBGFOR_USE_SYMVER_TRUE@version_arg = -Wl,--version-script=$(srcdir)/gfortran.map
 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) \
-           -no-undefined
+           -no-undefined -bindir "$(bindir)"
 
 toolexeclib_LTLIBRARIES = libgfortran.la
 libgfortran_la_LINK = $(LINK)
index 26ec062906219249926b64f77aeb4e65b939b1cd..4a6c30871953330280b5b2d8dae2040834784489 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-20  Dave Korn  <dave.korn.cygwin@gmail.com>
+
+       * Makefile.am (libgomp_la_LDFLAGS): Add -bindir flag.
+       * Makefile.in: Regenerate.
+
 2009-08-19  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/41102
index ebb4b6ab8f76ae784e5abddda9f6e966e9e89d62..154b28931dd4f833434caafbfc0af34e4e95bc33 100644 (file)
@@ -28,7 +28,7 @@ libgomp_version_script =
 endif
 libgomp_version_info = -version-info $(libtool_VERSION)
 libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) \
-        -no-undefined
+        -no-undefined -bindir "$(bindir)"
 
 libgomp_la_SOURCES = alloc.c barrier.c critical.c env.c error.c iter.c \
        iter_ull.c loop.c loop_ull.c ordered.c parallel.c sections.c single.c \
index a1e3afc484b564f828b36a8c0ed455f746769222..a9c8ba43079c5ee7b26649aeaaa19d8a53527b4c 100644 (file)
@@ -305,7 +305,7 @@ nodist_toolexeclib_HEADERS = libgomp.spec
 @LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp_version_script = -Wl,--version-script,$(top_srcdir)/libgomp.map
 libgomp_version_info = -version-info $(libtool_VERSION)
 libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) \
-        -no-undefined
+        -no-undefined -bindir "$(bindir)"
 
 libgomp_la_SOURCES = alloc.c barrier.c critical.c env.c error.c iter.c \
        iter_ull.c loop.c loop_ull.c ordered.c parallel.c sections.c single.c \
@@ -316,9 +316,10 @@ nodist_noinst_HEADERS = libgomp_f.h
 nodist_libsubinclude_HEADERS = omp.h
 @USE_FORTRAN_TRUE@nodist_finclude_HEADERS = omp_lib.h omp_lib.f90 omp_lib.mod omp_lib_kinds.mod
 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
-LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+LINK = $(LIBTOOL) --tag CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
        $(AM_LDFLAGS) $(LTLDFLAGS) -o $@
 
+
 # Automake Documentation:
 # If your package has Texinfo files in many directories, you can use the
 # variable TEXINFO_TEX to tell Automake where to find the canonical
index 445649aae847618e74f8ed9c80f2281b25ff3098..2aed8a6ccd3c8b59277d2a9bc59a7f9f0628c4ed 100644 (file)
@@ -1,3 +1,11 @@
+2009-08-20  Dave Korn  <dave.korn.cygwin@gmail.com>
+
+       * ltmain.sh (func_normal_abspath): New function.
+       (func_relative_path): Likewise.
+       (func_mode_help): Document new -bindir option for link mode.
+       (func_mode_link): Add new -bindir option, and use it to place
+       output DLL if specified.
+
 2009-06-29  Andrew Haley  <aph@redhat.com>
 
        PR java/40590   
index 8dfa0b3b5584265d34f92a05e5eb4fea684d586f..b01cb29a683b675b17f86b02172761c8e2a94a89 100644 (file)
@@ -170,6 +170,151 @@ func_dirname_and_basename ()
 
 # Generated shell functions inserted here.
 
+# These SED scripts presuppose an absolute path with a trailing slash.
+pathcar="s,^/\([^/]*\).*$,\1,"
+pathcdr="s,^/[^/]*,,"
+removedotparts="s,/\(\./\)\{1\,\},/,g;s,/\.$,/,"
+collapseslashes="s,/\{1\,\},/,g"
+finalslash="s,/*$,/,"
+
+# func_normal_abspath PATH
+# Remove doubled-up and trailing slashes, "." path components,
+# and cancel out any ".." path components in PATH after making
+# it an absolute path.
+#             value returned in "$func_normal_abspath_result"
+func_normal_abspath ()
+{
+  # Start from root dir and reassemble the path.
+  func_normal_abspath_result=
+  func_normal_abspath_tpath=$1
+  func_normal_abspath_altnamespace=
+  case $func_normal_abspath_tpath in
+    "")
+      # Empty path, that just means $cwd.
+      func_stripname '' '/' "`pwd`"
+      func_normal_abspath_result=$func_stripname_result
+      return
+    ;;
+    # The next three entries are used to spot a run of precisely
+    # two leading slashes without using negated character classes;
+    # we take advantage of case's first-match behaviour.
+    ///*)
+      # Unusual form of absolute path, do nothing.
+    ;;
+    //*)
+      # Not necessarily an ordinary path; POSIX reserves leading '//'
+      # and for example Cygwin uses it to access remote file shares
+      # over CIFS/SMB, so we conserve a leading double slash if found.
+      func_normal_abspath_altnamespace=/
+    ;;
+    /*)
+      # Absolute path, do nothing.
+    ;;
+    *)
+      # Relative path, prepend $cwd.
+      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
+    ;;
+  esac
+  # Cancel out all the simple stuff to save iterations.  We also want
+  # the path to end with a slash for ease of parsing, so make sure
+  # there is one (and only one) here.
+  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
+  while :; do
+    # Processed it all yet?
+    if test "$func_normal_abspath_tpath" = / ; then
+      # If we ascended to the root using ".." the result may be empty now.
+      if test -z "$func_normal_abspath_result" ; then
+        func_normal_abspath_result=/
+      fi
+      break
+    fi
+    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
+        -e "$pathcar"`
+    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+        -e "$pathcdr"`
+    # Figure out what to do with it
+    case $func_normal_abspath_tcomponent in
+      "")
+        # Trailing empty path component, ignore it.
+      ;;
+      ..)
+        # Parent dir; strip last assembled component from result.
+        func_dirname "$func_normal_abspath_result"
+        func_normal_abspath_result=$func_dirname_result
+      ;;
+      *)
+        # Actual path component, append it.
+        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
+      ;;
+    esac
+  done
+  # Restore leading double-slash if one was found on entry.
+  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
+}
+
+# func_relative_path SRCDIR DSTDIR
+# generates a relative path from SRCDIR to DSTDIR, with a trailing
+# slash if non-empty, suitable for immediately appending a filename
+# without needing to append a separator.
+#             value returned in "$func_relative_path_result"
+func_relative_path ()
+{
+  func_relative_path_result=
+  func_normal_abspath "$1"
+  func_relative_path_tlibdir=$func_normal_abspath_result
+  func_normal_abspath "$2"
+  func_relative_path_tbindir=$func_normal_abspath_result
+
+  # Ascend the tree starting from libdir
+  while :; do
+    # check if we have found a prefix of bindir
+    case $func_relative_path_tbindir in
+      $func_relative_path_tlibdir)
+        # found an exact match
+        func_relative_path_tcancelled=
+        break
+        ;;
+      $func_relative_path_tlibdir*)
+        # found a matching prefix
+        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
+        func_relative_path_tcancelled=$func_stripname_result
+        if test -z "$func_relative_path_result"; then
+          func_relative_path_result=.
+        fi
+        break
+        ;;
+      *)
+        func_dirname $func_relative_path_tlibdir
+        func_relative_path_tlibdir=${func_dirname_result}
+        if test "x$func_relative_path_tlibdir" = x ; then
+          # Have to descend all the way to the root!
+          func_relative_path_result=../$func_relative_path_result
+          func_relative_path_tcancelled=$func_relative_path_tbindir
+          break
+        fi
+        func_relative_path_result=../$func_relative_path_result
+        ;;
+    esac
+  done
+
+  # Now calculate path; take care to avoid doubling-up slashes.
+  func_stripname '' '/' "$func_relative_path_result"
+  func_relative_path_result=$func_stripname_result
+  func_stripname '/' '/' "$func_relative_path_tcancelled"
+  if test "x$func_stripname_result" != x ; then
+    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
+  fi
+
+  # Normalisation. If bindir is libdir, return empty string,
+  # else relative path ending with a slash; either way, target
+  # file name can be directly appended.
+  if test ! -z "$func_relative_path_result"; then
+    func_stripname './' '' "$func_relative_path_result/"
+    func_relative_path_result=$func_stripname_result
+  fi
+}
+
 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
 # is ksh but when the shell is invoked as "sh" and the current value of
 # the _XPG environment variable is not equal to 1 (one), the special
@@ -1558,6 +1703,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)
@@ -4072,6 +4219,7 @@ func_mode_link ()
     new_inherited_linker_flags=
 
     avoid_version=no
+    bindir=
     dlfiles=
     dlprefiles=
     dlself=no
@@ -4164,6 +4312,11 @@ func_mode_link ()
        esac
 
        case $prev in
+       bindir)
+         bindir="$arg"
+         prev=
+         continue
+         ;;
        dlfiles|dlprefiles)
          if test "$preload" = no; then
            # Add the symbol object into the linking commands.
@@ -4425,6 +4578,11 @@ func_mode_link ()
        continue
        ;;
 
+      -bindir)
+       prev=bindir
+       continue
+       ;;
+
       -dlopen)
        prev=dlfiles
        continue
@@ -8121,9 +8279,27 @@ EOF
          fi
          $RM $output
          # place dlname in correct position for cygwin
+         # In fact, it would be nice if we could use this code for all target
+         # systems that can't hard-code library paths into their executables
+         # and that have no shared library path variable independent of PATH,
+         # but it turns out we can't easily determine that from inspecting
+         # libtool variables, so we have to hard-code the OSs to which it
+         # applies here; at the moment, that means platforms that use the PE
+         # object format with DLL files.  See the long comment at the top of
+         # tests/bindir.at for full details.
          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)
+             # If a -bindir argument was supplied, place the dll there.
+             if test "x$bindir" != x ;
+             then
+               func_relative_path "$install_libdir" "$bindir"
+               tdlname=$func_relative_path_result$dlname
+             else
+               # Otherwise fall back on heuristic.
+               tdlname=../bin/$dlname
+             fi
+             ;;
          esac
          $ECHO > $output "\
 # $outputname - a libtool library file
index 7665f8c39600b9e6e46e99c687755737e90cb1a7..9ad7f8e9cae24e27ad20c1daa0be05bd63978fe8 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-20  Dave Korn  <dave.korn.cygwin@gmail.com>
+
+       * Makefile.am (libltdl_la_LDFLAGS): Add -bindir flag.
+       * Makefile.in: Regenerate.
+
 2008-06-17  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * Makefile.in: Regenerate.
index 737290e6c7cea0a7ac11f250fd400e94c31bf872..8a2af102e4ba8d40e1051a16800b77fcec3982bb 100644 (file)
@@ -22,7 +22,7 @@ endif
 CLEANFILES = libltdl.la libltdlc.la
 
 libltdl_la_SOURCES = ltdl.c
-libltdl_la_LDFLAGS = -no-undefined -version-info 4:1:1
+libltdl_la_LDFLAGS = -no-undefined -bindir "$(bindir)" -version-info 4:1:1
 libltdl_la_LIBADD = $(LIBADD_DL)
 
 libltdlc_la_SOURCES = ltdl.c
index 8a362433d817811952005df578dc78e0a3eccbf8..bab1425231d1bbaed30e18ce6c09b7dd600092c9 100644 (file)
@@ -232,7 +232,7 @@ INCLUDES = $(GCINCS)
 @CONVENIENCE_LTDL_TRUE@noinst_LTLIBRARIES = libltdlc.la
 CLEANFILES = libltdl.la libltdlc.la
 libltdl_la_SOURCES = ltdl.c
-libltdl_la_LDFLAGS = -no-undefined -version-info 4:1:1
+libltdl_la_LDFLAGS = -no-undefined -bindir "$(bindir)" -version-info 4:1:1
 libltdl_la_LIBADD = $(LIBADD_DL)
 libltdlc_la_SOURCES = ltdl.c
 libltdlc_la_LIBADD = $(LIBADD_DL)
index 89d23ae6bf32796c9fd9176ef9033dc9cb5eed91..fc30438a8f3578cb68325603b0adafb920253c50 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-20  Dave Korn  <dave.korn.cygwin@gmail.com>
+
+       * Makefile.am (libssp_la_LDFLAGS): Add -bindir flag.
+       * Makefile.in: Regenerate.
+
 2009-07-30  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * configure.ac (_AC_ARG_VAR_PRECIOUS): Use m4_rename_force.
index 6a8b4c8cf10724bf0799bc6fc1b1a32f60bca67f..2c5800ae25c0971769fb748824f9e75d9e23ca7b 100644 (file)
@@ -35,7 +35,7 @@ libssp_la_SOURCES = \
 libssp_la_LIBADD = 
 libssp_la_DEPENDENCIES = $(version_dep) $(libssp_la_LIBADD)
 libssp_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
-                   $(version_arg) -no-undefined
+                   $(version_arg) -no-undefined -bindir "$(bindir)"
 
 libssp_nonshared_la_SOURCES = \
        ssp-local.c
index fc5c90d650f2b87495d376b14443a0d5ddc7151e..64c1a8a2a594bf1d4f3d8f6f1680d7f9143f6bb4 100644 (file)
@@ -259,7 +259,7 @@ libssp_la_SOURCES = \
 libssp_la_LIBADD = 
 libssp_la_DEPENDENCIES = $(version_dep) $(libssp_la_LIBADD)
 libssp_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
-                   $(version_arg) -no-undefined
+                   $(version_arg) -no-undefined -bindir "$(bindir)"
 
 libssp_nonshared_la_SOURCES = \
        ssp-local.c
index 8dfa0b3b5584265d34f92a05e5eb4fea684d586f..b01cb29a683b675b17f86b02172761c8e2a94a89 100644 (file)
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -170,6 +170,151 @@ func_dirname_and_basename ()
 
 # Generated shell functions inserted here.
 
+# These SED scripts presuppose an absolute path with a trailing slash.
+pathcar="s,^/\([^/]*\).*$,\1,"
+pathcdr="s,^/[^/]*,,"
+removedotparts="s,/\(\./\)\{1\,\},/,g;s,/\.$,/,"
+collapseslashes="s,/\{1\,\},/,g"
+finalslash="s,/*$,/,"
+
+# func_normal_abspath PATH
+# Remove doubled-up and trailing slashes, "." path components,
+# and cancel out any ".." path components in PATH after making
+# it an absolute path.
+#             value returned in "$func_normal_abspath_result"
+func_normal_abspath ()
+{
+  # Start from root dir and reassemble the path.
+  func_normal_abspath_result=
+  func_normal_abspath_tpath=$1
+  func_normal_abspath_altnamespace=
+  case $func_normal_abspath_tpath in
+    "")
+      # Empty path, that just means $cwd.
+      func_stripname '' '/' "`pwd`"
+      func_normal_abspath_result=$func_stripname_result
+      return
+    ;;
+    # The next three entries are used to spot a run of precisely
+    # two leading slashes without using negated character classes;
+    # we take advantage of case's first-match behaviour.
+    ///*)
+      # Unusual form of absolute path, do nothing.
+    ;;
+    //*)
+      # Not necessarily an ordinary path; POSIX reserves leading '//'
+      # and for example Cygwin uses it to access remote file shares
+      # over CIFS/SMB, so we conserve a leading double slash if found.
+      func_normal_abspath_altnamespace=/
+    ;;
+    /*)
+      # Absolute path, do nothing.
+    ;;
+    *)
+      # Relative path, prepend $cwd.
+      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
+    ;;
+  esac
+  # Cancel out all the simple stuff to save iterations.  We also want
+  # the path to end with a slash for ease of parsing, so make sure
+  # there is one (and only one) here.
+  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
+  while :; do
+    # Processed it all yet?
+    if test "$func_normal_abspath_tpath" = / ; then
+      # If we ascended to the root using ".." the result may be empty now.
+      if test -z "$func_normal_abspath_result" ; then
+        func_normal_abspath_result=/
+      fi
+      break
+    fi
+    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
+        -e "$pathcar"`
+    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+        -e "$pathcdr"`
+    # Figure out what to do with it
+    case $func_normal_abspath_tcomponent in
+      "")
+        # Trailing empty path component, ignore it.
+      ;;
+      ..)
+        # Parent dir; strip last assembled component from result.
+        func_dirname "$func_normal_abspath_result"
+        func_normal_abspath_result=$func_dirname_result
+      ;;
+      *)
+        # Actual path component, append it.
+        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
+      ;;
+    esac
+  done
+  # Restore leading double-slash if one was found on entry.
+  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
+}
+
+# func_relative_path SRCDIR DSTDIR
+# generates a relative path from SRCDIR to DSTDIR, with a trailing
+# slash if non-empty, suitable for immediately appending a filename
+# without needing to append a separator.
+#             value returned in "$func_relative_path_result"
+func_relative_path ()
+{
+  func_relative_path_result=
+  func_normal_abspath "$1"
+  func_relative_path_tlibdir=$func_normal_abspath_result
+  func_normal_abspath "$2"
+  func_relative_path_tbindir=$func_normal_abspath_result
+
+  # Ascend the tree starting from libdir
+  while :; do
+    # check if we have found a prefix of bindir
+    case $func_relative_path_tbindir in
+      $func_relative_path_tlibdir)
+        # found an exact match
+        func_relative_path_tcancelled=
+        break
+        ;;
+      $func_relative_path_tlibdir*)
+        # found a matching prefix
+        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
+        func_relative_path_tcancelled=$func_stripname_result
+        if test -z "$func_relative_path_result"; then
+          func_relative_path_result=.
+        fi
+        break
+        ;;
+      *)
+        func_dirname $func_relative_path_tlibdir
+        func_relative_path_tlibdir=${func_dirname_result}
+        if test "x$func_relative_path_tlibdir" = x ; then
+          # Have to descend all the way to the root!
+          func_relative_path_result=../$func_relative_path_result
+          func_relative_path_tcancelled=$func_relative_path_tbindir
+          break
+        fi
+        func_relative_path_result=../$func_relative_path_result
+        ;;
+    esac
+  done
+
+  # Now calculate path; take care to avoid doubling-up slashes.
+  func_stripname '' '/' "$func_relative_path_result"
+  func_relative_path_result=$func_stripname_result
+  func_stripname '/' '/' "$func_relative_path_tcancelled"
+  if test "x$func_stripname_result" != x ; then
+    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
+  fi
+
+  # Normalisation. If bindir is libdir, return empty string,
+  # else relative path ending with a slash; either way, target
+  # file name can be directly appended.
+  if test ! -z "$func_relative_path_result"; then
+    func_stripname './' '' "$func_relative_path_result/"
+    func_relative_path_result=$func_stripname_result
+  fi
+}
+
 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
 # is ksh but when the shell is invoked as "sh" and the current value of
 # the _XPG environment variable is not equal to 1 (one), the special
@@ -1558,6 +1703,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)
@@ -4072,6 +4219,7 @@ func_mode_link ()
     new_inherited_linker_flags=
 
     avoid_version=no
+    bindir=
     dlfiles=
     dlprefiles=
     dlself=no
@@ -4164,6 +4312,11 @@ func_mode_link ()
        esac
 
        case $prev in
+       bindir)
+         bindir="$arg"
+         prev=
+         continue
+         ;;
        dlfiles|dlprefiles)
          if test "$preload" = no; then
            # Add the symbol object into the linking commands.
@@ -4425,6 +4578,11 @@ func_mode_link ()
        continue
        ;;
 
+      -bindir)
+       prev=bindir
+       continue
+       ;;
+
       -dlopen)
        prev=dlfiles
        continue
@@ -8121,9 +8279,27 @@ EOF
          fi
          $RM $output
          # place dlname in correct position for cygwin
+         # In fact, it would be nice if we could use this code for all target
+         # systems that can't hard-code library paths into their executables
+         # and that have no shared library path variable independent of PATH,
+         # but it turns out we can't easily determine that from inspecting
+         # libtool variables, so we have to hard-code the OSs to which it
+         # applies here; at the moment, that means platforms that use the PE
+         # object format with DLL files.  See the long comment at the top of
+         # tests/bindir.at for full details.
          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)
+             # If a -bindir argument was supplied, place the dll there.
+             if test "x$bindir" != x ;
+             then
+               func_relative_path "$install_libdir" "$bindir"
+               tdlname=$func_relative_path_result$dlname
+             else
+               # Otherwise fall back on heuristic.
+               tdlname=../bin/$dlname
+             fi
+             ;;
          esac
          $ECHO > $output "\
 # $outputname - a libtool library file