diff mbox

[08/15] qmake5: mingw support

Message ID 6eb9da57648db0c969f64c77ec41acbcbe09cb7c.1404891982.git.Svend.Vedstesen@prevas.dk
State Accepted
Delegated to: Christian Sørensen
Headers show

Commit Message

Svend Aage Vedstesen July 9, 2014, 8:37 a.m. UTC
From: Christian Sørensen <christian.braunersorensen@prevas.dk>

---
 ...5-qmake-is-already-built-in-qtbase-native.patch |  30 ++++++
 .../mingw-disable-vars-from-shell.patch            | 104 +++++++++++++++++++++
 .../qmake5-5.1.1/mingw-manually-enable-msys.patch  |  11 +++
 recipes/qt5/qmake5-5.1.1/mingw-spec.patch          |  20 ++++
 .../qtbug-33155-mingw-w64-compilation.patch        |  43 +++++++++
 recipes/qt5/qmake5.inc                             |  70 ++++++++++++--
 6 files changed, 271 insertions(+), 7 deletions(-)
 create mode 100644 recipes/qt5/qmake5-5.1.1/0005-qmake-is-already-built-in-qtbase-native.patch
 create mode 100644 recipes/qt5/qmake5-5.1.1/mingw-disable-vars-from-shell.patch
 create mode 100644 recipes/qt5/qmake5-5.1.1/mingw-manually-enable-msys.patch
 create mode 100644 recipes/qt5/qmake5-5.1.1/mingw-spec.patch
 create mode 100644 recipes/qt5/qmake5-5.1.1/qtbug-33155-mingw-w64-compilation.patch
diff mbox

Patch

diff --git a/recipes/qt5/qmake5-5.1.1/0005-qmake-is-already-built-in-qtbase-native.patch b/recipes/qt5/qmake5-5.1.1/0005-qmake-is-already-built-in-qtbase-native.patch
new file mode 100644
index 0000000..b2121cf
--- /dev/null
+++ b/recipes/qt5/qmake5-5.1.1/0005-qmake-is-already-built-in-qtbase-native.patch
@@ -0,0 +1,30 @@ 
+From 7b37f7fa8c68c1807eeb45936154a42c34cda666 Mon Sep 17 00:00:00 2001
+From: Michael Krelin <hacker@klever.net>
+Date: Mon, 29 Oct 2012 20:07:49 -0700
+Subject: [PATCH 05/16] qmake is already built in qtbase-native
+
+Ported from OE by: Yu Ke <ke.yu@intel.com>
+Upstream-Status: Inappropriate [configuration]
+
+Signed-off-by: Mikko Levonmaa <mikko.levonmaa@gmail.com>
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
+---
+ configure | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure b/configure
+index 1ca5b4e..546bed2 100755
+--- a/configure
++++ b/configure
+@@ -3667,7 +3667,7 @@ setBootstrapEvalVariable()
+ 
+ 
+ # build qmake
+-if true; then ###[ '!' -f "$outpath/bin/qmake" ];
++if false; then ###[ '!' -f "$outpath/bin/qmake" ];
+     echo "Creating qmake..."
+ 
+     mkdir -p "$outpath/qmake" || exit
+-- 
+1.8.2.1
+
diff --git a/recipes/qt5/qmake5-5.1.1/mingw-disable-vars-from-shell.patch b/recipes/qt5/qmake5-5.1.1/mingw-disable-vars-from-shell.patch
new file mode 100644
index 0000000..f7a25b2
--- /dev/null
+++ b/recipes/qt5/qmake5-5.1.1/mingw-disable-vars-from-shell.patch
@@ -0,0 +1,104 @@ 
+--- qtbase-opensource-src-5.1.1/configure.old	2014-03-12 09:22:08.287336576 +0100
++++ qtbase-opensource-src-5.1.1/configure	2014-03-12 09:23:56.919335001 +0100
+@@ -291,16 +291,6 @@
+     getSingleQMakeVariable "$1" "$specvals"
+ }
+ 
+-# OE qmake.conf is reading some variables from shell env
+-# read them from qmake.conf, replace qmake () syntax with shell and eval
+-getQEvalMakeConf()
+-{
+-    VAL=`getQMakeConf "$1" | sed -n 's/$[(]\([0-9a-zA-Z_]*\)[)]/$\1/pg'`
+-    EVAL=`eval "echo ${VAL}"`
+-#    echo "Running getQEvalMakeConf: var='$1', val='`getQMakeConf \"$1\"`, val-sed='$VAL', eval='$EVAL'" >&2
+-    eval "echo ${VAL}"
+-}
+-
+ getXQMakeConf()
+ {
+     if [ -z "$xspecvals" ]; then
+@@ -310,16 +300,6 @@
+     getSingleQMakeVariable "$1" "$xspecvals"
+ }
+ 
+-# OE qmake.conf is reading some variables from shell env
+-# read them from qmake.conf, replace qmake () syntax with shell and eval
+-getXQEvalMakeConf()
+-{
+-    VAL=`getXQMakeConf "$1" | sed -n 's/$[(]\([0-9a-zA-Z_]*\)[)]/$\1/pg'`
+-    EVAL=`eval "echo ${VAL}"`
+-#    echo "Running getXQEvalMakeConf: var='$1', val='`getXQMakeConf \"$1\"`, val-sed='$VAL', eval='$EVAL'" >&2
+-    eval "echo ${VAL}"
+-}
+-
+ compilerSupportsFlag()
+ {
+     cat >conftest.cpp <<EOF
+@@ -836,18 +816,6 @@
+ # initalize variables
+ #-------------------------------------------------------------------------------
+ 
+-# Export all OE variables for qmake.conf from shell env to QMakeVars
+-OE_VARIABLES="AR CC CFLAGS COMPILER CXX CXXFLAGS LDFLAGS LINK QT_CONFIG STRIP"
+-for varname in $OE_VARIABLES; do
+-    qmakevarname="${varname}"
+-    cmd=`echo \
+-'if [ -n "\$OE_QMAKE_'${varname}'" ]; then
+-    QMakeVar set OE_QMAKE_'${qmakevarname}' "\$OE_QMAKE_'${varname}'"
+-#    echo "Exporting OE_QMAKE_'${qmakevarname}' value=\"\$OE_QMAKE_'${varname}'\"" >&2
+-fi'`
+-    eval "$cmd"
+-done
+-
+ SYSTEM_VARIABLES="RANLIB STRIP OBJDUMP LD CC CXX CFLAGS CXXFLAGS LDFLAGS"
+ 
+ # Use CC/CXX to run config.tests
+@@ -2913,7 +2881,7 @@
+     CFG_QGTKSTYLE=no
+ fi
+ 
+-QMAKE_CONF_COMPILER=`getXQEvalMakeConf QMAKE_CXX`
++QMAKE_CONF_COMPILER=`getXQMakeConf QMAKE_CXX`
+ 
+ TEST_COMPILER=$QMAKE_CONF_COMPILER
+ 
+@@ -2948,7 +2916,7 @@
+         exit 1
+     fi
+ fi
+-TEST_COMPILER_CXXFLAGS=`getXQEvalMakeConf QMAKE_CXXFLAGS`
++TEST_COMPILER_CXXFLAGS=`getXQMakeConf QMAKE_CXXFLAGS`
+ 
+ GCC_MACHINE_DUMP=
+ case "$TEST_COMPILER" in *g++) GCC_MACHINE_DUMP=$($TEST_COMPILER -dumpmachine);; esac
+@@ -3978,13 +3946,6 @@
+     getQMakeConf "$1" | echo ${2-$1} = `if [ -n "$3" ]; then sed "$3"; else cat; fi` >> "$mkfile"
+ }
+ 
+-# OE qmake.conf is reading some variables from shell env
+-# read them from qmake.conf, replace qmake () syntax with shell and eval
+-setBootstrapEvalVariable()
+-{
+-    getQEvalMakeConf "$1" | echo ${2-$1} = `if [ -n "$3" ]; then sed "$3"; else cat; fi` >> "$mkfile"
+-}
+-
+ 
+ # build qmake
+ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
+@@ -4024,11 +3985,11 @@
+         fi
+ 
+         [ "$CFG_SILENT" = "yes" ] && CC_TRANSFORM='s,^,\@,' || CC_TRANSFORM=
+-        setBootstrapEvalVariable QMAKE_CC CC "$CC_TRANSFORM"
+-        setBootstrapEvalVariable QMAKE_CXX CXX "$CC_TRANSFORM"
+-        setBootstrapEvalVariable QMAKE_CFLAGS
+-        setBootstrapEvalVariable QMAKE_CXXFLAGS
+-        setBootstrapEvalVariable QMAKE_LFLAGS
++        setBootstrapVariable QMAKE_CC CC "$CC_TRANSFORM"
++        setBootstrapVariable QMAKE_CXX CXX "$CC_TRANSFORM"
++        setBootstrapVariable QMAKE_CFLAGS
++        setBootstrapVariable QMAKE_CXXFLAGS
++        setBootstrapVariable QMAKE_LFLAGS
+ 
+         if [ "$CFG_RELEASE_QMAKE" = "yes" ]; then
+             setBootstrapVariable QMAKE_CFLAGS_RELEASE
diff --git a/recipes/qt5/qmake5-5.1.1/mingw-manually-enable-msys.patch b/recipes/qt5/qmake5-5.1.1/mingw-manually-enable-msys.patch
new file mode 100644
index 0000000..2c6bd3a
--- /dev/null
+++ b/recipes/qt5/qmake5-5.1.1/mingw-manually-enable-msys.patch
@@ -0,0 +1,11 @@ 
+--- qtbase-opensource-src-5.1.1/configure.old	2014-03-11 13:41:46.362623481 +0100
++++ qtbase-opensource-src-5.1.1/configure	2014-03-11 13:42:18.250624617 +0100
+@@ -445,7 +445,7 @@
+     BUILD_ON_MAC=yes
+     PLATFORM_MAC=maybe
+ fi
+-BUILD_ON_MSYS=no
++BUILD_ON_MSYS=yes
+ HOST_DIRLIST_SEP=":"
+ DEV_NULL=/dev/null
+ if [ "$OSTYPE" = "msys" ]; then
diff --git a/recipes/qt5/qmake5-5.1.1/mingw-spec.patch b/recipes/qt5/qmake5-5.1.1/mingw-spec.patch
new file mode 100644
index 0000000..78a024c
--- /dev/null
+++ b/recipes/qt5/qmake5-5.1.1/mingw-spec.patch
@@ -0,0 +1,20 @@ 
+--- qtbase-opensource-src-5.1.1/mkspecs/win32-g++/qmake.conf~orig	2014-03-10 13:18:52.166561069 +0100
++++ qtbase-opensource-src-5.1.1/mkspecs/win32-g++/qmake.conf	2014-03-10 13:18:50.222561071 +0100
+@@ -13,7 +13,7 @@
+ QMAKE_PLATFORM          = win32 mingw
+ CONFIG                 += debug_and_release debug_and_release_target precompile_header
+ DEFINES                += UNICODE
+-QMAKE_COMPILER_DEFINES += __GNUC__ WIN32
++QMAKE_COMPILER_DEFINES += __GNUC__ WIN32 Q_OS_WIN
+ 
+ QMAKE_EXT_OBJ           = .o
+ QMAKE_EXT_RES           = _res.o
+@@ -25,7 +25,7 @@
+ QMAKE_LEXFLAGS          =
+ QMAKE_YACC              = byacc
+ QMAKE_YACCFLAGS         = -d
+-QMAKE_CFLAGS            = -pipe -fno-keep-inline-dllexport
++QMAKE_CFLAGS            = -pipe -fno-keep-inline-dllexport -DUNICODE -D_UNICODE
+ QMAKE_CFLAGS_DEPS       = -M
+ QMAKE_CFLAGS_WARN_ON    = -Wall -Wextra
+ QMAKE_CFLAGS_WARN_OFF   = -w
diff --git a/recipes/qt5/qmake5-5.1.1/qtbug-33155-mingw-w64-compilation.patch b/recipes/qt5/qmake5-5.1.1/qtbug-33155-mingw-w64-compilation.patch
new file mode 100644
index 0000000..9d1f1b3
--- /dev/null
+++ b/recipes/qt5/qmake5-5.1.1/qtbug-33155-mingw-w64-compilation.patch
@@ -0,0 +1,43 @@ 
+From e59a5f9fdcec5df2f54e88d75a75fcb4a2fe577b Mon Sep 17 00:00:00 2001
+From: Friedemann Kleint <Friedemann.Kleint@digia.com>
+Date: Mon, 26 Aug 2013 11:52:47 +0200
+Subject: [PATCH] Windows: Fix compilation with MinGW-64, gcc 4.8.1
+
+A definition for FILE_ID_128 was added.
+
+Change-Id: Ifdfe5da1b15a90afdf5cf09d92838a04b1cf5c19
+Reviewed-by: Kai Koehne <kai.koehne@digia.com>
+---
+ src/corelib/io/qfilesystemengine_win.cpp |    6 +++++-
+ 1 files changed, 5 insertions(+), 1 deletions(-)
+
+diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
+index e8904b0..57231b5 100644
+--- a/src/corelib/io/qfilesystemengine_win.cpp
++++ b/src/corelib/io/qfilesystemengine_win.cpp
+@@ -573,9 +573,12 @@ typedef enum { Q_FileIdInfo = 18 } Q_FILE_INFO_BY_HANDLE_CLASS;
+ 
+ #  if defined(Q_CC_MINGW) || (defined(Q_CC_MSVC) && _MSC_VER < 1700)
+ 
++// MinGW-64 defines FILE_ID_128 as of gcc-4.8.1 along with FILE_SUPPORTS_INTEGRITY_STREAMS
++#    if !(defined(Q_CC_MINGW) && defined(FILE_SUPPORTS_INTEGRITY_STREAMS))
+ typedef struct _FILE_ID_128 {
+     BYTE  Identifier[16];
+ } FILE_ID_128, *PFILE_ID_128;
++#    endif // !(Q_CC_MINGW && FILE_SUPPORTS_INTEGRITY_STREAMS)
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+@@ -614,7 +617,8 @@ QByteArray fileIdWin8(HANDLE handle)
+                                          &infoEx, sizeof(FILE_ID_INFO))) {
+             result = QByteArray::number(infoEx.VolumeSerialNumber, 16);
+             result += ':';
+-            result += QByteArray((char *)infoEx.FileId.Identifier, sizeof(infoEx.FileId.Identifier)).toHex();
++            // Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one.
++            result += QByteArray((char *)&infoEx.FileId, sizeof(infoEx.FileId)).toHex();
+         }
+     }
+     return result;
+-- 
+1.7.1
+
diff --git a/recipes/qt5/qmake5.inc b/recipes/qt5/qmake5.inc
index bb5034b..5797a9f 100644
--- a/recipes/qt5/qmake5.inc
+++ b/recipes/qt5/qmake5.inc
@@ -2,8 +2,10 @@  DESCRIPTION = "Native version of Qt/[X11|Mac|Embedded]"
 LICENSE = "GFDL-1.3 & LGPL-2.1 & GPL-3.0"
 DEPENDS = "zlib"
 
-DEPENDS:>sdk = " libdl libpthread librt libm"
-RDEPENDS_${PN}:>sdk = "libdl libphtread librt libm"
+EXTRA_DEPENDS_SDK = "libdl librt"
+EXTRA_DEPENDS_SDK:HOST_LIBC_mingw = ""
+DEPENDS:>sdk = " libpthread libm ${EXTRA_DEPENDS_SDK} native:qmake5"
+RDEPENDS_${PN}:>sdk = " libphtread libm ${EXTRA_DEPENDS_SDK}"
 HOMEPAGE = "http://qt-project.org"
 
 QT_MODULE = "qtbase"
@@ -13,7 +15,7 @@  inherit c++ make
 require qmake5-5.1.1.inc
 
 #TBD: Bugs are seen with more more than 1 parallel maker
-PARALLEL_MAKE:sdk = ""
+#PARALLEL_MAKE:sdk = ""
 
 SRC_URI += " \
     file://0001-Add-linux-oe-g-platform.patch \
@@ -27,6 +29,13 @@  SRC_URI += " \
     file://always_build_uic.patch \
 "
 
+SRC_URI:>HOST_LIBC_mingw = "\
+    file://qtbug-33155-mingw-w64-compilation.patch\
+    file://mingw-spec.patch\
+    file://mingw-manually-enable-msys.patch \
+    file://mingw-disable-vars-from-shell.patch \
+"
+
 QT_CONF_PATH = "${B}/qt.conf"
 
 EXTRA_OECONF = " \
@@ -62,8 +71,16 @@  EXTRA_OECONF = " \
     -nomake examples \
     -nomake tests \
     -no-rpath \
-    -platform linux-oe-g++ \
+    -platform ${BUILD_PLATFORM} \
 "
+BUILD_PLATFORM = "linux-oe-g++"
+BUILD_PLATFORM:HOST_LIBC_mingw = "win32-g++"
+EXTRA_OECONF:>HOST_LIBC_mingw += " \
+    -xplatform win32-g++ \
+    -device-option CROSS_COMPILE=${HOST_PREFIX} \
+    -qpa windows"
+
+
 # qtbase is exception, configure script is using our get(X)QEvalMakeConf and setBootstrapEvalVariable functions to read it from shell
 export OE_QMAKE_COMPILER
 export OE_QMAKE_CC
@@ -75,21 +92,60 @@  export OE_QMAKE_LDFLAGS
 export OE_QMAKE_AR
 export OE_QMAKE_STRIP
 
+CONFIGURE_MINGW_UTILS = ""
+CONFIGURE_MINGW_UTILS:HOST_LIBC_mingw = "do_configure_mingw"
+do_configure[prefuncs] += "${CONFIGURE_MINGW_UTILS}"
+do_configure_mingw () {
+#Use native tools to build instead of using the mingw tools
+    ln -sf ${STAGE_DIR}/native/bin/qmake ${S}/bin/qmake
+    ln -sf ${STAGE_DIR}/native/bin/moc ${S}/bin/moc.exe
+    ln -sf ${STAGE_DIR}/native/bin/rcc ${S}/bin/rcc.exe
+    ln -sf ${STAGE_DIR}/native/bin/uic ${S}/bin/uic.exe
+}
+
+USE_MINGW_SPEC = ""
+USE_MINGW_SPEC:HOST_LIBC_mingw = "-spec ${S}/mkspecs/win32-g++"
+
 do_configure[prefuncs] += "do_configure_preqt"
 do_configure_preqt() {
     (echo o; echo yes) | ${S}/configure ${EXTRA_OECONF} || die "Configuring qt failed. EXTRA_OECONF was ${EXTRA_OECONF}"
-    bin/qmake ${OE_QMAKE_DEBUG_OUTPUT} ${S} -o Makefile || die "Configuring qt with qmake failed. EXTRA_OECONF was ${EXTRA_OECONF}"
+    bin/qmake ${USE_MINGW_SPEC} ${OE_QMAKE_DEBUG_OUTPUT} ${S} -o Makefile || die "Configuring qt with qmake failed. EXTRA_OECONF was ${EXTRA_OECONF}"
+}
+
+CONFIGURE_BUILD_MINGW_UTILS = ""
+CONFIGURE_BUILD_MINGW_UTILS:HOST_LIBC_mingw = "do_configure_mingw2"
+do_configure[postfuncs] += "${CONFIGURE_BUILD_MINGW_UTILS}"
+do_configure_mingw2 () {
+    #Set the build target to something else, so it does not overwrite
+    #the native tools
+    echo "TARGET = \"realmoc\"" >> ${S}/src/tools/moc/moc.pro
+    echo "TARGET = \"realrcc\"" >> ${S}/src/tools/rcc/rcc.pro
+    echo "TARGET = \"realuic\"" >> ${S}/src/tools/uic/uic.pro
 }
 
-do_install() {
 
+do_install() {
     oe_runmake install INSTALL_ROOT=${D}
 
 }
 
+INSTALL_MINGW_UTILS = ""
+INSTALL_MINGW_UTILS:HOST_LIBC_mingw = "do_install_mingw_fixup"
+do_install[postfuncs] += "${INSTALL_MINGW_UTILS}"
+do_install_mingw_fixup () {
+    #Set the correct name of the build mingw utils
+    rm ${D}${bindir}/qmake
+    install ${S}/bin/qmake.exe ${D}${bindir}
+    mv ${D}${bindir}/realmoc.exe ${D}${bindir}/moc.exe
+    mv ${D}${bindir}/realuic.exe ${D}${bindir}/uic.exe
+    mv ${D}${bindir}/realrcc.exe ${D}${bindir}/rcc.exe
+}
+
 FILES_${PN} += " ${libdir}"
 
 PACKAGES =+ " ${PN}-utilities "
 FILES_${PN}-utilities = "${bindir}"
 DEPENDS_${PN} += "${PN}-utilities"
-RDEPENDS_${PN}-utilities = "librt libgcc libpthread libz libstdc++ libm"
+EXTRA_RDEPENDS_UTILITIES = "librt"
+EXTRA_RDEPENDS_UTILITIES:HOST_LIBC_mingw = ""
+RDEPENDS_${PN}-utilities = "${EXTRA_RDEPENDS_UTILITIES} libgcc libpthread libz libstdc++ libm"