title: Setting RPATH order in QMake
body: <p>I have a Linux Qt program. I'd like it to preferentially use the (dynamic) Qt libraries in the executable's directory if they exist, otherwise use the system's Qt libs. RPATH to the rescue.</p>
  
  <p>I add this line to the <strong>qmake</strong>'s .pro file:</p>
  
  <pre><code>QMAKE_LFLAGS    += '-Wl,-rpath,\'\$$ORIGIN\''
  </code></pre>
  
  <p>and looking at the resulting executable with <strong>readelf</strong> I see:</p>
  
  <pre><code>0x000000000000000f (RPATH)              Library rpath: [$ORIGIN:/usr/local/Trolltech/Qt-5.2.0/lib]
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/usr/local/Trolltech/Qt-5.2.0/lib]
  </code></pre>
  
  <p>Seems right, but <strong>ldd</strong> shows it's using the system version:</p>
  
  <pre><code>libQt5Core.so.5 =&gt; /usr/local/Trolltech/Qt-5.2.0/lib/libQt5Core.so.5 (0x00007f2d2fe09000)
  </code></pre>
  
  <p>If I manually edit qmake's resulting Makefile to swap the order of the two rpaths, so $ORIGIN comes after /usr/local/..., I get the right behavior:</p>
  
  <pre><code>0x000000000000000f (RPATH)              Library rpath: [/usr/local/Trolltech/Qt-5.2.0/lib:$ORIGIN]
  0x000000000000001d (RUNPATH)            Library runpath: [/usr/local/Trolltech/Qt-5.2.0/lib:$ORIGIN]
  
  libQt5Core.so.5 =&gt; ./libQt5Core.so.5 (0x00007fb92aba9000)
  </code></pre>
  
  <p>My problem is with how <strong>qmake</strong> constructs the final LFLAGS variable. I can't figure out how to make it put my addition ($ORIGIN) after the system library. Any ideas?</p>