From 905342ac836c726511d7575a40b70db2505ef7a6 Mon Sep 17 00:00:00 2001
From: Samuli Piippo <samuli.piippo@theqtcompany.com>
Date: Tue, 8 Mar 2016 13:03:08 +0200
Subject: [PATCH] qt5: move mingw32 specific parts from meta-qt5

Change-Id: Id380844d530ef599f78591a282474aa66d3dec69
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
---
 conf/distro/b2qt.conf                         |   4 +
 recipes-qt/qt5/nativesdk-qtbase_git.bbappend  |   9 +
 recipes-qt/qt5/qtbase-native_git.bbappend     |   6 +
 ...mkspec-that-uses-the-OE_-environment.patch | 180 ++++++++++++++++++
 recipes-qt/qt5/qtbase_git.bbappend            |   1 +
 scripts/manifest.xml                          |   2 +-
 6 files changed, 201 insertions(+), 1 deletion(-)
 create mode 100644 recipes-qt/qt5/qtbase/0001-Add-win32-g-oe-mkspec-that-uses-the-OE_-environment.patch

diff --git a/conf/distro/b2qt.conf b/conf/distro/b2qt.conf
index af7fcb37..7b561133 100644
--- a/conf/distro/b2qt.conf
+++ b/conf/distro/b2qt.conf
@@ -61,6 +61,10 @@ MACHINE_EXTRA_INSTALL ?= ""
 MACHINE_EXTRA_INSTALL_SDK ?= ""
 MACHINE_EXTRA_INSTALL_SDK_HOST ?= ""
 
+# Override mkspec for mingw build
+OE_QMAKE_PLATFORM_NATIVE_mingw32 = "win32-g++-oe"
+OE_QMAKE_PLATFORM_mingw32 = "win32-g++-oe"
+
 PACKAGE_EXCLUDE_COMPLEMENTARY ?= "qtquickcompiler"
 
 IMAGE_FSTYPES = "tar.gz conf"
diff --git a/recipes-qt/qt5/nativesdk-qtbase_git.bbappend b/recipes-qt/qt5/nativesdk-qtbase_git.bbappend
index 29adb9b4..4b622418 100644
--- a/recipes-qt/qt5/nativesdk-qtbase_git.bbappend
+++ b/recipes-qt/qt5/nativesdk-qtbase_git.bbappend
@@ -21,3 +21,12 @@
 
 QT_MODULE_BRANCH = "5.6.0"
 SRCREV = "38944d662eda76ecc57cb1fd61da42775fa52f6f"
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/qtbase:"
+
+SRC_URI += "\
+    file://0001-Add-win32-g-oe-mkspec-that-uses-the-OE_-environment.patch \
+    "
+
+fakeroot do_generate_qt_environment_file_mingw32() {
+}
diff --git a/recipes-qt/qt5/qtbase-native_git.bbappend b/recipes-qt/qt5/qtbase-native_git.bbappend
index 29adb9b4..e87a1904 100644
--- a/recipes-qt/qt5/qtbase-native_git.bbappend
+++ b/recipes-qt/qt5/qtbase-native_git.bbappend
@@ -21,3 +21,9 @@
 
 QT_MODULE_BRANCH = "5.6.0"
 SRCREV = "38944d662eda76ecc57cb1fd61da42775fa52f6f"
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/qtbase:"
+
+SRC_URI += "\
+    file://0001-Add-win32-g-oe-mkspec-that-uses-the-OE_-environment.patch \
+    "
diff --git a/recipes-qt/qt5/qtbase/0001-Add-win32-g-oe-mkspec-that-uses-the-OE_-environment.patch b/recipes-qt/qt5/qtbase/0001-Add-win32-g-oe-mkspec-that-uses-the-OE_-environment.patch
new file mode 100644
index 00000000..7ce3a9ee
--- /dev/null
+++ b/recipes-qt/qt5/qtbase/0001-Add-win32-g-oe-mkspec-that-uses-the-OE_-environment.patch
@@ -0,0 +1,180 @@
+From 5363b4d6d1f3c5683267ec3e190b85eca964eef8 Mon Sep 17 00:00:00 2001
+From: David Schulz <david.schulz@theqtcompany.com>
+Date: Fri, 3 Jul 2015 16:06:59 +0200
+Subject: [PATCH] Add win32-g++-oe mkspec that uses the OE_ environment.
+
+Upstream-Status: Inappropriate [embedded specific]
+                 too OE specific, probably cannot be upstreamed
+---
+ mkspecs/win32-g++-oe/qmake.conf      | 109 +++++++++++++++++++++++++++++++++++
+ mkspecs/win32-g++-oe/qplatformdefs.h |  42 ++++++++++++++
+ 2 files changed, 151 insertions(+)
+ create mode 100644 mkspecs/win32-g++-oe/qmake.conf
+ create mode 100644 mkspecs/win32-g++-oe/qplatformdefs.h
+
+diff --git a/mkspecs/win32-g++-oe/qmake.conf b/mkspecs/win32-g++-oe/qmake.conf
+new file mode 100644
+index 0000000..1c8879a
+--- /dev/null
++++ b/mkspecs/win32-g++-oe/qmake.conf
+@@ -0,0 +1,109 @@
++#
++# qmake configuration for win32-g++
++#
++# Written for MinGW / gcc 4.6 or higher
++#
++# Cross compile example for i686-w64-mingw32-g++:
++#   configure -xplatform win32-g++ -device-option CROSS_COMPILE=i686-w64-mingw32-
++#
++
++load(device_config)
++
++MAKEFILE_GENERATOR      = MINGW
++QMAKE_PLATFORM          = win32 mingw
++CONFIG                 += debug_and_release debug_and_release_target precompile_header
++DEFINES                += UNICODE
++QMAKE_COMPILER_DEFINES += __GNUC__ WIN32
++
++QMAKE_EXT_OBJ           = .o
++QMAKE_EXT_RES           = _res.o
++
++QMAKE_COMPILER          = $(OE_QMAKE_COMPILER) gcc
++
++QMAKE_CC                = $(OE_QMAKE_CC)
++QMAKE_LEX               = flex
++QMAKE_LEXFLAGS          =
++QMAKE_YACC              = byacc
++QMAKE_YACCFLAGS         = -d
++QMAKE_CFLAGS            = -pipe $(OE_QMAKE_CFLAGS)
++QMAKE_CFLAGS_DEPS       = -M
++QMAKE_CFLAGS_WARN_ON    = -Wall -Wextra
++QMAKE_CFLAGS_WARN_OFF   = -w
++QMAKE_CFLAGS_RELEASE    = -O2
++QMAKE_CFLAGS_DEBUG      = -g
++QMAKE_CFLAGS_YACC       = -Wno-unused -Wno-parentheses
++QMAKE_CFLAGS_SPLIT_SECTIONS = -ffunction-sections
++QMAKE_CFLAGS_SSE2       = -msse2 -mstackrealign
++QMAKE_CFLAGS_SSE3       = -msse3
++QMAKE_CFLAGS_SSSE3      = -mssse3
++QMAKE_CFLAGS_SSE4_1     = -msse4.1
++QMAKE_CFLAGS_SSE4_2     = -msse4.2
++QMAKE_CFLAGS_AVX        = -mavx
++QMAKE_CFLAGS_AVX2       = -mavx2
++QMAKE_CFLAGS_NEON       = -mfpu=neon
++
++QMAKE_CXX               = $(OE_QMAKE_CXX)
++QMAKE_CXXFLAGS          = $$QMAKE_CFLAGS $(OE_QMAKE_CXXFLAGS)
++QMAKE_CXXFLAGS_DEPS     = $$QMAKE_CFLAGS_DEPS
++QMAKE_CXXFLAGS_WARN_ON  = $$QMAKE_CFLAGS_WARN_ON
++QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF
++QMAKE_CXXFLAGS_RELEASE  = $$QMAKE_CFLAGS_RELEASE
++QMAKE_CXXFLAGS_DEBUG    = $$QMAKE_CFLAGS_DEBUG
++QMAKE_CXXFLAGS_YACC     = $$QMAKE_CFLAGS_YACC
++QMAKE_CXXFLAGS_THREAD   = $$QMAKE_CFLAGS_THREAD
++QMAKE_CXXFLAGS_RTTI_ON  = -frtti
++QMAKE_CXXFLAGS_RTTI_OFF = -fno-rtti
++QMAKE_CXXFLAGS_EXCEPTIONS_ON = -fexceptions -mthreads
++QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -fno-exceptions
++QMAKE_CXXFLAGS_CXX11    = -std=c++0x
++QMAKE_CXXFLAGS_SPLIT_SECTIONS = $$QMAKE_CFLAGS_SPLIT_SECTIONS
++
++QMAKE_INCDIR            =
++
++QMAKE_RUN_CC            = $(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src
++QMAKE_RUN_CC_IMP        = $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
++QMAKE_RUN_CXX           = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src
++QMAKE_RUN_CXX_IMP       = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
++
++QMAKE_LINK              = $(OE_QMAKE_LINK)
++QMAKE_LINK_C            = $(OE_QMAKE_LINK)
++QMAKE_LFLAGS            = $(OE_QMAKE_LDFLAGS)
++QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads
++QMAKE_LFLAGS_EXCEPTIONS_OFF =
++QMAKE_LFLAGS_RELEASE    = -Wl,-s
++QMAKE_LFLAGS_DEBUG      =
++QMAKE_LFLAGS_CONSOLE    = -Wl,-subsystem,console
++QMAKE_LFLAGS_WINDOWS    = -Wl,-subsystem,windows
++QMAKE_LFLAGS_DLL        = -shared
++QMAKE_LFLAGS_CXX11      =
++QMAKE_LFLAGS_GCSECTIONS = -Wl,--gc-sections
++QMAKE_LFLAGS_USE_GOLD   = -fuse-ld=gold
++QMAKE_LINK_OBJECT_MAX   = 10
++QMAKE_LINK_OBJECT_SCRIPT = object_script
++QMAKE_PREFIX_SHLIB      =
++QMAKE_EXTENSION_SHLIB   = dll
++QMAKE_PREFIX_STATICLIB  = lib
++QMAKE_EXTENSION_STATICLIB = a
++QMAKE_LIB_EXTENSIONS    = a dll.a
++
++QMAKE_LIBS              =
++QMAKE_LIBS_CORE         = -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32
++QMAKE_LIBS_GUI          = -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lws2_32 -lole32 -luuid -luser32 -ladvapi32
++QMAKE_LIBS_NETWORK      = -lws2_32
++QMAKE_LIBS_OPENGL       = -lglu32 -lopengl32 -lgdi32 -luser32
++QMAKE_LIBS_OPENGL_ES2   = -llibEGL -llibGLESv2 -lgdi32 -luser32
++QMAKE_LIBS_OPENGL_ES2_DEBUG = -llibEGLd -llibGLESv2d -lgdi32 -luser32
++QMAKE_LIBS_COMPAT       = -ladvapi32 -lshell32 -lcomdlg32 -luser32 -lgdi32 -lws2_32
++QMAKE_LIBS_QT_ENTRY     = -lmingw32 -lqtmain
++
++QMAKE_IDL               = midl
++QMAKE_LIB               = $(OE_QMAKE_AR) -ru
++QMAKE_RC                = $(RC)
++
++QMAKE_STRIP             = $${OE_QMAKE_STRIP}
++QMAKE_STRIPFLAGS_LIB   += --strip-unneeded
++QMAKE_OBJCOPY           = $${CROSS_COMPILE}objcopy
++QMAKE_NM                = $${CROSS_COMPILE}nm -P
++
++isEmpty(QMAKE_QT_CONFIG):QMAKE_QT_CONFIG = $(OE_QMAKE_QT_CONFIG)
++load(qt_config)
+diff --git a/mkspecs/win32-g++-oe/qplatformdefs.h b/mkspecs/win32-g++-oe/qplatformdefs.h
+new file mode 100644
+index 0000000..9d63527
+--- /dev/null
++++ b/mkspecs/win32-g++-oe/qplatformdefs.h
+@@ -0,0 +1,42 @@
++/****************************************************************************
++**
++** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
++** Contact: http://www.qt-project.org/legal
++**
++** This file is part of the qmake spec of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and Digia.  For licensing terms and
++** conditions see http://qt.digia.com/licensing.  For further information
++** use the contact form at http://qt.digia.com/contact-us.
++**
++** GNU Lesser General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU Lesser
++** General Public License version 2.1 as published by the Free Software
++** Foundation and appearing in the file LICENSE.LGPL included in the
++** packaging of this file.  Please review the following information to
++** ensure the GNU Lesser General Public License version 2.1 requirements
++** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
++**
++** In addition, as a special exception, Digia gives you certain additional
++** rights.  These rights are described in the Digia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** GNU General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU
++** General Public License version 3.0 as published by the Free Software
++** Foundation and appearing in the file LICENSE.GPL included in the
++** packaging of this file.  Please review the following information to
++** ensure the GNU General Public License version 3.0 requirements will be
++** met: http://www.gnu.org/copyleft/gpl.html.
++**
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++#include "../win32-g++/qplatformdefs.h"
+-- 
+1.9.1
+
diff --git a/recipes-qt/qt5/qtbase_git.bbappend b/recipes-qt/qt5/qtbase_git.bbappend
index b8053a86..a3f3fa60 100644
--- a/recipes-qt/qt5/qtbase_git.bbappend
+++ b/recipes-qt/qt5/qtbase_git.bbappend
@@ -39,6 +39,7 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
 
 SRC_URI += " \
     file://oe-device-extra.pri \
+    file://0001-Add-win32-g-oe-mkspec-that-uses-the-OE_-environment.patch \
     "
 do_configure_prepend() {
     install -m 0644 ${WORKDIR}/oe-device-extra.pri ${S}/mkspecs
diff --git a/scripts/manifest.xml b/scripts/manifest.xml
index bb9d27b6..5ba0e814 100644
--- a/scripts/manifest.xml
+++ b/scripts/manifest.xml
@@ -25,7 +25,7 @@
            path="sources/meta-openembedded"/>
   <project name="meta-qt5"
            remote="qtyocto"
-           revision="60c8b35f13f0969a2244e5ab06333fc3994ed221"
+           revision="e29477ac42b47f4fedd2cb4be27ec2e4aa70540c"
            path="sources/meta-qt5"/>
 
   <project name="meta-mingw"
-- 
GitLab