diff --git a/configure b/configure
index cfdb315e4fe0756f3f611db2c79070ae153d6edd..22df1d5e6f1b39bb32d42f504a67a6e35f4032ab 100755
--- a/configure
+++ b/configure
@@ -5105,7 +5105,7 @@ fi
 echo "$ac_t""$ac_cv_c_dll_gnuelf" 1>&6
   if test "$ac_cv_c_dll_gnuelf" = "yes"
   then
-    LDSHARED="\$(CC) -shared \$(SONAME:%=-Wl,-soname,%) -Wl,-rpath,\$(libdir)"
+    LDSHARED="\$(CC) -shared \$(SONAME:%=-Wl,-soname,%)"
     LDDLLFLAGS="-Wl,-Bsymbolic"
   else
     echo $ac_n "checking whether we can build a UnixWare (Solaris) dll""... $ac_c" 1>&6
@@ -5140,7 +5140,7 @@ fi
 echo "$ac_t""$ac_cv_c_dll_unixware" 1>&6
     if test "$ac_cv_c_dll_unixware" = "yes"
     then
-      LDSHARED="\$(CC) -Wl,-G \$(SONAME:%=-Wl,-h,\$(libdir)/%)"
+      LDSHARED="\$(CC) -Wl,-G \$(SONAME:%=-Wl,-h,%)"
       LDDLLFLAGS="-Wl,-B,symbolic"
     fi
   fi
diff --git a/configure.in b/configure.in
index 21be710cc8702d70645e331c00f152903b5a8842..739eaf583161baa8a61f34bbefa0cd310be382eb 100644
--- a/configure.in
+++ b/configure.in
@@ -650,7 +650,7 @@ then
   ])
   if test "$ac_cv_c_dll_gnuelf" = "yes"
   then
-    LDSHARED="\$(CC) -shared \$(SONAME:%=-Wl,-soname,%) -Wl,-rpath,\$(libdir)"
+    LDSHARED="\$(CC) -shared \$(SONAME:%=-Wl,-soname,%)"
     LDDLLFLAGS="-Wl,-Bsymbolic"
   else
     AC_CACHE_CHECK(whether we can build a UnixWare (Solaris) dll,
@@ -662,7 +662,7 @@ then
     ])
     if test "$ac_cv_c_dll_unixware" = "yes"
     then
-      LDSHARED="\$(CC) -Wl,-G \$(SONAME:%=-Wl,-h,\$(libdir)/%)"
+      LDSHARED="\$(CC) -Wl,-G \$(SONAME:%=-Wl,-h,%)"
       LDDLLFLAGS="-Wl,-B,symbolic"
     fi
   fi