From 78f6229222cd67316e18bf5bbeaed28d9a4056a5 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Date: Fri, 5 Jun 2015 16:12:02 +0200
Subject: [PATCH] fix relative rpaths on linux

$ORIGIN (or $LIB) needs to be escaped to survive the trip through
make and the shell.

this shouldn't break anything, as there was simply no way to get it
right so far.

Change-Id: I86337c5994d10dae2e80dd2f858f74874b14bca7
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
---
 qmake/generators/unix/unixmake.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp
index c4750cb8a49..03196fbc3ab 100644
--- a/qmake/generators/unix/unixmake.cpp
+++ b/qmake/generators/unix/unixmake.cpp
@@ -140,7 +140,9 @@ UnixMakefileGenerator::init()
         const ProStringList &rpathdirs = project->values("QMAKE_RPATHDIR");
         for (int i = 0; i < rpathdirs.size(); ++i) {
             QString rpathdir = rpathdirs[i].toQString();
-            if (!rpathdir.startsWith('@') && !rpathdir.startsWith('$'))
+            if (rpathdir.length() > 1 && rpathdir.at(0) == '$' && rpathdir.at(1) != '(')
+                rpathdir.replace(0, 1, "\\$$");  // Escape from make and the shell
+            else if (!rpathdir.startsWith('@'))
                 rpathdir = QFileInfo(rpathdir).absoluteFilePath();
             project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + escapeFilePath(rpathdir);
         }
-- 
GitLab