From 2784921c40d0b523c75e613e48b7fd1e90ba3ef1 Mon Sep 17 00:00:00 2001
From: Martin Jansa <Martin.Jansa@gmail.com>
Date: Mon, 15 Apr 2013 04:29:32 +0200
Subject: [PATCH] Add linux-oe-g++ platform

* This qmake.conf unlike other platforms reads most variables from
  shell environment, because it's easier for qt recipes to export
  *FLAGS or CC specific for given recipe

* configure: extend setBootstrapVariable to convert $$(...) operator
  to $(...) operator to work in qmake's Makefiles

* configure.prf: Allow to add extra arguments to make
  sometimes we would like to add -e or define some variable and respect it from both
  Makefiles used in configure tests and also Makefiles to build the application

Upstream-Status: Inappropriate [embedded specific]
                 too OE specific, probably cannot be upstreamed

Change-Id: I0591ed5da0d61d7cf1509d420e6b293582f1863c
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 configure                            |  2 +-
 mkspecs/features/configure.prf       |  4 ++--
 mkspecs/features/qt_functions.prf    |  2 +-
 mkspecs/linux-oe-g++/qmake.conf      | 43 ++++++++++++++++++++++++++++++++++++
 mkspecs/linux-oe-g++/qplatformdefs.h |  1 +
 5 files changed, 48 insertions(+), 4 deletions(-)
 create mode 100644 mkspecs/linux-oe-g++/qmake.conf
 create mode 100644 mkspecs/linux-oe-g++/qplatformdefs.h

diff --git a/configure b/configure
index 789ba4c..59cce01 100755
--- a/configure
+++ b/configure
@@ -1624,7 +1624,7 @@ fi
 # is where the resulting variable is written to
 setBootstrapVariable()
 {
-    getQMakeConf "$1" | echo ${2-$1} = `if [ -n "$3" ]; then sed "$3"; else cat; fi` >> "$mkfile"
+    getQMakeConf "$1" | sed 's:\$\$(:\$(:' | echo ${2-$1} = `if [ -n "$3" ]; then sed "$3"; else cat; fi` >> "$mkfile"
 }
 
 # build qmake
diff --git a/mkspecs/features/configure.prf b/mkspecs/features/configure.prf
index f275e3a..5aa15f5 100644
--- a/mkspecs/features/configure.prf
+++ b/mkspecs/features/configure.prf
@@ -37,14 +37,14 @@ defineTest(qtCompileTest) {
     }
 
     # Clean up after previous run
-    exists($$test_out_dir/Makefile):qtRunLoggedCommand("$$test_cmd_base $$QMAKE_MAKE distclean")
+    exists($$test_out_dir/Makefile):qtRunLoggedCommand("$$test_cmd_base $$QMAKE_MAKE $$(QMAKE_MAKE_ARGS) distclean")
 
     mkpath($$test_out_dir)|error()
 
     !isEmpty (QMAKE_QTCONF): qtconfarg = -qtconf $$QMAKE_QTCONF
 
     qtRunLoggedCommand("$$test_cmd_base $$system_quote($$system_path($$QMAKE_QMAKE)) $$qtconfarg -spec $$QMAKESPEC $$qmake_configs $$shell_quote($$test_dir)") {
-        qtRunLoggedCommand("$$test_cmd_base $$QMAKE_MAKE") {
+        qtRunLoggedCommand("$$test_cmd_base $$QMAKE_MAKE $$(QMAKE_MAKE_ARGS)") {
             log("yes$$escape_expand(\\n)")
             msg = "test $$1 succeeded"
             write_file($$QMAKE_CONFIG_LOG, msg, append)
diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf
index 708815d..097ac49 100644
--- a/mkspecs/features/qt_functions.prf
+++ b/mkspecs/features/qt_functions.prf
@@ -67,7 +67,7 @@ defineTest(qtHaveModule) {
 defineTest(qtPrepareTool) {
     cmd = $$eval(QT_TOOL.$${2}.binary)
     isEmpty(cmd) {
-        cmd = $$[QT_HOST_BINS]/$$2
+        cmd = $$[QT_HOST_BINS/get]/$$2
         exists($${cmd}.pl) {
             $${1}_EXE = $${cmd}.pl
             cmd = perl -w $$system_path($${cmd}.pl)
diff --git a/mkspecs/linux-oe-g++/qmake.conf b/mkspecs/linux-oe-g++/qmake.conf
new file mode 100644
index 0000000..c1837e6
--- /dev/null
+++ b/mkspecs/linux-oe-g++/qmake.conf
@@ -0,0 +1,43 @@
+#
+# qmake configuration for linux-g++ with modifications for building with OpenEmbedded
+#
+
+MAKEFILE_GENERATOR = UNIX
+CONFIG += incremental
+QMAKE_INCREMENTAL_STYLE = sublib
+
+include(../common/linux.conf)
+
+# QMAKE_<TOOL> (moc, uic, rcc) are gone, overwrite only ar and strip
+QMAKE_AR              = $$(OE_QMAKE_AR) cqs
+QMAKE_STRIP           = $$(OE_QMAKE_STRIP)
+QMAKE_WAYLAND_SCANNER = $$(OE_QMAKE_WAYLAND_SCANNER)
+
+include(../common/gcc-base-unix.conf)
+
+# *FLAGS from gcc-base.conf
+QMAKE_CFLAGS                += $$(OE_QMAKE_CFLAGS)
+QMAKE_CXXFLAGS              += $$(OE_QMAKE_CXXFLAGS)
+QMAKE_LFLAGS                += $$(OE_QMAKE_LDFLAGS)
+
+include(../common/g++-unix.conf)
+
+# tc settings from g++-base.conf
+QMAKE_COMPILER = $$(OE_QMAKE_COMPILER) gcc
+QMAKE_CC       = $$(OE_QMAKE_CC)
+QMAKE_CXX      = $$(OE_QMAKE_CXX)
+
+QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$(OE_QMAKE_CFLAGS)
+
+QMAKE_LINK         = $$(OE_QMAKE_LINK)
+QMAKE_LINK_SHLIB   = $$(OE_QMAKE_LINK)
+QMAKE_LINK_C       = $$(OE_QMAKE_LINK)
+QMAKE_LINK_C_SHLIB = $$(OE_QMAKE_LINK)
+
+# for the SDK
+isEmpty(QMAKE_QT_CONFIG):QMAKE_QT_CONFIG = $$(OE_QMAKE_QT_CONFIG)
+
+include(../oe-device-extra.pri)
+
+load(device_config)
+load(qt_config)
diff --git a/mkspecs/linux-oe-g++/qplatformdefs.h b/mkspecs/linux-oe-g++/qplatformdefs.h
new file mode 100644
index 0000000..5d22fb4
--- /dev/null
+++ b/mkspecs/linux-oe-g++/qplatformdefs.h
@@ -0,0 +1 @@
+#include "../linux-g++/qplatformdefs.h"