diff --git a/configure b/configure
index 93dda6fe6c9c955773b2b3a26f37ea1d606f6922..4a537735449bc405eebb934e04dff99a3a979a20 100755
--- a/configure
+++ b/configure
@@ -6294,8 +6294,8 @@ if [ -n "$CFG_SYSROOT" ]; then
     echo "}" >> "$QTCONFIG.tmp"
     echo >> "$QTCONFIG.tmp"
 fi
-if [ "$CFG_RPATH" = "yes" ]; then
-    echo "QMAKE_RPATHDIR += \"$QT_INSTALL_LIBS\"" >> "$QTCONFIG.tmp"
+if [ -n "$RPATH_FLAGS" ]; then
+    echo "QMAKE_RPATHDIR += $RPATH_FLAGS" >> "$QTCONFIG.tmp"
 fi
 if [ -n "$QT_GCC_MAJOR_VERSION" ]; then
     echo "QT_GCC_MAJOR_VERSION = $QT_GCC_MAJOR_VERSION" >> "$QTCONFIG.tmp"