Blob Blame History Raw
commit c5084a863990a4270582acf402d7881d9371092d
Author: Ken McDonell <kenj@internode.on.net>
Date:   Wed Sep 10 12:25:10 2014 +1000

    qmake fix - ugly
    
    qmake appears to be broken in that the generated Makefile contains a
    bogus -L/some/lib/dir component _before_ the PCP and related lib
    dirs we care about.
    
    If a down-rev libpcp, for example, is installed on /some/lib/dir, we
    try to link against the down-rev libpcp instead of the correct one in
    the build ... discovered by Jeff Hanson @ SGI.
    
    The fix is to edit the Makefile after qmake generates it and before we
    use it in the build.

diff --git a/src/include/builddefs.in b/src/include/builddefs.in
index f064251..cbf6acd 100644
--- a/src/include/builddefs.in
+++ b/src/include/builddefs.in
@@ -594,20 +594,20 @@ endif
 
 # Qt magic for build/installs across all the supported platforms
 ifeq ($(PCP_PLATFORM),darwin)
-QTMAKE = $(QMAKE) -spec macx-g++ CONFIG+=$(QT_RELEASE) && make -f Makefile
+QTMAKE = $(QMAKE) -spec macx-g++ CONFIG+=$(QT_RELEASE) && sed -i -e '/^LIBS/s/ -L\/[^ ]*//' Makefile && make -f Makefile
 MACBUILD = build/$(QT_RELEASE)/$(COMMAND).app/Contents
 BINARY = $(MACBUILD)/MacOS/$(COMMAND)
 LNMAKE = test ! -f $(BINARY) -o -L $(COMMAND) || $(LN_S) $(BINARY) $(COMMAND)
 WINDOW = mac
 endif
 ifeq ($(PCP_PLATFORM),mingw)
-QTMAKE = $(QMAKE) CONFIG+=$(QT_RELEASE) && $(MAKE) -f Makefile
+QTMAKE = $(QMAKE) CONFIG+=$(QT_RELEASE) && sed -i -e '/^LIBS/s/ -L\/[^ ]*//' Makefile && $(MAKE) -f Makefile
 BINARY = $(QT_RELEASE)/$(COMMAND)
 LNMAKE =
 WINDOW = win
 endif
 ifeq "$(findstring $(PCP_PLATFORM),darwin mingw)" ""
-QTMAKE = $(QMAKE) CONFIG+=$(QT_RELEASE) && $(MAKE) $(MAKEOPTS) -f Makefile
+QTMAKE = $(QMAKE) CONFIG+=$(QT_RELEASE) && sed -i -e '/^LIBS/s/ -L\/[^ ]*//' Makefile && $(MAKE) $(MAKEOPTS) -f Makefile
 BINARY = build/$(QT_RELEASE)/$(COMMAND)
 LNMAKE = test ! -f $(BINARY) -o -L $(COMMAND) || $(LN_S) $(BINARY) $(COMMAND)
 WINDOW = x11

commit 8837d83d311884e35d21541484cca5f099c3c5e3
Author: Ken McDonell <kenj@internode.on.net>
Date:   Thu Sep 11 11:01:41 2014 +1000

    qmake fix - less ugly solution
    
    Frank's right, I should accommodate qmake's badness by reordering
    the -L options to move the Qt libs dir to the end of the list.
    
    This involves some much hairier awk than the original sed, but
    appears to work.

diff --git a/src/include/builddefs.in b/src/include/builddefs.in
index cbf6acd..c302a4b 100644
--- a/src/include/builddefs.in
+++ b/src/include/builddefs.in
@@ -592,22 +592,33 @@ PYTHON_INSTALL =
 endif
 endif
 
+# qmake botches the order of the -L arguments in the generated $(LIBS)
+# in the Makefile ... need to get the Qt libraries dir (begins with a /)
+# out from the head of the list and insert it before the first -l argument
+# (or the end of the list).
+# So, for example
+# LIBS = $(SUBLIBS) -L/usr/lib -L../libpcp/src -L../libpcp_qmc/src ... -lpcp_qmc ...
+# becomes
+# LIBS = $(SUBLIBS) -L../libpcp/src -L../libpcp_qmc/src ... -L/usr/lib -lpcp_qmc ...
+#
+QTFIX = $(AWK) '$$1 == "LIBS" { printf $$1; for (i=2;i<=NF;i++) { if ($$i~/^-L\//) { save=save " " $$i; continue } else if (save!="" && $$i~/^-l/) { printf " %s",save; save="" } printf " %s",$$i } if (save!="") printf " %s",save; print ""; next } { print }'
+
 # Qt magic for build/installs across all the supported platforms
 ifeq ($(PCP_PLATFORM),darwin)
-QTMAKE = $(QMAKE) -spec macx-g++ CONFIG+=$(QT_RELEASE) && sed -i -e '/^LIBS/s/ -L\/[^ ]*//' Makefile && make -f Makefile
+QTMAKE = $(QMAKE) -spec macx-g++ CONFIG+=$(QT_RELEASE) && $(QTFIX) <Makefile >Makefile.fix && mv Makefile.fix Makefile && make -f Makefile
 MACBUILD = build/$(QT_RELEASE)/$(COMMAND).app/Contents
 BINARY = $(MACBUILD)/MacOS/$(COMMAND)
 LNMAKE = test ! -f $(BINARY) -o -L $(COMMAND) || $(LN_S) $(BINARY) $(COMMAND)
 WINDOW = mac
 endif
 ifeq ($(PCP_PLATFORM),mingw)
-QTMAKE = $(QMAKE) CONFIG+=$(QT_RELEASE) && sed -i -e '/^LIBS/s/ -L\/[^ ]*//' Makefile && $(MAKE) -f Makefile
+QTMAKE = $(QMAKE) CONFIG+=$(QT_RELEASE) && $(QTFIX) <Makefile >Makefile.fix && mv Makefile.fix Makefile && $(MAKE) -f Makefile
 BINARY = $(QT_RELEASE)/$(COMMAND)
 LNMAKE =
 WINDOW = win
 endif
 ifeq "$(findstring $(PCP_PLATFORM),darwin mingw)" ""
-QTMAKE = $(QMAKE) CONFIG+=$(QT_RELEASE) && sed -i -e '/^LIBS/s/ -L\/[^ ]*//' Makefile && $(MAKE) $(MAKEOPTS) -f Makefile
+QTMAKE = $(QMAKE) CONFIG+=$(QT_RELEASE) && $(QTFIX) <Makefile >Makefile.fix && mv Makefile.fix Makefile && $(MAKE) $(MAKEOPTS) -f Makefile
 BINARY = build/$(QT_RELEASE)/$(COMMAND)
 LNMAKE = test ! -f $(BINARY) -o -L $(COMMAND) || $(LN_S) $(BINARY) $(COMMAND)
 WINDOW = x11