summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichel Zou2018-05-02 20:25:59 +0200
committerMichel Zou2018-05-02 20:25:59 +0200
commit4d08d8d43697ea96da9cb31f8d1af26ecae0704d (patch)
treecc2bddc956408a1808eb3bd8941d27e96c67246b
downloadaur-4d08d8d43697ea96da9cb31f8d1af26ecae0704d.tar.gz
import
-rw-r--r--.SRCINFO110
-rw-r--r--0001-Add-profile-for-cross-compilation-with-mingw-w64.patch314
-rw-r--r--0002-Ensure-GLdouble-is-defined-when-using-dynamic-OpenGL.patch27
-rw-r--r--0003-Use-external-ANGLE-library.patch97
-rw-r--r--0004-Fix-too-many-sections-assemler-error-in-OpenGL-facto.patch29
-rw-r--r--0005-Make-sure-.pc-files-are-installed-correctly.patch66
-rw-r--r--0006-Don-t-add-resource-files-to-LIBS-parameter.patch28
-rw-r--r--0007-Prevent-debug-library-names-in-pkg-config-files.patch33
-rw-r--r--0008-Fix-linking-against-shared-static-libpng.patch27
-rw-r--r--0009-Fix-linking-against-static-D-Bus.patch58
-rw-r--r--0010-Don-t-try-to-use-debug-version-of-D-Bus-library.patch29
-rw-r--r--0011-Fix-linking-against-static-freetype2.patch30
-rw-r--r--0012-Fix-linking-against-static-harfbuzz.patch29
-rw-r--r--0013-Fix-linking-against-static-pcre.patch28
-rw-r--r--0014-Fix-linking-against-shared-static-MariaDB.patch27
-rw-r--r--0015-Fix-linking-against-shared-static-PostgreSQL.patch29
-rw-r--r--0016-Rename-qtmain-to-qt5main.patch56
-rw-r--r--0017-Build-dynamic-host-libraries.patch41
-rw-r--r--0018-Enable-rpath-for-build-tools.patch37
-rw-r--r--0019-Use-system-zlib-for-build-tools.patch25
-rw-r--r--0020-Use-.dll.a-as-import-lib-extension.patch68
-rw-r--r--0021-Merge-shared-and-static-library-trees.patch132
-rw-r--r--0022-Pull-dependencies-of-static-libraries-in-CMake-modul.patch282
-rw-r--r--0023-Allow-usage-of-static-version-with-CMake.patch1001
-rw-r--r--0024-Adjust-linker-flags-for-static-build-with-cmake-ming.patch29
-rw-r--r--0025-Use-correct-pkg-config-static-flag.patch26
-rw-r--r--0026-Fix-macro-invoking-moc-rcc-and-uic.patch74
-rw-r--r--0027-Ignore-errors-about-missing-feature-static.patch36
-rw-r--r--0028-Enable-and-fix-use-of-iconv.patch83
-rw-r--r--0029-Ignore-failing-pkg-config-test.patch25
-rw-r--r--0030-Prevent-qmake-from-messing-static-lib-dependencies.patch43
-rw-r--r--0031-Hardcode-linker-flags-for-platform-plugins.patch110
-rw-r--r--0032-Fix-linking-against-static-plugins-with-qmake.patch37
-rw-r--r--PKGBUILD438
-rw-r--r--qt-no-statx.patch24
35 files changed, 3528 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..a41fa6d8324f
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,110 @@
+# Generated by mksrcinfo v8
+# Wed May 2 18:25:59 UTC 2018
+pkgbase = mingw-w64-qt5-base-nostatx
+ pkgdesc = A cross-platform application and UI framework (mingw-w64)
+ pkgver = 5.10.1
+ pkgrel = 1
+ url = https://www.qt.io/
+ arch = i686
+ arch = x86_64
+ groups = mingw-w64-qt5
+ license = GPL3
+ license = LGPL3
+ license = FDL
+ license = custom
+ makedepends = mingw-w64-gcc
+ makedepends = mingw-w64-postgresql
+ makedepends = mingw-w64-mariadb-connector-c
+ makedepends = mingw-w64-pkg-config
+ depends = mingw-w64-crt
+ depends = mingw-w64-zlib
+ depends = mingw-w64-libjpeg-turbo
+ depends = mingw-w64-sqlite
+ depends = mingw-w64-libpng
+ depends = mingw-w64-openssl
+ depends = mingw-w64-dbus
+ depends = mingw-w64-harfbuzz
+ depends = mingw-w64-pcre2
+ optdepends = mingw-w64-postgresql: PostgreSQL support
+ optdepends = mingw-w64-mariadb-connector-c: MySQL support
+ provides = mingw-w64-qt5-base
+ conflicts = mingw-w64-qt5-base
+ conflicts = mingw-w64-qt5-base-angle
+ conflicts = mingw-w64-qt5-base-noopengl
+ conflicts = mingw-w64-qt5-base-dynamic
+ conflicts = mingw-w64-qt5-base-openql
+ options = !strip
+ options = !buildflags
+ options = staticlibs
+ options = !emptydirs
+ source = https://download.qt.io/official_releases/qt/5.10/5.10.1/submodules/qtbase-everywhere-src-5.10.1.tar.xz
+ source = 0001-Add-profile-for-cross-compilation-with-mingw-w64.patch
+ source = 0002-Ensure-GLdouble-is-defined-when-using-dynamic-OpenGL.patch
+ source = 0003-Use-external-ANGLE-library.patch
+ source = 0004-Fix-too-many-sections-assemler-error-in-OpenGL-facto.patch
+ source = 0005-Make-sure-.pc-files-are-installed-correctly.patch
+ source = 0006-Don-t-add-resource-files-to-LIBS-parameter.patch
+ source = 0007-Prevent-debug-library-names-in-pkg-config-files.patch
+ source = 0008-Fix-linking-against-shared-static-libpng.patch
+ source = 0009-Fix-linking-against-static-D-Bus.patch
+ source = 0010-Don-t-try-to-use-debug-version-of-D-Bus-library.patch
+ source = 0011-Fix-linking-against-static-freetype2.patch
+ source = 0012-Fix-linking-against-static-harfbuzz.patch
+ source = 0013-Fix-linking-against-static-pcre.patch
+ source = 0014-Fix-linking-against-shared-static-MariaDB.patch
+ source = 0015-Fix-linking-against-shared-static-PostgreSQL.patch
+ source = 0016-Rename-qtmain-to-qt5main.patch
+ source = 0017-Build-dynamic-host-libraries.patch
+ source = 0018-Enable-rpath-for-build-tools.patch
+ source = 0019-Use-system-zlib-for-build-tools.patch
+ source = 0020-Use-.dll.a-as-import-lib-extension.patch
+ source = 0021-Merge-shared-and-static-library-trees.patch
+ source = 0022-Pull-dependencies-of-static-libraries-in-CMake-modul.patch
+ source = 0023-Allow-usage-of-static-version-with-CMake.patch
+ source = 0024-Adjust-linker-flags-for-static-build-with-cmake-ming.patch
+ source = 0025-Use-correct-pkg-config-static-flag.patch
+ source = 0026-Fix-macro-invoking-moc-rcc-and-uic.patch
+ source = 0027-Ignore-errors-about-missing-feature-static.patch
+ source = 0028-Enable-and-fix-use-of-iconv.patch
+ source = 0029-Ignore-failing-pkg-config-test.patch
+ source = 0030-Prevent-qmake-from-messing-static-lib-dependencies.patch
+ source = 0031-Hardcode-linker-flags-for-platform-plugins.patch
+ source = 0032-Fix-linking-against-static-plugins-with-qmake.patch
+ source = qt-no-statx.patch
+ sha256sums = d8660e189caa5da5142d5894d328b61a4d3ee9750b76d61ad74e4eee8765a969
+ sha256sums = 6b29d7a3751a506c15155425d6dc213e9f4654ee5b833007a0119bda6a050b28
+ sha256sums = ca10438f4a2d309f496e85d7b974d9eeb88115e068e146ca511b9784db95b822
+ sha256sums = 75bf0d8b155f95bad2dfbc5c046f88afd6a5f2233336a1f6d148583ba445fca6
+ sha256sums = d70dcd1c44e751b0120f514af9db4ff20ebb0a327a22a371cf5e8d9453f66953
+ sha256sums = cbad834340bc9e9261704034e9192bd0d7306f9ff02a99fd73fc348948c37ed9
+ sha256sums = 3c7cd1839a6f0891b871c75824b8ebeb05e4e61884c342d6b6ab583f10819138
+ sha256sums = c923da99871dac4fc58b8e70bd76c70fba0f421fc676a53bcb8c0187190ba737
+ sha256sums = f9be656281652f72297f1e573f23298c22f4849857d92106096feb4b3fe9244f
+ sha256sums = 5add111a9e521159e31ecef4d85ebef86285bbbe2adce5d8cec94fd22822731e
+ sha256sums = 7d38e79bc6b2e5d74515291bf78c3a6168f8bc834f7f59bda2c013f65e45bd3e
+ sha256sums = 9ab62cc8cd1cf68ee5e87e276d5a2f19c43b04a1c50c10341794924277cfcca5
+ sha256sums = f1926bd51376a95ea1deee933dadd62166296e5780e24ce8312637c9d3eda27b
+ sha256sums = 03f7a178af6b630f48da79c76e1239695d96137fd8394ba814e4bdf8c7e0a826
+ sha256sums = dc3e0e3fe4ba979f74ff9dc343b235d32473edb18ca7f8afea3076f613564a95
+ sha256sums = ef64b965a19e1e2848761829a6817dcb9f3ad616faa666f9e52736d810190c66
+ sha256sums = 9e0c3848df586ec7decd9b7a6dab86a9e7e5cc7bf5ac06ff97d7d63e370bb05b
+ sha256sums = 7dc90045a838f9ebcb7933d582abb3e8bba250644602e1019bf1a03e74cc3b09
+ sha256sums = b5cc23a29e80ec8185da8ca0950ab8a2f12f4ef4b998c763334d352e68b53fc2
+ sha256sums = 944cfdbfd9d13285aefb4305596950d2880cc1023b5ad241af08e3d6995daa69
+ sha256sums = 5f7498a98912542c39b081c2df1930246df3bdb533c2e30204bf795cea8b885f
+ sha256sums = 0b8408d70a4544e43fd573e5b9ac751fb2732d3e4490f21e1737ac09ece25b62
+ sha256sums = 08155a41f22c03741096145bf201d5503e38495c2f255f3c81ea658948258cd3
+ sha256sums = 7b30d46f739dffa20a1964e09958a92af1749104fe7a88d7ea255aa54e553b25
+ sha256sums = c92d6a124b7b0333175122555ef9f647817eb54563480cf3eaaf47decfd907c3
+ sha256sums = 0818c4d59aabb898fed8f313e21085cc8fc576d3f4975383eb73ba3f758c302e
+ sha256sums = ce5d416a3404199072062063d8038084c23bbfe8aa45ed3340c4afb4dfa461e4
+ sha256sums = 8d1e93bea1cdcdf1b965f4c061975668334cef6a65130f1b4b528f2b6952a602
+ sha256sums = 298ffdcd378e2b07fe8e978cfb5faac29c117a5f79288273545a6938b905f33a
+ sha256sums = 7514edba8ecd28b27715650bbafa8649492b68efba1df9c9fa70f06a924fea14
+ sha256sums = 7c232c385303b447e17270b946d333b56274312b08b4e76439a5f77cb77aa909
+ sha256sums = acfdf70ae8738a0373bbd93e42048d1c699f666dd72933ad3c09b09620fb0715
+ sha256sums = c3df40da9b2494e59aae786a26ba93d88128b69971d10a64cb6d610045a101f8
+ sha256sums = fb4c2d464cd7c3fbd1bf488cf694dcfdc6cb515a8d7ddb9b41d9b6bef5da3be2
+
+pkgname = mingw-w64-qt5-base-nostatx
+
diff --git a/0001-Add-profile-for-cross-compilation-with-mingw-w64.patch b/0001-Add-profile-for-cross-compilation-with-mingw-w64.patch
new file mode 100644
index 000000000000..7f9af67268fd
--- /dev/null
+++ b/0001-Add-profile-for-cross-compilation-with-mingw-w64.patch
@@ -0,0 +1,314 @@
+From fc85bad55db9fd58860c84e74ba3de1720111ef1 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Fri, 3 Feb 2017 18:30:51 +0100
+Subject: [PATCH 01/32] Add profile for cross compilation with mingw-w64
+
+---
+ mkspecs/mingw-w64-g++/qmake.conf | 132 +++++++++++++++++++++++++++++
+ mkspecs/mingw-w64-g++/qplatformdefs.h | 155 ++++++++++++++++++++++++++++++++++
+ 2 files changed, 287 insertions(+)
+ create mode 100644 mkspecs/mingw-w64-g++/qmake.conf
+ create mode 100644 mkspecs/mingw-w64-g++/qplatformdefs.h
+
+diff --git a/mkspecs/mingw-w64-g++/qmake.conf b/mkspecs/mingw-w64-g++/qmake.conf
+new file mode 100644
+index 0000000000..978867fa1b
+--- /dev/null
++++ b/mkspecs/mingw-w64-g++/qmake.conf
+@@ -0,0 +1,132 @@
++#
++# qmake configuration for i686-w64-mingw32-g++ and x86_64-w64-mingw32-g++
++#
++# Written for cross compilation with mingw-w64 under GNU/Linux
++#
++# Cross compile example for i686-w64-mingw32-g++:
++# configure -xplatform mingw-w64-g++ -device-option CROSS_COMPILE=i686-w64-mingw32-
++#
++
++load(device_config)
++include(../common/angle.conf)
++
++MAKEFILE_GENERATOR = MINGW
++QMAKE_PLATFORM = win32 win32-g++ mingw
++CONFIG += debug_and_release debug_and_release_target precompile_header $${CROSS_COMPILE_CUSTOM_CONFIG}
++DEFINES += UNICODE
++QMAKE_COMPILER_DEFINES += __GNUC__ WIN32
++
++QMAKE_EXT_OBJ = .o
++QMAKE_EXT_RES = _res.o
++
++QMAKE_COMPILER = gcc
++
++QMAKE_CC = $${CROSS_COMPILE}gcc
++QMAKE_LEX = flex
++QMAKE_LEXFLAGS =
++QMAKE_YACC = bison -y
++QMAKE_YACCFLAGS = -d
++QMAKE_CFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -fno-keep-inline-dllexport $${CROSS_COMPILE_CFLAGS}
++QMAKE_CFLAGS_DEPS = -M
++QMAKE_CFLAGS_WARN_ON = -Wall -Wextra
++QMAKE_CFLAGS_WARN_OFF = -w
++QMAKE_CFLAGS_RELEASE = -O2
++QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO = -O2 -g
++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 = $${CROSS_COMPILE}g++
++QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
++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_RELEASE_WITH_DEBUGINFO = $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
++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++11
++QMAKE_CXXFLAGS_CXX14 = -std=c++1y
++QMAKE_CXXFLAGS_CXX1Z = -std=c++1z
++QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++11
++QMAKE_CXXFLAGS_GNUCXX14 = -std=gnu++1y
++QMAKE_CXXFLAGS_GNUCXX1Z = -std=gnu++1z
++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 = $${CROSS_COMPILE}g++
++QMAKE_LINK_C = $${CROSS_COMPILE}gcc
++QMAKE_LFLAGS = -g
++QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads
++QMAKE_LFLAGS_EXCEPTIONS_OFF =
++QMAKE_LFLAGS_RELEASE =
++QMAKE_LFLAGS_DEBUG =
++QMAKE_LFLAGS_CONSOLE = -Wl,-subsystem,console
++QMAKE_LFLAGS_WINDOWS = -Wl,-subsystem,windows
++QMAKE_LFLAGS_DLL = -shared
++QMAKE_LFLAGS_CXX11 =
++QMAKE_LFLAGS_CXX14 =
++QMAKE_LFLAGS_CXX1Z =
++QMAKE_LFLAGS_GCSECTIONS = -Wl,--gc-sections
++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_EXTENSION_IMPORTLIB = dll.a
++
++QMAKE_IDL = $${CROSS_COMPILE}widl
++QMAKE_LIB = $${CROSS_COMPILE}ar -rc
++QMAKE_RC = $${CROSS_COMPILE}windres
++QMAKE_DLLTOOL = $${CROSS_COMPILE}dlltool
++QMAKE_LRELEASE = $${CROSS_COMPILE}lrelease-qt5
++
++QMAKE_STRIP = $${CROSS_COMPILE}strip
++QMAKE_STRIPFLAGS_LIB += --strip-unneeded
++QMAKE_OBJCOPY = $${CROSS_COMPILE}objcopy
++QMAKE_NM = $${CROSS_COMPILE}nm -P
++
++PKG_CONFIG = $${CROSS_COMPILE}pkg-config
++QMAKE_PKG_CONFIG = $${CROSS_COMPILE}pkg-config
++
++QMAKE_LIBS =
++QMAKE_LIBS_CORE = -lz -lpcre2-16 -liconv -lversion -lnetapi32 -luserenv -lole32 -luuid -lwinmm -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32
++QMAKE_LIBS_GUI = -lopengl32 -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lws2_32 -lole32 -luuid -luser32 -ladvapi32 -ljpeg -lpng \
++ $$system($${QMAKE_PKG_CONFIG} --libs harfbuzz) \
++ $$system($${QMAKE_PKG_CONFIG} --libs freetype2)
++QMAKE_LIBS_GUI_STATIC = -lopengl32 -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lws2_32 -lole32 -luuid -luser32 -ladvapi32 -ljpeg -lpng \
++ $$system($${QMAKE_PKG_CONFIG} --static --libs harfbuzz) \
++ $$system($${QMAKE_PKG_CONFIG} --static --libs freetype2)
++QMAKE_LIBS_NETWORK = -lws2_32 -lcrypt32 -ldnsapi -liphlpapi
++QMAKE_LIBS_NETWORK_STATIC = $$system($${QMAKE_PKG_CONFIG} --static --libs openssl) \
++ -lws2_32 -lcrypt32 -ldnsapi -liphlpapi
++QMAKE_LIBS_DBUS = $$system($${QMAKE_PKG_CONFIG} --libs dbus-1)
++QMAKE_LIBS_DBUS_STATIC = $$system($${QMAKE_PKG_CONFIG} --static --libs dbus-1)
++QMAKE_LIBS_WIDGETS_STATIC = -ldwmapi -luxtheme
++QMAKE_LIBS_OPENGL = -lglu32 -lopengl32 -lgdi32 -luser32
++QMAKE_LIBS_OPENGL_ES2 = -l$${LIBEGL_NAME} -l$${LIBGLESV2_NAME} -ld3d9 -ldxguid -lgdi32 -luser32
++QMAKE_LIBS_OPENGL_ES2_DEBUG = -l$${LIBEGL_NAME} -l$${LIBGLESV2_NAME} -ld3d9 -ldxguid -lgdi32 -luser32
++QMAKE_LIBS_COMPAT = -ladvapi32 -lshell32 -lcomdlg32 -luser32 -lgdi32 -lws2_32
++QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqt5main
++
++load(qt_config)
+diff --git a/mkspecs/mingw-w64-g++/qplatformdefs.h b/mkspecs/mingw-w64-g++/qplatformdefs.h
+new file mode 100644
+index 0000000000..c5a70b1445
+--- /dev/null
++++ b/mkspecs/mingw-w64-g++/qplatformdefs.h
+@@ -0,0 +1,155 @@
++/****************************************************************************
++**
++** Copyright (C) 2016 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** 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 The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
++** Foundation and appearing in the file LICENSE.LGPL3 included in the
++** packaging of this file. Please review the following information to
++** ensure the GNU Lesser General Public License version 3 requirements
++** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
++**
++** GNU General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU
++** General Public License version 2.0 or (at your option) the GNU General
++** Public license version 3 or any later version approved by the KDE Free
++** Qt Foundation. The licenses are as published by the Free Software
++** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
++** included in the packaging of this file. Please review the following
++** information to ensure the GNU General Public License requirements will
++** be met: https://www.gnu.org/licenses/gpl-2.0.html and
++** https://www.gnu.org/licenses/gpl-3.0.html.
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++#ifndef QPLATFORMDEFS_H
++#define QPLATFORMDEFS_H
++
++#ifdef UNICODE
++#ifndef _UNICODE
++#define _UNICODE
++#endif
++#endif
++
++// Get Qt defines/settings
++
++#include "qglobal.h"
++
++#include <tchar.h>
++#include <io.h>
++#include <direct.h>
++#include <stdio.h>
++#include <fcntl.h>
++#include <errno.h>
++#include <sys/stat.h>
++#include <stdlib.h>
++#include <limits.h>
++
++#if !defined(_WIN32_WINNT) || (_WIN32_WINNT-0 < 0x0500)
++typedef enum {
++ NameUnknown = 0,
++ NameFullyQualifiedDN = 1,
++ NameSamCompatible = 2,
++ NameDisplay = 3,
++ NameUniqueId = 6,
++ NameCanonical = 7,
++ NameUserPrincipal = 8,
++ NameCanonicalEx = 9,
++ NameServicePrincipal = 10,
++ NameDnsDomain = 12
++} EXTENDED_NAME_FORMAT, *PEXTENDED_NAME_FORMAT;
++#endif
++
++#ifdef QT_LARGEFILE_SUPPORT
++#define QT_STATBUF struct _stati64 // non-ANSI defs
++#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs
++#define QT_STAT ::_stati64
++#define QT_FSTAT ::_fstati64
++#else
++#define QT_STATBUF struct _stat // non-ANSI defs
++#define QT_STATBUF4TSTAT struct _stat // non-ANSI defs
++#define QT_STAT ::_stat
++#define QT_FSTAT ::_fstat
++#endif
++#define QT_STAT_REG _S_IFREG
++#define QT_STAT_DIR _S_IFDIR
++#define QT_STAT_MASK _S_IFMT
++#if defined(_S_IFLNK)
++# define QT_STAT_LNK _S_IFLNK
++#endif
++#define QT_FILENO _fileno
++#define QT_OPEN ::_open
++#define QT_CLOSE ::_close
++#ifdef QT_LARGEFILE_SUPPORT
++#define QT_LSEEK ::_lseeki64
++#ifndef UNICODE
++#define QT_TSTAT ::_stati64
++#else
++#define QT_TSTAT ::_wstati64
++#endif
++#else
++#define QT_LSEEK ::_lseek
++#ifndef UNICODE
++#define QT_TSTAT ::_stat
++#else
++#define QT_TSTAT ::_wstat
++#endif
++#endif
++#define QT_READ ::_read
++#define QT_WRITE ::_write
++#define QT_ACCESS ::_access
++#define QT_GETCWD ::_getcwd
++#define QT_CHDIR ::_chdir
++#define QT_MKDIR ::_mkdir
++#define QT_RMDIR ::_rmdir
++#define QT_OPEN_LARGEFILE 0
++#define QT_OPEN_RDONLY _O_RDONLY
++#define QT_OPEN_WRONLY _O_WRONLY
++#define QT_OPEN_RDWR _O_RDWR
++#define QT_OPEN_CREAT _O_CREAT
++#define QT_OPEN_TRUNC _O_TRUNC
++#define QT_OPEN_APPEND _O_APPEND
++#if defined(O_TEXT)
++# define QT_OPEN_TEXT _O_TEXT
++# define QT_OPEN_BINARY _O_BINARY
++#endif
++
++#include "../common/c89/qplatformdefs.h"
++
++#ifdef QT_LARGEFILE_SUPPORT
++#undef QT_FSEEK
++#undef QT_FTELL
++#undef QT_OFF_T
++
++#define QT_FSEEK ::fseeko64
++#define QT_FTELL ::ftello64
++#define QT_OFF_T off64_t
++#endif
++
++#define QT_SIGNAL_ARGS int
++
++#define QT_VSNPRINTF ::_vsnprintf
++#define QT_SNPRINTF ::_snprintf
++
++# define F_OK 0
++# define X_OK 1
++# define W_OK 2
++# define R_OK 4
++
++
++#endif // QPLATFORMDEFS_H
+--
+2.16.1
+
diff --git a/0002-Ensure-GLdouble-is-defined-when-using-dynamic-OpenGL.patch b/0002-Ensure-GLdouble-is-defined-when-using-dynamic-OpenGL.patch
new file mode 100644
index 000000000000..724babddbd3c
--- /dev/null
+++ b/0002-Ensure-GLdouble-is-defined-when-using-dynamic-OpenGL.patch
@@ -0,0 +1,27 @@
+From e2c07e461564d363b8692b5b5de067c892259a36 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 13:36:53 +0200
+Subject: [PATCH 02/32] Ensure GLdouble is defined when using dynamic OpenGL
+
+FIXME: Not sure whether this is still required
+---
+ src/gui/opengl/qopenglfunctions.h | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/src/gui/opengl/qopenglfunctions.h b/src/gui/opengl/qopenglfunctions.h
+index 0a5de2c9af..35798a2a28 100644
+--- a/src/gui/opengl/qopenglfunctions.h
++++ b/src/gui/opengl/qopenglfunctions.h
+@@ -56,9 +56,7 @@
+
+ //#define Q_ENABLE_OPENGL_FUNCTIONS_DEBUG
+
+-#ifdef QT_OPENGL_ES
+ typedef double GLdouble;
+-#endif
+
+ #ifdef Q_ENABLE_OPENGL_FUNCTIONS_DEBUG
+ #include <stdio.h>
+--
+2.16.1
+
diff --git a/0003-Use-external-ANGLE-library.patch b/0003-Use-external-ANGLE-library.patch
new file mode 100644
index 000000000000..54822d27ae3f
--- /dev/null
+++ b/0003-Use-external-ANGLE-library.patch
@@ -0,0 +1,97 @@
+From 84d1b9f6d84e46ee756761d0a9cc264d067b9250 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 13:41:38 +0200
+Subject: [PATCH 03/32] Use external ANGLE library
+
+---
+ src/gui/Qt5GuiConfigExtras.cmake.in | 4 ++--
+ src/gui/gui.pro | 8 ++------
+ src/opengl/opengl.pro | 1 +
+ src/plugins/platforms/windows/windows.pri | 1 +
+ src/src.pro | 4 ----
+ 5 files changed, 6 insertions(+), 12 deletions(-)
+
+diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in
+index 07869efd7d..2e32911a64 100644
+--- a/src/gui/Qt5GuiConfigExtras.cmake.in
++++ b/src/gui/Qt5GuiConfigExtras.cmake.in
+@@ -2,9 +2,9 @@
+ !!IF !isEmpty(CMAKE_ANGLE_EGL_DLL_RELEASE)
+
+ !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
+-set(Qt5Gui_EGL_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR/QtANGLE\")
++set(Qt5Gui_EGL_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR\")
+ !!ELSE
+-set(Qt5Gui_EGL_INCLUDE_DIRS \"$$CMAKE_INCLUDE_DIR/QtANGLE\")
++set(Qt5Gui_EGL_INCLUDE_DIRS \"$$CMAKE_INCLUDE_DIR\")
+ !!ENDIF
+
+ _qt5_Gui_check_file_exists(${Qt5Gui_EGL_INCLUDE_DIRS})
+diff --git a/src/gui/gui.pro b/src/gui/gui.pro
+index f8cec00b82..d09c9fd49c 100644
+--- a/src/gui/gui.pro
++++ b/src/gui/gui.pro
+@@ -18,12 +18,6 @@ MODULE_PLUGIN_TYPES = \
+ imageformats \
+ egldeviceintegrations
+
+-# This is here only because the platform plugin is no module, obviously.
+-qtConfig(angle) {
+- MODULE_AUX_INCLUDES = \
+- \$\$QT_MODULE_INCLUDE_BASE/QtANGLE
+-}
+-
+ # Code coverage with TestCocoon
+ # The following is required as extra compilers use $$QMAKE_CXX instead of $(CXX).
+ # Without this, testcocoon.prf is read only after $$QMAKE_CXX is used by the
+@@ -35,6 +29,8 @@ testcocoon {
+ osx: LIBS_PRIVATE += -framework AppKit
+ darwin: LIBS_PRIVATE += -framework CoreGraphics
+
++win32:qtConfig(angle): LIBS_PRIVATE += -lGLESv2
++
+ CONFIG += simd optimize_full
+
+ include(accessible/accessible.pri)
+diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro
+index 742be61a50..5fef69fd3f 100644
+--- a/src/opengl/opengl.pro
++++ b/src/opengl/opengl.pro
+@@ -11,6 +11,7 @@ QMAKE_DOCS = $$PWD/doc/qtopengl.qdocconf
+
+ qtConfig(opengl): CONFIG += opengl
+ qtConfig(opengles2): CONFIG += opengles2
++win32:qtConfig(angle): LIBS_PRIVATE += -lGLESv2
+
+ HEADERS += qgl.h \
+ qgl_p.h \
+diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri
+index b7790a66e3..046fe34a06 100644
+--- a/src/plugins/platforms/windows/windows.pri
++++ b/src/plugins/platforms/windows/windows.pri
+@@ -4,6 +4,7 @@ LIBS += -lole32 -luser32 -lwinspool -limm32 -lwinmm -loleaut32
+ QT_FOR_CONFIG += gui
+
+ qtConfig(opengl):!qtConfig(opengles2):!qtConfig(dynamicgl): LIBS *= -lopengl32
++qtConfig(angle):LIBS += -lGLESv2 -lEGL
+
+ mingw: LIBS *= -luuid
+ # For the dialog helpers:
+diff --git a/src/src.pro b/src/src.pro
+index a73729a760..32d9f8502a 100644
+--- a/src/src.pro
++++ b/src/src.pro
+@@ -180,10 +180,6 @@ qtConfig(gui) {
+ SUBDIRS += src_3rdparty_harfbuzzng
+ src_gui.depends += src_3rdparty_harfbuzzng
+ }
+- qtConfig(angle) {
+- SUBDIRS += src_angle
+- src_gui.depends += src_angle
+- }
+ qtConfig(png):!qtConfig(system-png) {
+ SUBDIRS += src_3rdparty_libpng
+ src_3rdparty_freetype.depends += src_3rdparty_libpng
+--
+2.16.1
+
diff --git a/0004-Fix-too-many-sections-assemler-error-in-OpenGL-facto.patch b/0004-Fix-too-many-sections-assemler-error-in-OpenGL-facto.patch
new file mode 100644
index 000000000000..5c87faacb8a1
--- /dev/null
+++ b/0004-Fix-too-many-sections-assemler-error-in-OpenGL-facto.patch
@@ -0,0 +1,29 @@
+From b001d0484e9fc4d2f3af20359db96f4d3942d0c7 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 13:48:51 +0200
+Subject: [PATCH 04/32] Fix too many sections assemler error in OpenGL factory
+
+On x86_64 qopenglversionfunctionsfactory.o exceeds the
+limit of 32768 sections.
+Hence the assembler option -mbig-obj is required.
+---
+ src/gui/opengl/opengl.pri | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri
+index 4c778b184e..1dd1755d7f 100644
+--- a/src/gui/opengl/opengl.pri
++++ b/src/gui/opengl/opengl.pri
+@@ -3,7 +3,8 @@
+ qtConfig(opengl): CONFIG += opengl
+ qtConfig(opengles2): CONFIG += opengles2
+
+-qtConfig(opengl) {
++qtConfig(opengl)|qtConfig(opengles2) {
++ mingw:QMAKE_CXXFLAGS+="-Wa,-mbig-obj"
+
+ HEADERS += opengl/qopengl.h \
+ opengl/qopengl_p.h \
+--
+2.16.1
+
diff --git a/0005-Make-sure-.pc-files-are-installed-correctly.patch b/0005-Make-sure-.pc-files-are-installed-correctly.patch
new file mode 100644
index 000000000000..6ca3d4f86416
--- /dev/null
+++ b/0005-Make-sure-.pc-files-are-installed-correctly.patch
@@ -0,0 +1,66 @@
+From 192e4593262474507b9b96424104e130c595e512 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 13:54:12 +0200
+Subject: [PATCH 05/32] Make sure *.pc files are installed correctly
+
+---
+ qmake/generators/makefile.cpp | 8 ++++++--
+ qmake/generators/makefile.h | 2 +-
+ qmake/generators/win32/winmakefile.cpp | 2 +-
+ 3 files changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
+index 82573347b6..b9871ff49c 100644
+--- a/qmake/generators/makefile.cpp
++++ b/qmake/generators/makefile.cpp
+@@ -3146,7 +3146,7 @@ MakefileGenerator::openOutput(QFile &file, const QString &build) const
+ }
+
+ QString
+-MakefileGenerator::pkgConfigFileName(bool fixify)
++MakefileGenerator::pkgConfigFileName(bool fixify, bool onlyPrependDestdir)
+ {
+ QString ret = project->first("QMAKE_PKGCONFIG_FILE").toQString();
+ if (ret.isEmpty()) {
+@@ -3171,7 +3171,11 @@ MakefileGenerator::pkgConfigFileName(bool fixify)
+ if(fixify) {
+ if(QDir::isRelativePath(ret) && !project->isEmpty("DESTDIR"))
+ ret.prepend(project->first("DESTDIR").toQString());
+- ret = fileFixify(ret, FileFixifyBackwards);
++ if (onlyPrependDestdir) {
++ ret = Option::fixPathToLocalOS(ret);
++ } else {
++ ret = fileFixify(ret, FileFixifyBackwards);
++ }
+ }
+ return ret;
+ }
+diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h
+index 4ced3bd121..f7cc3b9e9b 100644
+--- a/qmake/generators/makefile.h
++++ b/qmake/generators/makefile.h
+@@ -89,7 +89,7 @@ protected:
+ virtual void writeDefaultVariables(QTextStream &t);
+
+ QString pkgConfigPrefix() const;
+- QString pkgConfigFileName(bool fixify=true);
++ QString pkgConfigFileName(bool fixify=true, bool onlyPrependDestdir = false);
+ QString pkgConfigFixPath(QString) const;
+ void writePkgConfigFile(); // for pkg-config
+
+diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
+index 75bb5d236d..737f3abc3a 100644
+--- a/qmake/generators/win32/winmakefile.cpp
++++ b/qmake/generators/win32/winmakefile.cpp
+@@ -726,7 +726,7 @@ QString Win32MakefileGenerator::defaultInstall(const QString &t)
+ }
+ if(!ret.isEmpty())
+ ret += "\n\t";
+- ret += installMetaFile(ProKey("QMAKE_PKGCONFIG_INSTALL_REPLACE"), pkgConfigFileName(true), dst_pc);
++ ret += installMetaFile(ProKey("QMAKE_PKGCONFIG_INSTALL_REPLACE"), pkgConfigFileName(true, true), dst_pc);
+ if(!uninst.isEmpty())
+ uninst.append("\n\t");
+ uninst.append("-$(DEL_FILE) " + escapeFilePath(dst_pc));
+--
+2.16.1
+
diff --git a/0006-Don-t-add-resource-files-to-LIBS-parameter.patch b/0006-Don-t-add-resource-files-to-LIBS-parameter.patch
new file mode 100644
index 000000000000..6c7a6dec6276
--- /dev/null
+++ b/0006-Don-t-add-resource-files-to-LIBS-parameter.patch
@@ -0,0 +1,28 @@
+From 19a847d6ea1601de83ad067ba6c0fcf562273e72 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 13:58:28 +0200
+Subject: [PATCH 06/32] Don't add resource files to LIBS parameter
+
+Solves an issue where the generated pkg-config
+files contained invalid Libs.private references
+like .obj/debug/Qt5Cored_resource_res.o
+---
+ qmake/generators/win32/mingw_make.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp
+index d6d6b04148..7bb616302f 100644
+--- a/qmake/generators/win32/mingw_make.cpp
++++ b/qmake/generators/win32/mingw_make.cpp
+@@ -196,7 +196,7 @@ void MingwMakefileGenerator::init()
+
+ processVars();
+
+- project->values("QMAKE_LIBS") += project->values("RES_FILE");
++ project->values("OBJECTS") += project->values("RES_FILE");
+
+ if (project->isActiveConfig("dll")) {
+ QString destDir = "";
+--
+2.16.1
+
diff --git a/0007-Prevent-debug-library-names-in-pkg-config-files.patch b/0007-Prevent-debug-library-names-in-pkg-config-files.patch
new file mode 100644
index 000000000000..98d4bbde04d9
--- /dev/null
+++ b/0007-Prevent-debug-library-names-in-pkg-config-files.patch
@@ -0,0 +1,33 @@
+From bcb4c82d669d352c183c45e1cb71bd7c0946d1ec Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 14:01:14 +0200
+Subject: [PATCH 07/32] Prevent debug library names in pkg-config files
+
+qmake generates the pkgconfig .pc files two times, once for the
+release build and once for the debug build (which we're not actually
+building in this package). For both generations the exact same
+pkgconfig file name is used. This causes references to the debug
+build ending up in the .pc files which are unwanted
+Prevent this from happening by giving the pkgconfig .pc
+files for the debug build an unique file name.
+---
+ qmake/generators/makefile.cpp | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
+index b9871ff49c..0d07d6c333 100644
+--- a/qmake/generators/makefile.cpp
++++ b/qmake/generators/makefile.cpp
+@@ -3160,6 +3160,9 @@ MakefileGenerator::pkgConfigFileName(bool fixify, bool onlyPrependDestdir)
+ if (dot != -1)
+ ret = ret.left(dot);
+ }
++ if (project->isActiveConfig("debug")) {
++ ret += "d";
++ }
+ ret += Option::pkgcfg_ext;
+ QString subdir = project->first("QMAKE_PKGCONFIG_DESTDIR").toQString();
+ if(!subdir.isEmpty()) {
+--
+2.16.1
+
diff --git a/0008-Fix-linking-against-shared-static-libpng.patch b/0008-Fix-linking-against-shared-static-libpng.patch
new file mode 100644
index 000000000000..13b1f738ba68
--- /dev/null
+++ b/0008-Fix-linking-against-shared-static-libpng.patch
@@ -0,0 +1,27 @@
+From 9914d843bf7833fb04303cb96cff6912cfc7a7f3 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Thu, 26 Jan 2017 17:51:31 +0100
+Subject: [PATCH 08/32] Fix linking against shared/static libpng
+
+Change-Id: Ic7a0ec9544059b8e647a5d0186f1b88c00911dcf
+---
+ src/gui/configure.json | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/gui/configure.json b/src/gui/configure.json
+index dab66fafb4..bc501bd3fc 100644
+--- a/src/gui/configure.json
++++ b/src/gui/configure.json
+@@ -291,7 +291,8 @@
+ "sources": [
+ { "type": "pkgConfig", "args": "libpng" },
+ { "libs": "-llibpng", "condition": "config.msvc" },
+- { "libs": "-lpng", "condition": "!config.msvc" }
++ { "libs": "-lpng -lz", "condition": "!config.msvc && !features.shared" },
++ { "libs": "-lpng", "condition": "!config.msvc && features.shared" }
+ ],
+ "use": [
+ { "lib": "zlib", "condition": "features.system-zlib" }
+--
+2.16.1
+
diff --git a/0009-Fix-linking-against-static-D-Bus.patch b/0009-Fix-linking-against-static-D-Bus.patch
new file mode 100644
index 000000000000..bf620e71d31f
--- /dev/null
+++ b/0009-Fix-linking-against-static-D-Bus.patch
@@ -0,0 +1,58 @@
+From 3b501d8fc4dab1c437f18d2d21c64265858e367d Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Fri, 3 Feb 2017 19:36:25 +0100
+Subject: [PATCH 09/32] Fix linking against static D-Bus
+
+---
+ configure.json | 9 +++++++--
+ src/dbus/qdbus_symbols_p.h | 4 ++++
+ 2 files changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/configure.json b/configure.json
+index a6f3ed66a9..803abf38bb 100644
+--- a/configure.json
++++ b/configure.json
+@@ -171,18 +171,23 @@
+ "CONFIG(debug, debug|release): \\",
+ " LIBS += $$LIBS_DEBUG",
+ "else: \\",
+- " LIBS += $$LIBS_RELEASE"
++ " LIBS += $$LIBS_RELEASE",
++ "static: DEFINES += DBUS_STATIC_BUILD"
+ ]
+ },
+ "sources": [
+ { "type": "pkgConfig", "args": "dbus-1 >= 1.2" },
++ {
++ "libs": "-ldbus-1 -lws2_32 -liphlpapi",
++ "condition": "config.win32 && !features.shared"
++ },
+ {
+ "libs": "",
+ "builds": {
+ "debug": "-ldbus-1d",
+ "release": "-ldbus-1"
+ },
+- "condition": "config.win32"
++ "condition": "config.win32 && features.shared"
+ },
+ { "libs": "-ldbus-1", "condition": "!config.win32" }
+ ]
+diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h
+index 9eaebe6d7e..ac1b1d977b 100644
+--- a/src/dbus/qdbus_symbols_p.h
++++ b/src/dbus/qdbus_symbols_p.h
+@@ -57,6 +57,10 @@
+
+ #ifndef QT_NO_DBUS
+
++#ifdef QT_STATIC
++# define DBUS_STATIC_BUILD
++#endif
++
+ #ifdef QT_LINKED_LIBDBUS
+ # include <dbus/dbus.h>
+ #else
+--
+2.16.1
+
diff --git a/0010-Don-t-try-to-use-debug-version-of-D-Bus-library.patch b/0010-Don-t-try-to-use-debug-version-of-D-Bus-library.patch
new file mode 100644
index 000000000000..93c1d12d2835
--- /dev/null
+++ b/0010-Don-t-try-to-use-debug-version-of-D-Bus-library.patch
@@ -0,0 +1,29 @@
+From 5faa23e98e0fb63f3c2fedf3fe5fb93b2df940df Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Fri, 2 Jun 2017 18:28:10 +0200
+Subject: [PATCH 10/32] Don't try to use debug version of D-Bus library
+
+Required for a debug build of Qt because mingw-w64-dbus
+does not contain debug version
+
+Change-Id: Ic34e1025fda55f9659e065f5bbe9d51f55420adb
+---
+ configure.json | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.json b/configure.json
+index 803abf38bb..7e0b7ffb56 100644
+--- a/configure.json
++++ b/configure.json
+@@ -184,7 +184,7 @@
+ {
+ "libs": "",
+ "builds": {
+- "debug": "-ldbus-1d",
++ "debug": "-ldbus-1",
+ "release": "-ldbus-1"
+ },
+ "condition": "config.win32 && features.shared"
+--
+2.16.1
+
diff --git a/0011-Fix-linking-against-static-freetype2.patch b/0011-Fix-linking-against-static-freetype2.patch
new file mode 100644
index 000000000000..36bf76065090
--- /dev/null
+++ b/0011-Fix-linking-against-static-freetype2.patch
@@ -0,0 +1,30 @@
+From 3deafc5a5c28faaafb1f1ec52d32c9fc5df2986d Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Fri, 3 Feb 2017 20:51:19 +0100
+Subject: [PATCH 11/32] Fix linking against static freetype2
+
+---
+ src/gui/configure.json | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/src/gui/configure.json b/src/gui/configure.json
+index bc501bd3fc..f7a4a39fd4 100644
+--- a/src/gui/configure.json
++++ b/src/gui/configure.json
+@@ -158,8 +158,11 @@
+ ]
+ },
+ "sources": [
+- { "type": "pkgConfig", "args": "freetype2" },
+- { "type": "freetype", "libs": "-lfreetype" }
++ { "type": "pkgConfig", "args": "--static --libs freetype2", "condition": "!features.shared" },
++ { "type": "pkgConfig", "args": "--libs freetype2", "condition": "features.shared" },
++ { "libs": "-lfreetype -lharfbuzz -lfreetype -lglib-2.0 -lintl -lws2_32 -lole32 -lwinmm -lshlwapi -lpcre -lintl -lpcre -lintl -liconv -lgraphite2 -lbz2", "condition": "!features.shared" },
++ { "libs": "-Wl,-Bdynamic -lfreetype -Wl,-Bstatic", "condition": "!features.shared" },
++ { "libs": "-lfreetype", "condition": "features.shared" }
+ ]
+ },
+ "fontconfig": {
+--
+2.16.1
+
diff --git a/0012-Fix-linking-against-static-harfbuzz.patch b/0012-Fix-linking-against-static-harfbuzz.patch
new file mode 100644
index 000000000000..796b98390b65
--- /dev/null
+++ b/0012-Fix-linking-against-static-harfbuzz.patch
@@ -0,0 +1,29 @@
+From 61f5c3fcc4d5ad5fb1bad5bc711c2d4e803e655a Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 14:22:56 +0200
+Subject: [PATCH 12/32] Fix linking against static harfbuzz
+
+---
+ src/gui/configure.json | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/src/gui/configure.json b/src/gui/configure.json
+index f7a4a39fd4..5ff8449509 100644
+--- a/src/gui/configure.json
++++ b/src/gui/configure.json
+@@ -218,7 +218,11 @@
+ ]
+ },
+ "sources": [
+- "-lharfbuzz"
++ { "type": "pkgConfig", "args": "--static --libs harfbuzz", "condition": "!features.shared" },
++ { "type": "pkgConfig", "args": "--libs harfbuzz", "condition": "features.shared" },
++ { "libs": "-lharfbuzz -lfreetype -lharfbuzz -lglib-2.0 -lintl -lws2_32 -lole32 -lwinmm -lshlwapi -lpcre -lintl -lpcre -lintl -liconv -lgraphite2 -lbz2", "condition": "!features.shared" },
++ { "libs": "-Wl,-Bdynamic -lharfbuzz -Wl,-Bstatic", "condition": "!features.shared" },
++ { "libs": "-lharfbuzz", "condition": "features.shared" }
+ ]
+ },
+ "imf": {
+--
+2.16.1
+
diff --git a/0013-Fix-linking-against-static-pcre.patch b/0013-Fix-linking-against-static-pcre.patch
new file mode 100644
index 000000000000..cee71e740246
--- /dev/null
+++ b/0013-Fix-linking-against-static-pcre.patch
@@ -0,0 +1,28 @@
+From c74216cc1ed27e282939c159bc63714f3cd69482 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 14:24:01 +0200
+Subject: [PATCH 13/32] Fix linking against static pcre
+
+Change-Id: I3225c6e82dc4d17aef37d4289c16eb7a5ea3c5a1
+---
+ src/corelib/tools/qregularexpression.cpp | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
+index 86bc99716d..5037ae68a1 100644
+--- a/src/corelib/tools/qregularexpression.cpp
++++ b/src/corelib/tools/qregularexpression.cpp
+@@ -55,6 +55,10 @@
+ #include <QtCore/qdatastream.h>
+
+ #define PCRE2_CODE_UNIT_WIDTH 16
++#ifdef QT_STATIC
++#define PCRE_STATIC
++#define PCRE2_STATIC
++#endif
+
+ #include <pcre2.h>
+
+--
+2.16.1
+
diff --git a/0014-Fix-linking-against-shared-static-MariaDB.patch b/0014-Fix-linking-against-shared-static-MariaDB.patch
new file mode 100644
index 000000000000..1d5d8bdb7837
--- /dev/null
+++ b/0014-Fix-linking-against-shared-static-MariaDB.patch
@@ -0,0 +1,27 @@
+From d8dca16ee267d09792a232e415cd92ef3ec4b294 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 18:56:55 +0200
+Subject: [PATCH 14/32] Fix linking against shared/static MariaDB
+
+Change-Id: I9722c154d845f288a2d4d1ab14a014066b28819b
+---
+ src/plugins/sqldrivers/configure.json | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/plugins/sqldrivers/configure.json b/src/plugins/sqldrivers/configure.json
+index 234f880579..4619db4a54 100644
+--- a/src/plugins/sqldrivers/configure.json
++++ b/src/plugins/sqldrivers/configure.json
+@@ -69,6 +69,9 @@
+ "main": "mysql_get_client_version();"
+ },
+ "sources": [
++ { "libs": "-lmariadbclient -lssl -lcrypto -lgdi32 -lws2_32 -lpthread -lz -lm", "condition": "config.win32 && !features.shared" },
++ { "libs": "-Wl,-Bdynamic -lmariadb -Wl,-Bstatic", "condition": "config.win32 && !features.shared" },
++ { "libs": "-lmariadb", "condition": "config.win32 && features.shared" },
+ { "type": "mysqlConfig", "query": "--libs_r", "cleanlibs": true },
+ { "type": "mysqlConfig", "query": "--libs", "cleanlibs": true },
+ { "type": "mysqlConfig", "query": "--libs_r", "cleanlibs": false },
+--
+2.16.1
+
diff --git a/0015-Fix-linking-against-shared-static-PostgreSQL.patch b/0015-Fix-linking-against-shared-static-PostgreSQL.patch
new file mode 100644
index 000000000000..c66730e9dbf2
--- /dev/null
+++ b/0015-Fix-linking-against-shared-static-PostgreSQL.patch
@@ -0,0 +1,29 @@
+From 4900e0717b3f5562150d1ccbd5aaf64c0b4e5359 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 18:58:25 +0200
+Subject: [PATCH 15/32] Fix linking against shared/static PostgreSQL
+
+---
+ src/plugins/sqldrivers/configure.json | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/src/plugins/sqldrivers/configure.json b/src/plugins/sqldrivers/configure.json
+index 4619db4a54..ef0d45f6cc 100644
+--- a/src/plugins/sqldrivers/configure.json
++++ b/src/plugins/sqldrivers/configure.json
+@@ -91,9 +91,10 @@
+ ]
+ },
+ "sources": [
+- { "type": "pkgConfig", "args": "libpq" },
+ { "type": "psqlConfig" },
+- { "type": "psqlEnv", "libs": "-llibpq -lws2_32 -ladvapi32", "condition": "config.win32" },
++ { "type": "psqlEnv", "libs": "-lpq -lintl -lssl -lcrypto -lshell32 -lws2_32 -lsecur32", "condition": "config.win32 && !features.shared" },
++ { "type": "psqlEnv", "libs": "-Wl,-Bdynamic -lpq -Wl,-Bstatic", "condition": "config.win32 && !features.shared" },
++ { "type": "psqlEnv", "libs": "-lpq", "condition": "config.win32 && features.shared" },
+ { "type": "psqlEnv", "libs": "-lpq", "condition": "!config.win32" }
+ ]
+ },
+--
+2.16.1
+
diff --git a/0016-Rename-qtmain-to-qt5main.patch b/0016-Rename-qtmain-to-qt5main.patch
new file mode 100644
index 000000000000..93a9c548fef7
--- /dev/null
+++ b/0016-Rename-qtmain-to-qt5main.patch
@@ -0,0 +1,56 @@
+From 810f18a177482cbe7bef0a8674b4f47de6730821 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 14:25:40 +0200
+Subject: [PATCH 16/32] Rename qtmain to qt5main
+
+Prevents conflict with mingw-w64-qt4 package
+---
+ mkspecs/features/create_cmake.prf | 4 ++--
+ mkspecs/features/win32/windows.prf | 2 +-
+ src/winmain/winmain.pro | 2 +-
+ 3 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
+index bb5083c925..146e83ae67 100644
+--- a/mkspecs/features/create_cmake.prf
++++ b/mkspecs/features/create_cmake.prf
+@@ -225,8 +225,8 @@ mac {
+ CMAKE_LIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.dll
+
+ mingw {
+- CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqtmain$${QT_LIBINFIX}d.a
+- CMAKE_WINMAIN_FILE_LOCATION_RELEASE = libqtmain$${QT_LIBINFIX}.a
++ CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqt5main$${QT_LIBINFIX}.a
++ CMAKE_WINMAIN_FILE_LOCATION_RELEASE = libqt5main$${QT_LIBINFIX}.a
+
+ !isEmpty(CMAKE_STATIC_TYPE) {
+ CMAKE_STATIC_WINDOWS_BUILD = "true"
+diff --git a/mkspecs/features/win32/windows.prf b/mkspecs/features/win32/windows.prf
+index ecb167bf18..7c9368c3b3 100644
+--- a/mkspecs/features/win32/windows.prf
++++ b/mkspecs/features/win32/windows.prf
+@@ -5,7 +5,7 @@ contains(TEMPLATE, ".*app") {
+ mingw:DEFINES += QT_NEEDS_QMAIN
+
+ qt:for(entryLib, $$list($$unique(QMAKE_LIBS_QT_ENTRY))) {
+- isEqual(entryLib, -lqtmain) {
++ isEqual(entryLib, -lqt5main): {
+ !contains(QMAKE_DEFAULT_LIBDIRS, $$QT.core.libs): \
+ QMAKE_LIBS += -L$$QT.core.libs
+ CONFIG(debug, debug|release): QMAKE_LIBS += $${entryLib}$${QT_LIBINFIX}d
+diff --git a/src/winmain/winmain.pro b/src/winmain/winmain.pro
+index 4140ae48de..9ae73db74b 100644
+--- a/src/winmain/winmain.pro
++++ b/src/winmain/winmain.pro
+@@ -2,7 +2,7 @@
+ !win32:error("$$_FILE_ is intended only for Windows!")
+
+ TEMPLATE = lib
+-TARGET = qtmain
++TARGET = qt5main
+ DESTDIR = $$QT.core.libs
+
+ CONFIG += static
+--
+2.16.1
+
diff --git a/0017-Build-dynamic-host-libraries.patch b/0017-Build-dynamic-host-libraries.patch
new file mode 100644
index 000000000000..3535c0553c87
--- /dev/null
+++ b/0017-Build-dynamic-host-libraries.patch
@@ -0,0 +1,41 @@
+From b1563b11dbbc5a2ed80ef4aa7a3ee9d21fba7070 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 14:27:28 +0200
+Subject: [PATCH 17/32] Build dynamic host libraries
+
+This came initially from Fedora, not sure whether
+it makes sense to keep it. Regular Arch package
+uses static lib as intended by upstream.
+
+Change-Id: I91a3613955c656fb0d262ccb9b2529350bab032b
+---
+ mkspecs/features/qt_module.prf | 2 +-
+ src/tools/bootstrap-dbus/bootstrap-dbus.pro | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf
+index e6a0d97f1a..c07c1adc8b 100644
+--- a/mkspecs/features/qt_module.prf
++++ b/mkspecs/features/qt_module.prf
+@@ -24,7 +24,7 @@ requires(!$$skip)
+
+ # Compile as shared/DLL or static according to the option given to configure
+ # unless overridden. Host builds are always static
+-host_build|staticlib: CONFIG += static
++staticlib: CONFIG += static
+
+ host_build {
+ QT -= gui # no host module will ever use gui
+diff --git a/src/tools/bootstrap-dbus/bootstrap-dbus.pro b/src/tools/bootstrap-dbus/bootstrap-dbus.pro
+index c3ed27d979..30d2114aa1 100644
+--- a/src/tools/bootstrap-dbus/bootstrap-dbus.pro
++++ b/src/tools/bootstrap-dbus/bootstrap-dbus.pro
+@@ -27,4 +27,4 @@ SOURCES = \
+ load(qt_module)
+
+ lib.CONFIG = dummy_install
+-INSTALLS = lib
++INSTALLS += lib
+--
+2.16.1
+
diff --git a/0018-Enable-rpath-for-build-tools.patch b/0018-Enable-rpath-for-build-tools.patch
new file mode 100644
index 000000000000..499eab9484ae
--- /dev/null
+++ b/0018-Enable-rpath-for-build-tools.patch
@@ -0,0 +1,37 @@
+From 056173285f8854856cb9d710cc7af0cfb67ed294 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 17:59:27 +0200
+Subject: [PATCH 18/32] Enable rpath for build tools
+
+- Required because various tools depend on libQt5Bootstrap.so which resides
+ in folder /usr/${_arch}/lib
+- Can't use regular lib dir because it would conflict with the native package
+
+Change-Id: I9808062a66406cdec7446a75150b40b2f30038c7
+---
+ mkspecs/features/qt_app.prf | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mkspecs/features/qt_app.prf b/mkspecs/features/qt_app.prf
+index 883f8ca215..786f2e660c 100644
+--- a/mkspecs/features/qt_app.prf
++++ b/mkspecs/features/qt_app.prf
+@@ -24,6 +24,7 @@ isEmpty(QMAKE_INFO_PLIST): CONFIG -= app_bundle
+ QMAKE_LFLAGS += $$QMAKE_LFLAGS_GCSECTIONS
+
+ host_build: QT -= gui # no host tool will ever use gui
++host_build: QMAKE_RPATHDIR += $$[QT_INSTALL_LIBS/dev] # force rpath
+ host_build:force_bootstrap {
+ !build_pass:qtConfig(release_tools): CONFIG += release
+ contains(QT, core(-private)?|xml) {
+@@ -34,7 +35,6 @@ host_build:force_bootstrap {
+ } else {
+ !build_pass:qtConfig(debug_and_release): CONFIG += release
+ target.path = $$[QT_INSTALL_BINS]
+- CONFIG += relative_qt_rpath # Qt's tools and apps should be relocatable
+ }
+ INSTALLS += target
+
+--
+2.16.1
+
diff --git a/0019-Use-system-zlib-for-build-tools.patch b/0019-Use-system-zlib-for-build-tools.patch
new file mode 100644
index 000000000000..5bb33f855ce4
--- /dev/null
+++ b/0019-Use-system-zlib-for-build-tools.patch
@@ -0,0 +1,25 @@
+From d268e7908b8cd1509023bdbfd61c9140b5bf1f62 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 18:04:42 +0200
+Subject: [PATCH 19/32] Use system zlib for build tools
+
+---
+ src/tools/bootstrap/bootstrap.pro | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
+index 042ad7adb9..7e3bc3977a 100644
+--- a/src/tools/bootstrap/bootstrap.pro
++++ b/src/tools/bootstrap/bootstrap.pro
+@@ -132,7 +132,7 @@ macx {
+ ../../corelib/io/qstandardpaths_win.cpp
+ }
+
+-!qtConfig(system-zlib)|cross_compile {
++!qtConfig(system-zlib) {
+ include(../../3rdparty/zlib.pri)
+ } else {
+ CONFIG += no_core_dep
+--
+2.16.1
+
diff --git a/0020-Use-.dll.a-as-import-lib-extension.patch b/0020-Use-.dll.a-as-import-lib-extension.patch
new file mode 100644
index 000000000000..39d3af6e9432
--- /dev/null
+++ b/0020-Use-.dll.a-as-import-lib-extension.patch
@@ -0,0 +1,68 @@
+From e01cb55796ac795043b4e3afd6811c8d0bfaf6c1 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 18:26:18 +0200
+Subject: [PATCH 20/32] Use *.dll.a as import lib extension
+
+The variables used here are provided by
+mingw-w64 specific mkspec
+---
+ mkspecs/features/create_cmake.prf | 5 +++--
+ qmake/generators/win32/winmakefile.cpp | 17 ++++++++++++-----
+ 2 files changed, 15 insertions(+), 7 deletions(-)
+
+diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
+index 146e83ae67..15fc070008 100644
+--- a/mkspecs/features/create_cmake.prf
++++ b/mkspecs/features/create_cmake.prf
+@@ -236,8 +236,9 @@ mac {
+ CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.prl
+ CMAKE_PRL_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.prl
+ } else {
+- CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.a
+- CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
++ isEmpty(QMAKE_EXTENSION_IMPORTLIB): QMAKE_EXTENSION_IMPORTLIB = a
++ CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.$${QMAKE_EXTENSION_IMPORTLIB}
++ CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.$${QMAKE_EXTENSION_IMPORTLIB}
+ }
+ } else {
+ CMAKE_WINMAIN_FILE_LOCATION_DEBUG = qtmain$${QT_LIBINFIX}d.lib
+diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
+index 737f3abc3a..2e6d5d94a9 100644
+--- a/qmake/generators/win32/winmakefile.cpp
++++ b/qmake/generators/win32/winmakefile.cpp
+@@ -80,10 +80,14 @@ Win32MakefileGenerator::parseLibFlag(const ProString &flag, ProString *arg)
+ bool
+ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
+ {
+- ProStringList impexts = project->values("QMAKE_LIB_EXTENSIONS");
+- if (impexts.isEmpty())
+- impexts = project->values("QMAKE_EXTENSION_STATICLIB");
+- QList<QMakeLocalFileName> dirs;
++ ProStringList impexts;
++ if (project->isActiveConfig("staticlib")) {
++ impexts.append(project->values("QMAKE_EXTENSION_STATICLIB"));
++ } else {
++ impexts.append(project->values("QMAKE_EXTENSION_IMPORTLIB"));
++ impexts.append(project->values("QMAKE_EXTENSION_STATICLIB"));
++ }
++ QList<QMakeLocalFileName> dirs;
+ static const char * const lflags[] = { "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", 0 };
+ for (int i = 0; lflags[i]; i++) {
+ ProStringList &l = project->values(lflags[i]);
+@@ -234,9 +238,12 @@ void Win32MakefileGenerator::fixTargetExt()
+ if (!project->values("QMAKE_APP_FLAG").isEmpty()) {
+ project->values("TARGET_EXT").append(".exe");
+ } else if (project->isActiveConfig("shared")) {
++ ProString impext = project->first("QMAKE_EXTENSION_IMPORTLIB");
++ if (impext.isEmpty())
++ impext = project->first("QMAKE_PREFIX_STATICLIB");
+ project->values("LIB_TARGET").prepend(project->first("QMAKE_PREFIX_STATICLIB")
+ + project->first("TARGET") + project->first("TARGET_VERSION_EXT")
+- + '.' + project->first("QMAKE_EXTENSION_STATICLIB"));
++ + '.' + impext);
+ project->values("TARGET_EXT").append(project->first("TARGET_VERSION_EXT") + "."
+ + project->first("QMAKE_EXTENSION_SHLIB"));
+ project->values("TARGET").first() = project->first("QMAKE_PREFIX_SHLIB") + project->first("TARGET");
+--
+2.16.1
+
diff --git a/0021-Merge-shared-and-static-library-trees.patch b/0021-Merge-shared-and-static-library-trees.patch
new file mode 100644
index 000000000000..c75ede7a9cf2
--- /dev/null
+++ b/0021-Merge-shared-and-static-library-trees.patch
@@ -0,0 +1,132 @@
+From 297f163b0298a45307f397842bca505c860a7fc3 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 18:45:08 +0200
+Subject: [PATCH 21/32] Merge shared and static library trees
+
+Allow installation of shared and static build in the same prefix
+---
+ configure.pri | 9 +++++++++
+ mkspecs/features/default_post.prf | 11 +++++++++++
+ mkspecs/features/qt.prf | 17 +++++++++++++++++
+ mkspecs/features/spec_pre.prf | 11 ++++++++---
+ qmake/generators/makefile.cpp | 9 ++++++---
+ 5 files changed, 51 insertions(+), 6 deletions(-)
+
+diff --git a/configure.pri b/configure.pri
+index ea482552c4..9da756fb3a 100644
+--- a/configure.pri
++++ b/configure.pri
+@@ -1225,3 +1225,12 @@ defineTest(createConfigStatus) {
+
+ QMAKE_POST_CONFIGURE += \
+ "createConfigStatus()"
++
++# merge shared and static library trees
++contains(CONFIG, static) {
++ CONFIG -= shared
++ QT_CONFIG += static jpeg gif
++ QT_CONFIG -= shared
++ # prevent smart library merge from messing cyclic dependency between freetype2 and harfbuzz
++ CONFIG += no_smart_library_merge
++}
+diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf
+index 7e027325bd..ad0db62b78 100644
+--- a/mkspecs/features/default_post.prf
++++ b/mkspecs/features/default_post.prf
+@@ -1,5 +1,16 @@
+ # This file is loaded by qmake right after loading the actual project file.
+
++win32:contains(CONFIG, static) {
++ # Ensure defines are set correctly for static build
++ DEFINES -= QT_SHARED
++ DEFINES *= QT_STATIC QT_DESIGNER_STATIC
++ contains(QT_CONFIG, angle): DEFINES *= QT_OPENGL_ES_2_ANGLE_STATIC
++ # Ensure we link against all dependencies statically
++ QMAKE_LFLAGS += -static -static-libstdc++ -static-libgcc
++ # Prevent qmake from finding the prl file for shared libs
++ QMAKE_EXT_PRL = .static.prl
++}
++
+ contains(TEMPLATE, ".*(lib|app)"):CONFIG += have_target
+
+ !have_target:!force_qt: CONFIG -= qt
+diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf
+index b57afcf72d..6eebd068f1 100644
+--- a/mkspecs/features/qt.prf
++++ b/mkspecs/features/qt.prf
+@@ -259,6 +259,23 @@ for(ever) {
+ !isEmpty(MODULE_WINRT_CAPABILITIES_DEVICE): \
+ WINRT_MANIFEST.capabilities_device_default += $$MODULE_WINRT_CAPABILITIES_DEVICE
+ }
++
++ # Ensure linking against all required static libraries as defined in mingw-w64-g++ mkspec
++ win32:contains(CONFIG, static) {
++ isEqual(MODULE_NAME, QtCore) {
++ LIBS$$var_sfx += $$QMAKE_LIBS_CORE
++ } else:isEqual(MODULE_NAME, QtGui) {
++ LIBS$$var_sfx += $$QMAKE_LIBS_GUI_STATIC
++ } else:isEqual(MODULE_NAME, QtNetwork) {
++ LIBS$$var_sfx += $$QMAKE_LIBS_NETWORK_STATIC
++ } else:isEqual(MODULE_NAME, QtDBus) {
++ LIBS$$var_sfx += $$QMAKE_LIBS_DBUS_STATIC
++ } else:isEqual(MODULE_NAME, QtWidgets) {
++ LIBS$$var_sfx += $$QMAKE_LIBS_WIDGETS_STATIC
++ } else:isEqual(MODULE_NAME, QtOpenGL) {
++ LIBS$$var_sfx += $$QMAKE_LIBS_OPENGL
++ }
++ }
+ }
+ !isEmpty(BAD_QT):error("Unknown module(s) in QT$$var_sfx: $$replace(BAD_QT, _private$, -private)")
+
+diff --git a/mkspecs/features/spec_pre.prf b/mkspecs/features/spec_pre.prf
+index 51ea3a8321..275e080ae4 100644
+--- a/mkspecs/features/spec_pre.prf
++++ b/mkspecs/features/spec_pre.prf
+@@ -14,9 +14,14 @@ QMAKE_EXT_H = .h .hpp .hh .hxx
+ QMAKE_EXT_H_MOC = .cpp
+ QMAKE_EXT_JS = .js
+ QMAKE_EXT_LEX = .l
+-QMAKE_EXT_LIBTOOL = .la
+-QMAKE_EXT_PKGCONFIG = .pc
+-QMAKE_EXT_PRL = .prl
++QMAKE_EXT_PKGCONFIG = .pc
++contains(CONFIG, static) {
++ QMAKE_EXT_LIBTOOL = .static.la
++ QMAKE_EXT_PRL = .static.prl
++} else {
++ QMAKE_EXT_LIBTOOL = .la
++ QMAKE_EXT_PRL = .prl
++}
+ QMAKE_EXT_UI = .ui
+ QMAKE_EXT_YACC = .y
+
+diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
+index 0d07d6c333..5e84628e72 100644
+--- a/qmake/generators/makefile.cpp
++++ b/qmake/generators/makefile.cpp
+@@ -3163,6 +3163,9 @@ MakefileGenerator::pkgConfigFileName(bool fixify, bool onlyPrependDestdir)
+ if (project->isActiveConfig("debug")) {
+ ret += "d";
+ }
++ if (project->isActiveConfig("staticlib")) {
++ ret.insert(0, QStringLiteral("Static"));
++ }
+ ret += Option::pkgcfg_ext;
+ QString subdir = project->first("QMAKE_PKGCONFIG_DESTDIR").toQString();
+ if(!subdir.isEmpty()) {
+@@ -3336,9 +3339,9 @@ MakefileGenerator::writePkgConfigFile()
+ t << endl;
+
+ // requires
+- const QString requires = project->values("QMAKE_PKGCONFIG_REQUIRES").join(' ');
+- if (!requires.isEmpty()) {
+- t << "Requires: " << requires << endl;
++ t << "Requires:";
++ for (const auto &required : project->values("QMAKE_PKGCONFIG_REQUIRES")) {
++ t << (project->isActiveConfig("staticlib") ? QStringLiteral(" Static") : QStringLiteral(" ")) << required.toQString();
+ }
+
+ t << endl;
+--
+2.16.1
+
diff --git a/0022-Pull-dependencies-of-static-libraries-in-CMake-modul.patch b/0022-Pull-dependencies-of-static-libraries-in-CMake-modul.patch
new file mode 100644
index 000000000000..d01739b9b4a5
--- /dev/null
+++ b/0022-Pull-dependencies-of-static-libraries-in-CMake-modul.patch
@@ -0,0 +1,282 @@
+From 22098826acc64ddaa2dbbeabe2d509fd8a54a6d1 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 18:32:00 +0200
+Subject: [PATCH 22/32] Pull dependencies of static libraries in CMake modules
+
+When doing a static build of Qt, the dependencies of the Qt
+libraries and plugins itself must be specified when linking
+the final application.
+---
+ .../features/data/cmake/Qt5BasicConfig.cmake.in | 148 ++++++++++++++++-----
+ .../features/data/cmake/Qt5PluginTarget.cmake.in | 11 +-
+ qmake/generators/makefile.cpp | 16 ++-
+ 3 files changed, 133 insertions(+), 42 deletions(-)
+
+diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+index 55c74aad66..b401db5ac2 100644
+--- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
++++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+@@ -55,35 +55,52 @@ but not all the files it references.
+ endmacro()
+
+ !!IF !equals(TEMPLATE, aux)
+-macro(_populate_$${CMAKE_MODULE_NAME}_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION)
+- set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
++macro(_populate_$${CMAKE_MODULE_NAME}_target_properties TARGET_CONFIG LIB_LOCATION IMPLIB_LOCATION)
++ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${TARGET_CONFIG})
+
+ !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+ set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+ !!ELSE
+ set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+ !!ENDIF
++
+ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
++
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ if (_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES)
++ set(_list_sep \";\")
++ endif()
++ set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
++ \"INTERFACE_LINK_LIBRARIES_${TARGET_CONFIG}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}${_list_sep}${_Qt5$${CMAKE_MODULE_NAME}_STATIC_${TARGET_CONFIG}_LIB_DEPENDENCIES}\"
++ \"IMPORTED_LOCATION_${TARGET_CONFIG}\" ${imported_location}
++!!IF !isEmpty(CMAKE_LIB_SONAME)
++ \"IMPORTED_SONAME_${TARGET_CONFIG}\" \"$${CMAKE_LIB_SONAME}\"
++!!ENDIF
++ # For backward compatibility with CMake < 2.8.12
++ \"IMPORTED_LINK_INTERFACE_LIBRARIES_${TARGET_CONFIG}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}${_list_sep}${_Qt5$${CMAKE_MODULE_NAME}_STATIC_${TARGET_CONFIG}_LIB_DEPENDENCIES}\"
++ )
++!!ELSE
+ set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
+- \"INTERFACE_LINK_LIBRARIES\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
+- \"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
++ \"INTERFACE_LINK_LIBRARIES_${TARGET_CONFIG}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
++ \"IMPORTED_LOCATION_${TARGET_CONFIG}\" ${imported_location}
+ !!IF !isEmpty(CMAKE_LIB_SONAME)
+- \"IMPORTED_SONAME_${Configuration}\" \"$${CMAKE_LIB_SONAME}\"
++ \"IMPORTED_SONAME_${TARGET_CONFIG}\" \"$${CMAKE_LIB_SONAME}\"
+ !!ENDIF
+ # For backward compatibility with CMake < 2.8.12
+- \"IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
++ \"IMPORTED_LINK_INTERFACE_LIBRARIES_${TARGET_CONFIG}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
+ )
++!!ENDIF
+
+ !!IF !isEmpty(CMAKE_WINDOWS_BUILD)
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+ set(imported_implib \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+ !!ELSE
+- set(imported_implib \"IMPORTED_IMPLIB_${Configuration}\" \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
++ set(imported_implib \"IMPORTED_IMPLIB_${TARGET_CONFIG}\" \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+ !!ENDIF
+ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_implib})
+ if(NOT \"${IMPLIB_LOCATION}\" STREQUAL \"\")
+ set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
+- \"IMPORTED_IMPLIB_${Configuration}\" ${imported_implib}
++ \"IMPORTED_IMPLIB_${TARGET_CONFIG}\" ${imported_implib}
+ )
+ endif()
+ !!ENDIF
+@@ -227,13 +244,47 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!IF !isEmpty(CMAKE_STATIC_TYPE)
+ add_library(Qt5::$${CMAKE_MODULE_NAME} STATIC IMPORTED)
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
++ macro(_process_prl_file PRL_FILE_LOCATION CONFIGURATION)
++ if (EXISTS \"${PRL_FILE_LOCATION}\")
++ file(STRINGS \"${PRL_FILE_LOCATION}\" prl_strings REGEX \"QMAKE_PRL_LIBS_FOR_CMAKE\")
++ string(REGEX REPLACE \"QMAKE_PRL_LIBS_FOR_CMAKE *= *([^\\n]*)\" \"\\\\1\" static_depends ${prl_strings})
++ string(REGEX REPLACE \"\\\\$\\\\$\\\\[QT_INSTALL_LIBS\\\\]\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/lib\" static_depends \"${static_depends}\")
++ string(REPLACE \"-framework;\" \"-framework \" static_depends \"${static_depends}\")
++ if (_Qt5$${CMAKE_MODULE_NAME}_STATIC_${CONFIGURATION}_LIB_DEPENDENCIES)
++ set(_list_sep \";\")
++ endif()
++ set(_Qt5$${CMAKE_MODULE_NAME}_STATIC_${CONFIGURATION}_LIB_DEPENDENCIES \"${_Qt5$${CMAKE_MODULE_NAME}_STATIC_${CONFIGURATION}_LIB_DEPENDENCIES}${_list_sep}${static_depends}\")
++ endif()
++ endmacro()
++
++ macro(_populate_plugin_target_dependencies_from_prl_file PLUGIN_TARGET_NAME PRL_FILE_LOCATION CONFIGURATION LIB_DIRECTORY LIB_LOCATION)
++ file(STRINGS "${PRL_FILE_LOCATION}" prl_strings REGEX "QMAKE_PRL_LIBS_FOR_CMAKE")
++ string(REGEX REPLACE \"QMAKE_PRL_LIBS_FOR_CMAKE *= *([^\n]*)\" \"\\\\1\" static_depends ${prl_strings})
++ string(REGEX REPLACE \"\\\\$\\\\$\\\\[QT_INSTALL_LIBS\\\\]\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/lib\" static_depends \"${static_depends}\")
++ set_property(TARGET ${PLUGIN_TARGET_NAME} PROPERTY
++ INTERFACE_LINK_LIBRARIES ${static_depends}
++ )
++ endmacro()
++
++!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
++ _process_prl_file(\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG}\" DEBUG)
+ !!ELSE
++ _process_prl_file(\"$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG}\" DEBUG)
++!!ENDIF
++!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
++ _process_prl_file(\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE}\" RELEASE)
++!!ELSE
++ _process_prl_file(\"$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE}\" RELEASE)
++!!ENDIF
++
++!!ELSE // !isEmpty(CMAKE_STATIC_TYPE)
+ !!IF equals(TEMPLATE, aux)
+ add_library(Qt5::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
+ !!ELSE
+ add_library(Qt5::$${CMAKE_MODULE_NAME} SHARED IMPORTED)
+ !!ENDIF
+-!!ENDIF
++!!ENDIF // !isEmpty(CMAKE_STATIC_TYPE)
++
+ !!IF !equals(TEMPLATE, aux)
+ !!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1)
+@@ -245,6 +296,56 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS $${MODULE_DEFINES})
+
++ # Find plugin targets
++ file(GLOB pluginTargetsMaybe \"${CMAKE_CURRENT_LIST_DIR}/*Qt5$${CMAKE_MODULE_NAME}_*.cmake\")
++ unset(pluginTargets)
++ if(pluginTargetsMaybe)
++ foreach(pluginTarget ${pluginTargetsMaybe})
++ file(STRINGS ${pluginTarget} matched REGEX Qt5$${CMAKE_MODULE_NAME}_PLUGINS)
++ if(matched)
++ list(APPEND pluginTargets ${pluginTarget})
++ endif()
++ endforeach()
++ endif()
++
++ macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties TARGET_NAME PLUGIN_TARGET_NAME PLUGIN_NAME CONFIG PLUGIN_LOCATION)
++ set_property(TARGET ${PLUGIN_TARGET_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${CONFIG})
++
++!!IF isEmpty(CMAKE_PLUGIN_DIR_IS_ABSOLUTE)
++ set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
++!!ELSE
++ set(imported_location \"$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
++!!ENDIF
++ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
++ set_target_properties(${PLUGIN_TARGET_NAME} PROPERTIES
++ \"IMPORTED_LOCATION_${CONFIG}\" ${imported_location}
++ )
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ set_property(TARGET ${TARGET_NAME} APPEND PROPERTY STATIC_PLUGINS ${PLUGIN_NAME})
++ get_filename_component(_PLUGIN_DIR ${PLUGIN_LOCATION} PATH)
++ get_filename_component(_PLUGIN_DIR_NAME ${_PLUGIN_DIR} NAME)
++ get_filename_component(_PLUGIN_NAME ${PLUGIN_LOCATION} NAME)
++ string(REGEX REPLACE \"^lib(.*)\\\\.a\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/lib/qt/plugins/${_PLUGIN_DIR_NAME}/\\\\1.static.prl\" PLUGIN_PRL_FILE_LOCATION ${_PLUGIN_NAME})
++ if(NOT EXISTS ${PLUGIN_PRL_FILE_LOCATION})
++ string(REGEX REPLACE \"^lib(.*)\\\\.a\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/lib/qt/plugins/${_PLUGIN_DIR_NAME}/\\\\1.prl\" PLUGIN_PRL_FILE_LOCATION ${_PLUGIN_NAME})
++ endif()
++ if(NOT EXISTS ${PLUGIN_PRL_FILE_LOCATION})
++ string(REGEX REPLACE \"^lib(.*)\\\\.a\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/lib/qt/plugins/${_PLUGIN_DIR_NAME}/lib\\\\1.prl\" PLUGIN_PRL_FILE_LOCATION ${_PLUGIN_NAME})
++ endif()
++ if(NOT EXISTS ${PLUGIN_PRL_FILE_LOCATION})
++ message(FATAL_ERROR "The prl file containing dependencies of static plugin ${PLUGIN_TARGET_NAME} of ${TARGET_NAME} could not be found.")
++ endif()
++ _populate_plugin_target_dependencies_from_prl_file(${PLUGIN_TARGET_NAME} ${PLUGIN_PRL_FILE_LOCATION} ${CONFIG} \"lib/qt/plugins\" ${PLUGIN_LOCATION})
++!!ENDIF
++
++ endmacro()
++
++ if(pluginTargets)
++ foreach(pluginTarget ${pluginTargets})
++ include(${pluginTarget})
++ endforeach()
++ endif()
++
+ set(_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIRS_EXIST TRUE)
+ foreach (_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIR ${Qt5$${CMAKE_MODULE_NAME}_OWN_PRIVATE_INCLUDE_DIRS})
+ if (NOT EXISTS ${_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIR})
+@@ -336,9 +437,11 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!ELSE
+ \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+ !!ENDIF
+- _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
++ _populate_$${CMAKE_MODULE_NAME}_target_properties(Qt5::$${CMAKE_MODULE_NAME} RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+ endif()
++!!ENDIF // CMAKE_STATIC_TYPE
++
++
+ !!ENDIF // CMAKE_RELEASE_TYPE
+ !!ENDIF // CMAKE_FIND_OTHER_LIBRARY_BUILD
+
+@@ -349,29 +452,6 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ )
+ !!ENDIF // TEMPLATE != aux
+
+- file(GLOB pluginTargets \"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}_*Plugin.cmake\")
+-
+- macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION)
+- set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
+-
+-!!IF isEmpty(CMAKE_PLUGIN_DIR_IS_ABSOLUTE)
+- set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
+-!!ELSE
+- set(imported_location \"$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
+-!!ENDIF
+- _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
+- set_target_properties(Qt5::${Plugin} PROPERTIES
+- \"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
+- )
+- endmacro()
+-
+- if (pluginTargets)
+- foreach(pluginTarget ${pluginTargets})
+- include(${pluginTarget})
+- endforeach()
+- endif()
+-
+-
+ !!IF !isEmpty(CMAKE_MODULE_EXTRAS)
+ include(\"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}ConfigExtras.cmake\")
+ !!ENDIF
+diff --git a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
+index 5baf0fdb10..ec5f3cc437 100644
+--- a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
++++ b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
+@@ -1,11 +1,14 @@
+-
+-add_library(Qt5::$$CMAKE_PLUGIN_NAME MODULE IMPORTED)
++# Some Qt modules also load plugin target in extra config, so check whether the target already exists
++if(NOT TARGET Qt5::$$CMAKE_PLUGIN_NAME)
++ add_library(Qt5::$$CMAKE_PLUGIN_NAME MODULE IMPORTED)
+
+ !!IF !isEmpty(CMAKE_RELEASE_TYPE)
+-_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
++ _populate_$${CMAKE_MODULE_NAME}_plugin_properties(Qt5::$$CMAKE_MODULE_NAME Qt5::$$CMAKE_PLUGIN_NAME $$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
+ !!ENDIF
+ !!IF !isEmpty(CMAKE_DEBUG_TYPE)
+-_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
++ _populate_$${CMAKE_MODULE_NAME}_plugin_properties(Qt5::$$CMAKE_MODULE_NAME Qt5::$$CMAKE_PLUGIN_NAME $$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
+ !!ENDIF
+
+ list(APPEND Qt5$${CMAKE_MODULE_NAME}_PLUGINS Qt5::$$CMAKE_PLUGIN_NAME)
++
++endif()
+diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
+index 5e84628e72..43f570fb2c 100644
+--- a/qmake/generators/makefile.cpp
++++ b/qmake/generators/makefile.cpp
+@@ -994,10 +994,18 @@ MakefileGenerator::writePrlFile(QTextStream &t)
+ libs << "QMAKE_LIBS"; //obvious one
+ if(project->isActiveConfig("staticlib"))
+ libs << "QMAKE_LIBS_PRIVATE";
+- t << "QMAKE_PRL_LIBS =";
+- for (ProStringList::Iterator it = libs.begin(); it != libs.end(); ++it)
+- t << qv(project->values((*it).toKey()));
+- t << endl;
++ QStringList libNames;
++ QStringList libNamesCMake;
++ for (const auto &lib : libs) {
++ for (const auto &libName : project->values(lib.toKey())) {
++ libNames << QMakeEvaluator::quoteValue(libName);
++ QString libNameCMake(libName.toQString());
++ libNameCMake.replace(QChar('\\'), QLatin1String("\\\\"));
++ libNamesCMake << libNameCMake;
++ }
++ }
++ t << "QMAKE_PRL_LIBS = " << libNames.join(QChar(' ')) << endl;
++ t << "QMAKE_PRL_LIBS_FOR_CMAKE = " << libNamesCMake.join(QChar(';')) << endl;
+ }
+ }
+
+--
+2.16.1
+
diff --git a/0023-Allow-usage-of-static-version-with-CMake.patch b/0023-Allow-usage-of-static-version-with-CMake.patch
new file mode 100644
index 000000000000..9ea53096f369
--- /dev/null
+++ b/0023-Allow-usage-of-static-version-with-CMake.patch
@@ -0,0 +1,1001 @@
+From 4a11c942e31ea61ffdb83ff4a25d6ce708e3b817 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sat, 5 Aug 2017 21:14:26 +0200
+Subject: [PATCH 23/32] Allow usage of static version with CMake
+
+Allow selecting between dynamic and static Qt versions
+installed in the same prefix
+ - Use eg. find_package(Qt5Core) for dynamic version
+ - and eg. find_package(StaticQt5Core) for static version
+ - Static targets are prefixed, eg. StaticQt5::Core
+ - Set USE_STATIC_QT_BY_DEFAULT to use static version
+ via regular find_package(Qt5Core)
+---
+ mkspecs/features/create_cmake.prf | 103 ++++---
+ .../features/data/cmake/Qt5BasicConfig.cmake.in | 298 ++++++++++++++-------
+ .../features/data/cmake/Qt5PluginTarget.cmake.in | 18 +-
+ .../data/cmake/Qt5StaticOnlyRedirection.cmake.in | 11 +
+ src/corelib/Qt5CoreConfigExtras.cmake.in | 26 +-
+ src/gui/Qt5GuiConfigExtras.cmake.in | 8 +-
+ src/testlib/Qt5TestConfigExtras.cmake.in | 2 +-
+ 7 files changed, 314 insertions(+), 152 deletions(-)
+ create mode 100644 mkspecs/features/data/cmake/Qt5StaticOnlyRedirection.cmake.in
+
+diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
+index 15fc070008..13bd362092 100644
+--- a/mkspecs/features/create_cmake.prf
++++ b/mkspecs/features/create_cmake.prf
+@@ -38,7 +38,7 @@ split_incpath {
+ $$QT_MODULE_INCLUDE_BASE/Qt$${CMAKE_MODULE_NAME}/$$eval(QT.$${MODULE}.VERSION)/Qt$${CMAKE_MODULE_NAME})
+
+ cmake_extra_source_includes.input = $$PWD/data/cmake/ExtraSourceIncludes.cmake.in
+- cmake_extra_source_includes.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/ExtraSourceIncludes.cmake
++ cmake_extra_source_includes.output = $$CMAKE_OUT_DIR/$${DEFAULT_QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}/ExtraSourceIncludes.cmake
+
+ !build_pass:QMAKE_SUBSTITUTES += \
+ cmake_extra_source_includes
+@@ -90,6 +90,8 @@ win32:!static:!staticlib {
+ }
+
+ static|staticlib:CMAKE_STATIC_TYPE = true
++static|staticlib:DEFAULT_QT_VARIANT_PREFIX = "Static"
++else:DEFAULT_QT_VARIANT_PREFIX = ""
+
+ CMAKE_DEBUG_TYPE =
+ CMAKE_RELEASE_TYPE =
+@@ -135,17 +137,19 @@ contains(CONFIG, plugin) {
+ CMAKE_PLUGIN_NAME = $$PLUGIN_CLASS_NAME
+
+ win32 {
+- isEmpty(CMAKE_STATIC_TYPE) {
++ mingw {
+ CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.dll
+ CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.dll
+- } else:mingw {
+- CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}.a
+- CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}d.a
++ CMAKE_PLUGIN_LOCATION_RELEASE_STATIC = $$PLUGIN_TYPE/lib$${TARGET}.a
++ CMAKE_PLUGIN_LOCATION_DEBUG_STATIC = $$PLUGIN_TYPE/lib$${TARGET}d.a
+ } else { # MSVC static
+ CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.lib
+ CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.lib
++ CMAKE_PLUGIN_LOCATION_RELEASE_STATIC = $$PLUGIN_TYPE/$${TARGET}.lib
++ CMAKE_PLUGIN_LOCATION_DEBUG_STATIC = $$PLUGIN_TYPE/$${TARGET}d.lib
+ }
+ } else {
++ # this branch is broken by the patch, only apply when building for Windows
+ mac {
+ isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .dylib
+ else: CMAKE_PlUGIN_EXT = .a
+@@ -161,13 +165,13 @@ contains(CONFIG, plugin) {
+ }
+ }
+ cmake_target_file.input = $$PWD/data/cmake/Qt5PluginTarget.cmake.in
+- cmake_target_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}_$${PLUGIN_CLASS_NAME}.cmake
++ cmake_target_file.output = $$CMAKE_OUT_DIR/$${DEFAULT_QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}/$${DEFAULT_QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_$${PLUGIN_CLASS_NAME}.cmake
+
+ !build_pass:QMAKE_SUBSTITUTES += \
+ cmake_target_file
+
+ cmake_qt5_plugin_file.files = $$cmake_target_file.output
+- cmake_qt5_plugin_file.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
++ cmake_qt5_plugin_file.path = $$[QT_INSTALL_LIBS]/cmake/$${DEFAULT_QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}
+ INSTALLS += cmake_qt5_plugin_file
+
+ return()
+@@ -180,27 +184,36 @@ mod_deps =
+ lib_deps =
+ aux_mod_deps =
+ aux_lib_deps =
++aux_compile_defs_static = QT_STATIC QT_DESIGNER_STATIC
++contains(QT_CONFIG, angle): aux_compile_defs += QT_OPENGL_ES_2_ANGLE_STATIC
+ # Until CMake 3.0 is the minimum requirement of Qt 5, we need to filter
+ # out header-only modules from dependencies. CMake 3.0 provides INTERFACE
+ # libraries which are equivalent to header-only modules.
+ for (dep, sorted_deps) {
+ cdep = $$cmakeModuleName($$dep)
+ !contains(QT.$${dep}.module_config, no_link) {
+- mod_deps += $$cdep
+- lib_deps += Qt5::$$cdep
++ mod_deps += "$$cdep"
++ lib_deps += "${QT_VARIANT_PREFIX}Qt5::$$cdep"
++ lib_deps_static += "${QT_VARIANT_PREFIX}Qt5::$$cdep"
+ } else {
+- aux_mod_deps += $$cdep
+- aux_lib_deps += Qt5::$$cdep
++ aux_mod_deps += "$$cdep"
++ aux_lib_deps += "${QT_VARIANT_PREFIX}Qt5::$$cdep"
++ aux_lib_deps_static += "${QT_VARIANT_PREFIX}Qt5::$$cdep"
+ }
+ }
+ CMAKE_MODULE_DEPS = $$join(mod_deps, ";")
+ CMAKE_QT5_MODULE_DEPS = $$join(lib_deps, ";")
++CMAKE_QT5_MODULE_DEPS_STATIC = $$join(lib_deps_static, ";")
+ CMAKE_INTERFACE_MODULE_DEPS = $$join(aux_mod_deps, ";")
+ CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";")
++CMAKE_INTERFACE_QT5_MODULE_DEPS_STATIC = $$join(aux_lib_deps_static, ";")
++CMAKE_INTERFACE_COMPILE_DEFINITIONS_STATIC = $$join(aux_compile_defs_static, ";")
++
+
+ CMAKE_QT_STEM = Qt$$QT_MAJOR_VERSION$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}
+
+ mac {
++ # this branch is broken by the patch, only apply when building for Windows
+ !isEmpty(CMAKE_STATIC_TYPE) {
+ CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.a
+ CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
+@@ -228,35 +241,33 @@ mac {
+ CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqt5main$${QT_LIBINFIX}.a
+ CMAKE_WINMAIN_FILE_LOCATION_RELEASE = libqt5main$${QT_LIBINFIX}.a
+
+- !isEmpty(CMAKE_STATIC_TYPE) {
+- CMAKE_STATIC_WINDOWS_BUILD = "true"
+- CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.a
+- CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
++ isEmpty(QMAKE_EXTENSION_IMPORTLIB): QMAKE_EXTENSION_IMPORTLIB = dll.a
++ CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.$${QMAKE_EXTENSION_IMPORTLIB}
++ CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.$${QMAKE_EXTENSION_IMPORTLIB}
++ CMAKE_PRL_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.prl
++ CMAKE_PRL_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.prl
++
++ CMAKE_IMPLIB_FILE_LOCATION_DEBUG_STATIC = lib$${CMAKE_QT_STEM}d.a
++ CMAKE_IMPLIB_FILE_LOCATION_RELEASE_STATIC = lib$${CMAKE_QT_STEM}.a
++ CMAKE_PRL_FILE_LOCATION_DEBUG_STATIC = $${CMAKE_QT_STEM}d.static.prl
++ CMAKE_PRL_FILE_LOCATION_RELEASE_STATIC = $${CMAKE_QT_STEM}.static.prl
+
+- CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.prl
+- CMAKE_PRL_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.prl
+- } else {
+- isEmpty(QMAKE_EXTENSION_IMPORTLIB): QMAKE_EXTENSION_IMPORTLIB = a
+- CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.$${QMAKE_EXTENSION_IMPORTLIB}
+- CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.$${QMAKE_EXTENSION_IMPORTLIB}
+- }
+ } else {
+ CMAKE_WINMAIN_FILE_LOCATION_DEBUG = qtmain$${QT_LIBINFIX}d.lib
+ CMAKE_WINMAIN_FILE_LOCATION_RELEASE = qtmain$${QT_LIBINFIX}.lib
+
+- !isEmpty(CMAKE_STATIC_TYPE) {
+- CMAKE_STATIC_WINDOWS_BUILD = "true"
+- CMAKE_IMPLIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.lib
+- CMAKE_IMPLIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.lib
++ CMAKE_IMPLIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.lib
++ CMAKE_IMPLIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.lib
++ CMAKE_PRL_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.prl
++ CMAKE_PRL_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.prl
+
+- CMAKE_PRL_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.prl
+- CMAKE_PRL_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.prl
+- } else {
+- CMAKE_IMPLIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.lib
+- CMAKE_IMPLIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.lib
+- }
++ CMAKE_IMPLIB_FILE_LOCATION_DEBUG_STATIC = $${CMAKE_QT_STEM}d.lib
++ CMAKE_IMPLIB_FILE_LOCATION_RELEASE_STATIC = $${CMAKE_QT_STEM}.lib
++ CMAKE_PRL_FILE_LOCATION_DEBUG_STATIC = $${CMAKE_QT_STEM}d.static.prl
++ CMAKE_PRL_FILE_LOCATION_RELEASE_STATIC = $${CMAKE_QT_STEM}.static.prl
+ }
+ } else {
++ # this branch is broken by the patch, only apply when building for Windows
+ !isEmpty(CMAKE_STATIC_TYPE) {
+ CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.a
+ CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
+@@ -276,12 +287,12 @@ mac {
+ INSTALLS += cmake_qt5_module_files
+
+ cmake_config_file.input = $$PWD/data/cmake/Qt5BasicConfig.cmake.in
+-cmake_config_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}Config.cmake
++cmake_config_file.output = $$CMAKE_OUT_DIR/$${DEFAULT_QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}/$${DEFAULT_QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}Config.cmake
+
+ CMAKE_PACKAGE_VERSION = $$eval(QT.$${MODULE}.VERSION)
+
+ cmake_config_version_file.input = $$PWD/data/cmake/Qt5ConfigVersion.cmake.in
+-cmake_config_version_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}ConfigVersion.cmake
++cmake_config_version_file.output = $$CMAKE_OUT_DIR/$${DEFAULT_QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}/$${DEFAULT_QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}ConfigVersion.cmake
+
+ !build_pass:QMAKE_SUBSTITUTES += \
+ cmake_config_file \
+@@ -291,11 +302,29 @@ cmake_qt5_module_files.files = \
+ $$cmake_config_file.output \
+ $$cmake_config_version_file.output
+
++# add regular CMake package for static-only modules
++static|staticlib:actually_a_shared_build {
++ INSTALLS += cmake_qt5_module_files_shared
++
++ cmake_config_file_shared.input = $$PWD/data/cmake/Qt5StaticOnlyRedirection.cmake.in
++ cmake_config_file_shared.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}Config.cmake
++ cmake_config_version_file_shared.input = $$PWD/data/cmake/Qt5ConfigVersion.cmake.in
++ cmake_config_version_file_shared.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}ConfigVersion.cmake
++ !build_pass:QMAKE_SUBSTITUTES += \
++ cmake_config_file_shared \
++ cmake_config_version_file_shared
++
++ cmake_qt5_module_files_shared.files = \
++ $$cmake_config_file_shared.output \
++ $$cmake_config_version_file_shared.output
++ cmake_qt5_module_files_shared.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
++}
++
+ cmake_extras_file.input = $$_PRO_FILE_PWD_/Qt5$${CMAKE_MODULE_NAME}ConfigExtras.cmake.in
+ exists($$cmake_extras_file.input) {
+
+ CMAKE_MODULE_EXTRAS = "true"
+- cmake_extras_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}ConfigExtras.cmake
++ cmake_extras_file.output = $$CMAKE_OUT_DIR/$${DEFAULT_QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}/$${DEFAULT_QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}ConfigExtras.cmake
+
+ !build_pass:QMAKE_SUBSTITUTES += cmake_extras_file
+
+@@ -307,7 +336,7 @@ cmake_macros_file.input = $$_PRO_FILE_PWD_/Qt5$${CMAKE_MODULE_NAME}Macros.cmake
+ exists($$cmake_macros_file.input) {
+ CMAKE_MODULE_MACROS = "true"
+
+- cmake_macros_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}Macros.cmake
++ cmake_macros_file.output = $$CMAKE_OUT_DIR/$${DEFAULT_QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}/$${DEFAULT_QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}Macros.cmake
+ cmake_macros_file.CONFIG = verbatim
+
+ !build_pass:QMAKE_SUBSTITUTES += cmake_macros_file
+@@ -315,7 +344,7 @@ exists($$cmake_macros_file.input) {
+ cmake_qt5_module_files.files += $$cmake_macros_file.output
+ }
+
+-cmake_qt5_module_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
++cmake_qt5_module_files.path = $$[QT_INSTALL_LIBS]/cmake/$${DEFAULT_QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}
+
+ # We are generating cmake files. Most developers of Qt are not aware of cmake,
+ # so we require automatic tests to be available. The only module which should
+diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+index b401db5ac2..e6dd749c9e 100644
+--- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
++++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+@@ -9,6 +9,33 @@ if (CMAKE_VERSION VERSION_LESS 3.0.0)
+ endif()
+ !!ENDIF
+
++!!IF isEmpty(CMAKE_STATIC_TYPE)
++# "redirect" to static package overriding variant prefix so it does not contain "Static" anymore
++option(USE_STATIC_QT_BY_DEFAULT \"specifies whether to use static Qt by default (rather than via Static-prefix)\" OFF)
++if(USE_STATIC_QT_BY_DEFAULT)
++ set(ORIGINAL_OVERRIDE_QT_VARIANT_PREFIX "${OVERRIDE_QT_VARIANT_PREFIX}")
++ if(OVERRIDE_QT_VARIANT_PREFIX)
++ string(REPLACE \"Static\" \"\" OVERRIDE_QT_VARIANT_PREFIX "${OVERRIDE_QT_VARIANT_PREFIX}")
++ endif()
++ if(NOT OVERRIDE_QT_VARIANT_PREFIX)
++ set(OVERRIDE_QT_VARIANT_PREFIX "none")
++ endif()
++ find_package(StaticQt5$${CMAKE_MODULE_NAME})
++ set(OVERRIDE_QT_VARIANT_PREFIX "${ORIGINAL_OVERRIDE_QT_VARIANT_PREFIX}")
++ return()
++endif()
++!!ENDIF
++
++if(OVERRIDE_QT_VARIANT_PREFIX)
++ if(OVERRIDE_QT_VARIANT_PREFIX STREQUAL "none")
++ unset(QT_VARIANT_PREFIX)
++ else()
++ set(QT_VARIANT_PREFIX "${OVERRIDE_QT_VARIANT_PREFIX}")
++ endif()
++else()
++ set(QT_VARIANT_PREFIX \"$${DEFAULT_QT_VARIANT_PREFIX}\")
++endif()
++
+ !!IF !isEmpty(CMAKE_USR_MOVE_WORKAROUND)
+ !!IF !isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+ set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
+@@ -35,15 +62,19 @@ set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
+
+ !!IF !equals(TEMPLATE, aux)
+ # For backwards compatibility only. Use Qt5$${CMAKE_MODULE_NAME}_VERSION instead.
+-set(Qt5$${CMAKE_MODULE_NAME}_VERSION_STRING "$$eval(QT.$${MODULE}.VERSION)")
++set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_VERSION_STRING "$$eval(QT.$${MODULE}.VERSION)")
+
+-set(Qt5$${CMAKE_MODULE_NAME}_LIBRARIES Qt5::$${CMAKE_MODULE_NAME})
++set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_LIBRARIES ${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME})
+ !!ENDIF // TEMPLATE != aux
+
+-macro(_qt5_$${CMAKE_MODULE_NAME}_check_file_exists file)
+- if(NOT EXISTS \"${file}\" )
+- message(FATAL_ERROR \"The imported target \\\"Qt5::$${CMAKE_MODULE_NAME}\\\" references the file
+- \\\"${file}\\\"
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++macro(_qt5_$${CMAKE_MODULE_NAME}_check_file_exists_static FILE)
++!!ELSE
++macro(_qt5_$${CMAKE_MODULE_NAME}_check_file_exists FILE)
++!!ENDIF
++ if(NOT EXISTS \"${FILE}\")
++ message(FATAL_ERROR \"The imported target \\\"${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME}\\\" references the file
++ \\\"${FILE}\\\"
+ but this file does not exist. Possible reasons include:
+ * The file was deleted, renamed, or moved to another location.
+ * An install or uninstall procedure did not complete successfully.
+@@ -54,23 +85,60 @@ but not all the files it references.
+ endif()
+ endmacro()
+
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++# ensure also regular/dynamic macro exists because it might be used in some extra config
++if(NOT COMMAND _qt5_$${CMAKE_MODULE_NAME}_check_file_exists)
++ macro(_qt5_$${CMAKE_MODULE_NAME}_check_file_exists FILE)
++ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists_static("${FILE}")
++ endmacro()
++endif()
++!!ENDIF
++
+ !!IF !equals(TEMPLATE, aux)
+-macro(_populate_$${CMAKE_MODULE_NAME}_target_properties TARGET_CONFIG LIB_LOCATION IMPLIB_LOCATION)
+- set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${TARGET_CONFIG})
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++macro(_populate_$${CMAKE_MODULE_NAME}_target_properties_static TARGET_NAME TARGET_CONFIG LIB_LOCATION IMPLIB_LOCATION)
++!!ELSE
++macro(_populate_$${CMAKE_MODULE_NAME}_target_properties TARGET_NAME TARGET_CONFIG LIB_LOCATION IMPLIB_LOCATION)
++!!ENDIF
++ set_property(TARGET ${TARGET_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${TARGET_CONFIG})
+
+ !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
++
++!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/lib/${LIB_LOCATION}\")
++!!ELSE
++ set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/bin/${LIB_LOCATION}\")
++!!ENDIF
++!!ELSE
+ set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
++!!ENDIF
++
++!!ELSE // isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
++
++!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ set(imported_location \"lib/${LIB_LOCATION}\")
++!!ELSE
++ set(imported_location \"bin/${LIB_LOCATION}\")
++!!ENDIF
+ !!ELSE
+ set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+ !!ENDIF
+
++!!ENDIF // isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
++
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists_static(${imported_location})
++!!ELSE
+ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
++!!ENDIF
+
+ !!IF !isEmpty(CMAKE_STATIC_TYPE)
+ if (_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES)
+ set(_list_sep \";\")
+ endif()
+- set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
++ set_target_properties(${TARGET_NAME} PROPERTIES
+ \"INTERFACE_LINK_LIBRARIES_${TARGET_CONFIG}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}${_list_sep}${_Qt5$${CMAKE_MODULE_NAME}_STATIC_${TARGET_CONFIG}_LIB_DEPENDENCIES}\"
+ \"IMPORTED_LOCATION_${TARGET_CONFIG}\" ${imported_location}
+ !!IF !isEmpty(CMAKE_LIB_SONAME)
+@@ -80,7 +148,7 @@ macro(_populate_$${CMAKE_MODULE_NAME}_target_properties TARGET_CONFIG LIB_LOCATI
+ \"IMPORTED_LINK_INTERFACE_LIBRARIES_${TARGET_CONFIG}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}${_list_sep}${_Qt5$${CMAKE_MODULE_NAME}_STATIC_${TARGET_CONFIG}_LIB_DEPENDENCIES}\"
+ )
+ !!ELSE
+- set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
++ set_target_properties(${TARGET_NAME} PROPERTIES
+ \"INTERFACE_LINK_LIBRARIES_${TARGET_CONFIG}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
+ \"IMPORTED_LOCATION_${TARGET_CONFIG}\" ${imported_location}
+ !!IF !isEmpty(CMAKE_LIB_SONAME)
+@@ -97,9 +165,13 @@ macro(_populate_$${CMAKE_MODULE_NAME}_target_properties TARGET_CONFIG LIB_LOCATI
+ !!ELSE
+ set(imported_implib \"IMPORTED_IMPLIB_${TARGET_CONFIG}\" \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+ !!ENDIF
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists_static(${imported_implib})
++!!ELSE
+ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_implib})
++!!ENDIF
+ if(NOT \"${IMPLIB_LOCATION}\" STREQUAL \"\")
+- set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
++ set_target_properties(${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
+ \"IMPORTED_IMPLIB_${TARGET_CONFIG}\" ${imported_implib}
+ )
+ endif()
+@@ -107,8 +179,9 @@ macro(_populate_$${CMAKE_MODULE_NAME}_target_properties TARGET_CONFIG LIB_LOCATI
+ endmacro()
+ !!ENDIF
+
+-if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
++set(TARGET_NAME ${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME})
+
++if(NOT TARGET ${TARGET_NAME})
+ !!IF !no_module_headers
+ !!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
+ set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS
+@@ -116,46 +189,50 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
+ )
+ !!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
+- set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
++ set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
+ \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
+ \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
+ )
+-!!ELSE
+- set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+-!!ENDIF
+-!!ELSE
++!!ELSE // isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
++ set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
++!!ENDIF // isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
++!!ELSE // !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
+ !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
+ set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}\")
+ !!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
+- set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
++ set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
+ \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION\"
+ \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION/$${MODULE_INCNAME}\"
+ )
+-!!ELSE
+- set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+-!!ENDIF
+-!!ELSE
++!!ELSE // isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
++ set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
++!!ENDIF // isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
++!!ELSE // isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
+ set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"$$CMAKE_INCLUDE_DIR\" \"$${CMAKE_INCLUDE_DIR}Qt$${CMAKE_MODULE_NAME}\")
+ !!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
+- set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
++ set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
+ \"$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION\"
+ \"$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION/$${MODULE_INCNAME}\"
+ )
+-!!ELSE
+- set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+-!!ENDIF
+-!!ENDIF
+-!!ENDIF
++!!ELSE // isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
++ set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
++!!ENDIF // isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
++!!ENDIF // isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
++!!ENDIF // !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
+ !!IF !isEmpty(CMAKE_ADD_SOURCE_INCLUDE_DIRS)
+ include(\"${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake\" OPTIONAL)
+ !!ENDIF
+ !!ELSE
+ set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"\")
+- set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
++ set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+ !!ENDIF
+
+ foreach(_dir ${_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS})
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists_static(${_dir})
++!!ELSE
+ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${_dir})
++!!ENDIF
+ endforeach()
+
+ !!IF isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
+@@ -164,16 +241,20 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ list(FIND Qt5$${CMAKE_MODULE_NAME}_FIND_COMPONENTS Private _check_private)
+ if (NOT _check_private STREQUAL -1)
+ foreach(_dir ${Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS})
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists_static(${_dir})
++!!ELSE
+ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${_dir})
++!!ENDIF
+ endforeach()
+ endif()
+ !!ENDIF
+
+ !!IF !equals(TEMPLATE, aux)
+- set(Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS ${_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS})
++ set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS ${_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS})
+
+- set(Qt5$${CMAKE_MODULE_NAME}_DEFINITIONS -D$${MODULE_DEFINE})
+- set(Qt5$${CMAKE_MODULE_NAME}_COMPILE_DEFINITIONS $${MODULE_DEFINES})
++ set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_DEFINITIONS -D$${MODULE_DEFINE})
++ set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_COMPILE_DEFINITIONS $${MODULE_DEFINES})
+ !!ENDIF // TEMPLATE != aux
+ set(_Qt5$${CMAKE_MODULE_NAME}_MODULE_DEPENDENCIES \"$${CMAKE_MODULE_DEPS}\")
+
+@@ -183,10 +264,10 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ endif()
+ !!ENDIF
+
+- set(Qt5$${CMAKE_MODULE_NAME}_OWN_PRIVATE_INCLUDE_DIRS ${Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS})
++ set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_OWN_PRIVATE_INCLUDE_DIRS ${Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS})
+
+ set(_Qt5$${CMAKE_MODULE_NAME}_FIND_DEPENDENCIES_REQUIRED)
+- if (Qt5$${CMAKE_MODULE_NAME}_FIND_REQUIRED)
++ if (${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_FIND_REQUIRED)
+ set(_Qt5$${CMAKE_MODULE_NAME}_FIND_DEPENDENCIES_REQUIRED REQUIRED)
+ endif()
+ set(_Qt5$${CMAKE_MODULE_NAME}_FIND_DEPENDENCIES_QUIET)
+@@ -194,17 +275,17 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ set(_Qt5$${CMAKE_MODULE_NAME}_DEPENDENCIES_FIND_QUIET QUIET)
+ endif()
+ set(_Qt5$${CMAKE_MODULE_NAME}_FIND_VERSION_EXACT)
+- if (Qt5$${CMAKE_MODULE_NAME}_FIND_VERSION_EXACT)
++ if (${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_FIND_VERSION_EXACT)
+ set(_Qt5$${CMAKE_MODULE_NAME}_FIND_VERSION_EXACT EXACT)
+ endif()
+
+ !!IF !equals(TEMPLATE, aux)
+- set(Qt5$${CMAKE_MODULE_NAME}_EXECUTABLE_COMPILE_FLAGS \"\")
++ set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_EXECUTABLE_COMPILE_FLAGS \"\")
+ !!ENDIF // TEMPLATE != aux
+
+ foreach(_module_dep ${_Qt5$${CMAKE_MODULE_NAME}_MODULE_DEPENDENCIES})
+- if (NOT Qt5${_module_dep}_FOUND)
+- find_package(Qt5${_module_dep}
++ if (NOT ${QT_VARIANT_PREFIX}Qt5${_module_dep}_FOUND)
++ find_package(${QT_VARIANT_PREFIX}Qt5${_module_dep}
+ $$VERSION ${_Qt5$${CMAKE_MODULE_NAME}_FIND_VERSION_EXACT}
+ ${_Qt5$${CMAKE_MODULE_NAME}_DEPENDENCIES_FIND_QUIET}
+ ${_Qt5$${CMAKE_MODULE_NAME}_FIND_DEPENDENCIES_REQUIRED}
+@@ -212,28 +293,32 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ )
+ endif()
+
+- if (NOT Qt5${_module_dep}_FOUND)
+- set(Qt5$${CMAKE_MODULE_NAME}_FOUND False)
++ if (NOT ${QT_VARIANT_PREFIX}Qt5${_module_dep}_FOUND)
++ set(${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_FOUND False)
+ return()
+ endif()
+
+ !!IF !equals(TEMPLATE, aux)
+- list(APPEND Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS \"${Qt5${_module_dep}_INCLUDE_DIRS}\")
+- list(APPEND Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"${Qt5${_module_dep}_PRIVATE_INCLUDE_DIRS}\")
+- list(APPEND Qt5$${CMAKE_MODULE_NAME}_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS})
+- list(APPEND Qt5$${CMAKE_MODULE_NAME}_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS})
+- list(APPEND Qt5$${CMAKE_MODULE_NAME}_EXECUTABLE_COMPILE_FLAGS ${Qt5${_module_dep}_EXECUTABLE_COMPILE_FLAGS})
++ list(APPEND ${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS \"${Qt5${_module_dep}_INCLUDE_DIRS}\")
++ list(APPEND ${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"${Qt5${_module_dep}_PRIVATE_INCLUDE_DIRS}\")
++ list(APPEND ${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS})
++ list(APPEND ${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS})
++ list(APPEND ${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_EXECUTABLE_COMPILE_FLAGS ${Qt5${_module_dep}_EXECUTABLE_COMPILE_FLAGS})
+ !!ENDIF // TEMPLATE != aux
+ endforeach()
+ !!IF !equals(TEMPLATE, aux)
+- list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS)
+- list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS)
+- list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_DEFINITIONS)
+- list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_COMPILE_DEFINITIONS)
+- list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_EXECUTABLE_COMPILE_FLAGS)
++ list(REMOVE_DUPLICATES ${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS)
++ list(REMOVE_DUPLICATES ${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS)
++ list(REMOVE_DUPLICATES ${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_DEFINITIONS)
++ list(REMOVE_DUPLICATES ${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_COMPILE_DEFINITIONS)
++ list(REMOVE_DUPLICATES ${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_EXECUTABLE_COMPILE_FLAGS)
+ !!ENDIF // TEMPLATE != aux
+
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ set(_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES \"$${CMAKE_QT5_MODULE_DEPS_STATIC}\")
++!!ELSE
+ set(_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES \"$${CMAKE_QT5_MODULE_DEPS}\")
++!!ENDIF
+
+ !!IF !isEmpty(CMAKE_INTERFACE_QT5_MODULE_DEPS)
+ if (NOT CMAKE_VERSION VERSION_LESS 3.0.0)
+@@ -242,8 +327,9 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!ENDIF
+
+ !!IF !isEmpty(CMAKE_STATIC_TYPE)
+- add_library(Qt5::$${CMAKE_MODULE_NAME} STATIC IMPORTED)
+- set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
++ add_library(${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} STATIC IMPORTED)
++ set_property(TARGET ${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
++
+ macro(_process_prl_file PRL_FILE_LOCATION CONFIGURATION)
+ if (EXISTS \"${PRL_FILE_LOCATION}\")
+ file(STRINGS \"${PRL_FILE_LOCATION}\" prl_strings REGEX \"QMAKE_PRL_LIBS_FOR_CMAKE\")
+@@ -267,34 +353,45 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ endmacro()
+
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+- _process_prl_file(\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG}\" DEBUG)
++ _process_prl_file(\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG_STATIC}\" DEBUG)
+ !!ELSE
+- _process_prl_file(\"$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG}\" DEBUG)
++ _process_prl_file(\"$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG_STATIC}\" DEBUG)
+ !!ENDIF
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+- _process_prl_file(\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE}\" RELEASE)
++ _process_prl_file(\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE_STATIC}\" RELEASE)
+ !!ELSE
+- _process_prl_file(\"$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE}\" RELEASE)
++ _process_prl_file(\"$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE_STATIC}\" RELEASE)
+ !!ENDIF
+
+ !!ELSE // !isEmpty(CMAKE_STATIC_TYPE)
+ !!IF equals(TEMPLATE, aux)
+- add_library(Qt5::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
++ add_library(${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
+ !!ELSE
+- add_library(Qt5::$${CMAKE_MODULE_NAME} SHARED IMPORTED)
++ add_library(${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} SHARED IMPORTED)
+ !!ENDIF
+ !!ENDIF // !isEmpty(CMAKE_STATIC_TYPE)
+
+ !!IF !equals(TEMPLATE, aux)
+ !!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
+- set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1)
++ set_property(TARGET ${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1)
+ !!ENDIF
+ !!ENDIF // TEMPLATE != aux
+
+- set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY
++!!IF !equals(TEMPLATE, aux)
++!!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
++ set_property(TARGET ${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1)
++!!ENDIF
++!!ENDIF // TEMPLATE != aux
++
++ set_property(TARGET ${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} PROPERTY
+ INTERFACE_INCLUDE_DIRECTORIES ${_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS})
+- set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY
+- INTERFACE_COMPILE_DEFINITIONS $${MODULE_DEFINES})
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ set_property(TARGET ${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} PROPERTY
++ INTERFACE_COMPILE_DEFINITIONS $${CMAKE_INTERFACE_COMPILE_DEFINITIONS_STATIC} $${MODULE_DEFINES})
++!!ELSE
++ set_property(TARGET ${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} PROPERTY
++ INTERFACE_COMPILE_DEFINITIONS $${MODULE_DEFINES})
++!!ENDIF
+
+ # Find plugin targets
+ file(GLOB pluginTargetsMaybe \"${CMAKE_CURRENT_LIST_DIR}/*Qt5$${CMAKE_MODULE_NAME}_*.cmake\")
+@@ -308,7 +405,11 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ endforeach()
+ endif()
+
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties_static TARGET_NAME PLUGIN_TARGET_NAME PLUGIN_NAME CONFIG PLUGIN_LOCATION)
++!!ELSE
+ macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties TARGET_NAME PLUGIN_TARGET_NAME PLUGIN_NAME CONFIG PLUGIN_LOCATION)
++!!ENDIF
+ set_property(TARGET ${PLUGIN_TARGET_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${CONFIG})
+
+ !!IF isEmpty(CMAKE_PLUGIN_DIR_IS_ABSOLUTE)
+@@ -316,7 +417,11 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!ELSE
+ set(imported_location \"$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
+ !!ENDIF
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists_static(${imported_location})
++!!ELSE
+ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
++!!ENDIF
+ set_target_properties(${PLUGIN_TARGET_NAME} PROPERTIES
+ \"IMPORTED_LOCATION_${CONFIG}\" ${imported_location}
+ )
+@@ -347,7 +452,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ endif()
+
+ set(_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIRS_EXIST TRUE)
+- foreach (_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIR ${Qt5$${CMAKE_MODULE_NAME}_OWN_PRIVATE_INCLUDE_DIRS})
++ foreach (_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIR ${${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_OWN_PRIVATE_INCLUDE_DIRS})
+ if (NOT EXISTS ${_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIR})
+ set(_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIRS_EXIST FALSE)
+ endif()
+@@ -355,9 +460,9 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+
+ if (_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIRS_EXIST
+ AND NOT CMAKE_VERSION VERSION_LESS 3.0.0 )
+- add_library(Qt5::$${CMAKE_MODULE_NAME}Private INTERFACE IMPORTED)
+- set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}Private PROPERTY
+- INTERFACE_INCLUDE_DIRECTORIES ${Qt5$${CMAKE_MODULE_NAME}_OWN_PRIVATE_INCLUDE_DIRS}
++ add_library(${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME}Private INTERFACE IMPORTED)
++ set_property(TARGET ${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME}Private PROPERTY
++ INTERFACE_INCLUDE_DIRECTORIES ${${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_OWN_PRIVATE_INCLUDE_DIRS}
+ )
+ set(_Qt5$${CMAKE_MODULE_NAME}_PRIVATEDEPS)
+ foreach(dep ${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES})
+@@ -365,66 +470,68 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ list(APPEND _Qt5$${CMAKE_MODULE_NAME}_PRIVATEDEPS ${dep}Private)
+ endif()
+ endforeach()
+- set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}Private PROPERTY
+- INTERFACE_LINK_LIBRARIES Qt5::$${CMAKE_MODULE_NAME} ${_Qt5$${CMAKE_MODULE_NAME}_PRIVATEDEPS}
++ set_property(TARGET ${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME}Private PROPERTY
++ INTERFACE_LINK_LIBRARIES ${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} ${_Qt5$${CMAKE_MODULE_NAME}_PRIVATEDEPS}
+ )
+ endif()
+
+ !!IF !equals(TEMPLATE, aux)
+ !!IF !isEmpty(CMAKE_RELEASE_TYPE)
+-!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
+- _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" \"\" )
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ _populate_$${CMAKE_MODULE_NAME}_target_properties_static(${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE_STATIC}\" \"\" )
+ !!ELSE
+- _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
++ _populate_$${CMAKE_MODULE_NAME}_target_properties(${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
++!!ENDIF // CMAKE_STATIC_TYPE
++
+
+ !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
+ !!IF isEmpty(CMAKE_DEBUG_TYPE)
+-!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+- if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
++ if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG_STATIC}\" )
+ !!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
+ if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+ !!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
+- _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
+-!!ELSE // CMAKE_STATIC_WINDOWS_BUILD
++ _populate_$${CMAKE_MODULE_NAME}_target_properties_static(${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG_STATIC}\" \"\" )
++ endif()
++!!ELSE // CMAKE_STATIC_TYPE
+ if (EXISTS
+ !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+ \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
+ !!ELSE
+ \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
+ !!ENDIF
+- AND EXISTS
++ AND EXISTS
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+ \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+ !!ELSE
+ \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+ !!ENDIF
+- _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
++ _populate_$${CMAKE_MODULE_NAME}_target_properties(${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+ endif()
++!!ENDIF // CMAKE_STATIC_TYPE
+ !!ENDIF // CMAKE_DEBUG_TYPE
+ !!ENDIF // CMAKE_FIND_OTHER_LIBRARY_BUILD
+-
+ !!ENDIF // CMAKE_RELEASE_TYPE
+
+ !!IF !isEmpty(CMAKE_DEBUG_TYPE)
+-!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
+- _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ _populate_$${CMAKE_MODULE_NAME}_target_properties_static(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
+ !!ELSE
+ _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
++!!ENDIF // CMAKE_STATIC_TYPE
+
+ !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
+ !!IF isEmpty(CMAKE_RELEASE_TYPE)
+-!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
++
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+- if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
++ if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE_STATIC}\" )
+ !!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
+- if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
++ if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE_STATIC}\" )
+ !!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
+- _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" \"\" )
+-!!ELSE // CMAKE_STATIC_WINDOWS_BUILD
++ _populate_$${CMAKE_MODULE_NAME}_target_properties_static(${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE_STATIC}\" \"\" )
++!!ELSE // CMAKE_STATIC_TYPE
+ if (EXISTS
+ !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+ \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
+@@ -437,7 +544,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!ELSE
+ \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+ !!ENDIF
+- _populate_$${CMAKE_MODULE_NAME}_target_properties(Qt5::$${CMAKE_MODULE_NAME} RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
++ _populate_$${CMAKE_MODULE_NAME}_target_properties(${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+ endif()
+ !!ENDIF // CMAKE_STATIC_TYPE
+
+@@ -447,19 +554,22 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+
+ !!ENDIF // CMAKE_DEBUG_TYPE
+ !!ELSE // TEMPLATE != aux
+- set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
++ set_target_properties(${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
+ INTERFACE_LINK_LIBRARIES \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
+ )
+ !!ENDIF // TEMPLATE != aux
+
+ !!IF !isEmpty(CMAKE_MODULE_EXTRAS)
+- include(\"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}ConfigExtras.cmake\")
++ include(\"${CMAKE_CURRENT_LIST_DIR}/../${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}/${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}ConfigExtras.cmake\")
+ !!ENDIF
+-
+ !!IF !isEmpty(CMAKE_MODULE_MACROS)
+- include(\"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}Macros.cmake\")
++ include(\"${CMAKE_CURRENT_LIST_DIR}/../${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}/${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}Macros.cmake\")
+ !!ENDIF
+
+-_qt5_$${CMAKE_MODULE_NAME}_check_file_exists(\"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}ConfigVersion.cmake\")
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++_qt5_$${CMAKE_MODULE_NAME}_check_file_exists_static(\"${CMAKE_CURRENT_LIST_DIR}/../${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}/${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}ConfigVersion.cmake\")
++!!ELSE
++_qt5_$${CMAKE_MODULE_NAME}_check_file_exists(\"${CMAKE_CURRENT_LIST_DIR}/../${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}/${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}ConfigVersion.cmake\")
++!!ENDIF
+
+ endif()
+diff --git a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
+index ec5f3cc437..1e4d98086c 100644
+--- a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
++++ b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
+@@ -1,14 +1,22 @@
+ # Some Qt modules also load plugin target in extra config, so check whether the target already exists
+-if(NOT TARGET Qt5::$$CMAKE_PLUGIN_NAME)
+- add_library(Qt5::$$CMAKE_PLUGIN_NAME MODULE IMPORTED)
++if(NOT TARGET ${QT_VARIANT_PREFIX}Qt5::$$CMAKE_PLUGIN_NAME)
++ add_library(${QT_VARIANT_PREFIX}Qt5::$$CMAKE_PLUGIN_NAME MODULE IMPORTED)
+
+ !!IF !isEmpty(CMAKE_RELEASE_TYPE)
+- _populate_$${CMAKE_MODULE_NAME}_plugin_properties(Qt5::$$CMAKE_MODULE_NAME Qt5::$$CMAKE_PLUGIN_NAME $$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ _populate_$${CMAKE_MODULE_NAME}_plugin_properties_static(${QT_VARIANT_PREFIX}Qt5::$$CMAKE_MODULE_NAME ${QT_VARIANT_PREFIX}Qt5::$$CMAKE_PLUGIN_NAME $$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE_STATIC}\")
++!!ELSE
++ _populate_$${CMAKE_MODULE_NAME}_plugin_properties(${QT_VARIANT_PREFIX}Qt5::$$CMAKE_MODULE_NAME ${QT_VARIANT_PREFIX}Qt5::$$CMAKE_PLUGIN_NAME $$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
++!!ENDIF
+ !!ENDIF
+ !!IF !isEmpty(CMAKE_DEBUG_TYPE)
+- _populate_$${CMAKE_MODULE_NAME}_plugin_properties(Qt5::$$CMAKE_MODULE_NAME Qt5::$$CMAKE_PLUGIN_NAME $$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++ _populate_$${CMAKE_MODULE_NAME}_plugin_properties_static(${QT_VARIANT_PREFIX}Qt5::$$CMAKE_MODULE_NAME ${QT_VARIANT_PREFIX}Qt5::$$CMAKE_PLUGIN_NAME $$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG_STATIC}\")
++!!ELSE
++ _populate_$${CMAKE_MODULE_NAME}_plugin_properties(${QT_VARIANT_PREFIX}Qt5::$$CMAKE_MODULE_NAME ${QT_VARIANT_PREFIX}Qt5::$$CMAKE_PLUGIN_NAME $$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
++!!ENDIF
+ !!ENDIF
+
+-list(APPEND Qt5$${CMAKE_MODULE_NAME}_PLUGINS Qt5::$$CMAKE_PLUGIN_NAME)
++list(APPEND ${QT_VARIANT_PREFIX}Qt5$${CMAKE_MODULE_NAME}_PLUGINS ${QT_VARIANT_PREFIX}Qt5::$$CMAKE_PLUGIN_NAME)
+
+ endif()
+diff --git a/mkspecs/features/data/cmake/Qt5StaticOnlyRedirection.cmake.in b/mkspecs/features/data/cmake/Qt5StaticOnlyRedirection.cmake.in
+new file mode 100644
+index 0000000000..0091940fd2
+--- /dev/null
++++ b/mkspecs/features/data/cmake/Qt5StaticOnlyRedirection.cmake.in
+@@ -0,0 +1,11 @@
++# "redirect" to static package overriding variant prefix so it does not contain "Static" anymore
++set(ORIGINAL_OVERRIDE_QT_VARIANT_PREFIX "${OVERRIDE_QT_VARIANT_PREFIX}")
++if(OVERRIDE_QT_VARIANT_PREFIX)
++ string(REPLACE \"Static\" \"\" OVERRIDE_QT_VARIANT_PREFIX "${OVERRIDE_QT_VARIANT_PREFIX}")
++endif()
++if(NOT OVERRIDE_QT_VARIANT_PREFIX)
++ set(OVERRIDE_QT_VARIANT_PREFIX "none")
++endif()
++find_package(StaticQt5$${CMAKE_MODULE_NAME})
++set(OVERRIDE_QT_VARIANT_PREFIX "${ORIGINAL_OVERRIDE_QT_VARIANT_PREFIX}")
++
+diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
+index 545b9a3d1e..ebe6644dfe 100644
+--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
++++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
+@@ -1,4 +1,6 @@
+
++set(IMPORTED_TARGET_NAME ${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME})
++
+ if (NOT TARGET Qt5::qmake)
+ add_executable(Qt5::qmake IMPORTED)
+
+@@ -50,9 +52,9 @@ set(Qt5Core_QMAKE_EXECUTABLE Qt5::qmake)
+ set(Qt5Core_MOC_EXECUTABLE Qt5::moc)
+ set(Qt5Core_RCC_EXECUTABLE Qt5::rcc)
+
+-set_property(TARGET Qt5::Core PROPERTY INTERFACE_QT_MAJOR_VERSION 5)
+-set_property(TARGET Qt5::Core PROPERTY INTERFACE_QT_COORD_TYPE $$QT_COORD_TYPE)
+-set_property(TARGET Qt5::Core APPEND PROPERTY
++set_property(TARGET ${IMPORTED_TARGET_NAME} PROPERTY INTERFACE_QT_MAJOR_VERSION 5)
++set_property(TARGET ${IMPORTED_TARGET_NAME} PROPERTY INTERFACE_QT_COORD_TYPE $$QT_COORD_TYPE)
++set_property(TARGET ${IMPORTED_TARGET_NAME} APPEND PROPERTY
+ COMPATIBLE_INTERFACE_STRING QT_MAJOR_VERSION QT_COORD_TYPE
+ )
+
+@@ -63,7 +65,7 @@ foreach(_dir ${_qt5_corelib_extra_includes})
+ endforeach()
+
+ list(APPEND Qt5Core_INCLUDE_DIRS ${_qt5_corelib_extra_includes})
+-set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_qt5_corelib_extra_includes})
++set_property(TARGET ${IMPORTED_TARGET_NAME} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_qt5_corelib_extra_includes})
+ set(_qt5_corelib_extra_includes)
+
+ # Targets using Qt need to use the POSITION_INDEPENDENT_CODE property. The
+@@ -81,9 +83,9 @@ set(Qt5_POSITION_INDEPENDENT_CODE True)
+ if (CMAKE_VERSION VERSION_LESS 2.8.12
+ AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\"
+ OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))
+- set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE \"ON\")
++ set_property(TARGET ${IMPORTED_TARGET_NAME} APPEND PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE \"ON\")
+ else()
+- set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $$QMAKE_CXXFLAGS_APP)
++ set_property(TARGET ${IMPORTED_TARGET_NAME} APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $$QMAKE_CXXFLAGS_APP)
+ endif()
+
+ # Applications using qmake or cmake >= 2.8.12 as their build system will
+@@ -103,7 +105,7 @@ endif()
+ !!IF !isEmpty(QT_NAMESPACE)
+ list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE)
+ list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE)
+-set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE)
++set_property(TARGET ${IMPORTED_TARGET_NAME} APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE)
+ !!ENDIF
+
+ !!IF !isEmpty(CMAKE_DISABLED_FEATURES)
+@@ -112,9 +114,9 @@ set(Qt5_DISABLED_FEATURES
+ )
+ !!ENDIF
+
+-set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)
++set_property(TARGET ${IMPORTED_TARGET_NAME} APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)
+
+-set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_FEATURES cxx_decltype)
++set_property(TARGET ${IMPORTED_TARGET_NAME} PROPERTY INTERFACE_COMPILE_FEATURES cxx_decltype)
+
+ !!IF qtConfig(reduce_exports)
+ set(QT_VISIBILITY_AVAILABLE \"True\")
+@@ -162,14 +164,14 @@ if (NOT TARGET Qt5::WinMain)
+ set(_isWin32 $<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>)
+ set(_isNotExcluded $<NOT:$<BOOL:$<TARGET_PROPERTY:Qt5_NO_LINK_QTMAIN>>>)
+ set(_isPolicyNEW $<TARGET_POLICY:CMP0020>)
+- get_target_property(_configs Qt5::Core IMPORTED_CONFIGURATIONS)
+- set_property(TARGET Qt5::Core APPEND PROPERTY
++ get_target_property(_configs ${IMPORTED_TARGET_NAME} IMPORTED_CONFIGURATIONS)
++ set_property(TARGET ${IMPORTED_TARGET_NAME} APPEND PROPERTY
+ INTERFACE_LINK_LIBRARIES
+ $<$<AND:${_isExe},${_isWin32},${_isNotExcluded},${_isPolicyNEW}>:Qt5::WinMain>
+ )
+ # For backward compatibility with CMake < 2.8.12
+ foreach(_config ${_configs})
+- set_property(TARGET Qt5::Core APPEND PROPERTY
++ set_property(TARGET ${IMPORTED_TARGET_NAME} APPEND PROPERTY
+ IMPORTED_LINK_INTERFACE_LIBRARIES_${_config}
+ $<$<AND:${_isExe},${_isWin32},${_isNotExcluded},${_isPolicyNEW}>:Qt5::WinMain>
+ )
+diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in
+index 2e32911a64..6b02a12944 100644
+--- a/src/gui/Qt5GuiConfigExtras.cmake.in
++++ b/src/gui/Qt5GuiConfigExtras.cmake.in
+@@ -1,4 +1,6 @@
+
++set(IMPORTED_TARGET_NAME ${QT_VARIANT_PREFIX}Qt5::$${CMAKE_MODULE_NAME})
++
+ !!IF !isEmpty(CMAKE_ANGLE_EGL_DLL_RELEASE)
+
+ !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
+@@ -67,7 +69,7 @@ unset(_GL_INCDIRS)
+ # optional.
+
+ list(APPEND Qt5Gui_INCLUDE_DIRS ${_qt5gui_OPENGL_INCLUDE_DIR})
+-set_property(TARGET Qt5::Gui APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_qt5gui_OPENGL_INCLUDE_DIR})
++set_property(TARGET ${IMPORTED_TARGET_NAME} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_qt5gui_OPENGL_INCLUDE_DIR})
+
+ unset(_qt5gui_OPENGL_INCLUDE_DIR CACHE)
+
+@@ -170,9 +172,9 @@ _qt5gui_find_extra_libs(OPENGL \"$$CMAKE_OPENGL_LIBS\" \"$$CMAKE_OPENGL_LIBDIR\"
+
+ set(Qt5Gui_OPENGL_IMPLEMENTATION $$CMAKE_QT_OPENGL_IMPLEMENTATION)
+
+-get_target_property(_configs Qt5::Gui IMPORTED_CONFIGURATIONS)
++get_target_property(_configs ${IMPORTED_TARGET_NAME} IMPORTED_CONFIGURATIONS)
+ foreach(_config ${_configs})
+- set_property(TARGET Qt5::Gui APPEND PROPERTY
++ set_property(TARGET ${IMPORTED_TARGET_NAME} APPEND PROPERTY
+ IMPORTED_LINK_DEPENDENT_LIBRARIES_${_config}
+ ${Qt5Gui_EGL_LIBRARIES} ${Qt5Gui_OPENGL_LIBRARIES}
+ )
+diff --git a/src/testlib/Qt5TestConfigExtras.cmake.in b/src/testlib/Qt5TestConfigExtras.cmake.in
+index 2a575958ae..ca0e3be3b5 100644
+--- a/src/testlib/Qt5TestConfigExtras.cmake.in
++++ b/src/testlib/Qt5TestConfigExtras.cmake.in
+@@ -1,5 +1,5 @@
+
+-set_property(TARGET Qt5::Test
++set_property(TARGET ${QT_VARIANT_PREFIX}Qt5::Test
+ APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS QT_TESTCASE_BUILDDIR=\\\"\${CMAKE_BINARY_DIR}\\\"
+ )
+--
+2.16.1
+
diff --git a/0024-Adjust-linker-flags-for-static-build-with-cmake-ming.patch b/0024-Adjust-linker-flags-for-static-build-with-cmake-ming.patch
new file mode 100644
index 000000000000..d463e883d3ad
--- /dev/null
+++ b/0024-Adjust-linker-flags-for-static-build-with-cmake-ming.patch
@@ -0,0 +1,29 @@
+From 61cc992fc37a4f44ada488a9e60514e237e523b5 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Fri, 2 Jun 2017 16:42:07 +0200
+Subject: [PATCH 24/32] Adjust linker flags for static build with
+ cmake/mingw-w64
+
+Change-Id: I33b88976d8f5ce87ce431a6f422fe87785bf5b8d
+---
+ src/corelib/Qt5CoreConfigExtras.cmake.in | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
+index ebe6644dfe..687d611b3f 100644
+--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
++++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
+@@ -190,3 +190,10 @@ get_filename_component(_Qt5CoreConfigDir ${CMAKE_CURRENT_LIST_FILE} PATH)
+ set(_Qt5CTestMacros \"${_Qt5CoreConfigDir}/Qt5CTestMacros.cmake\")
+
+ _qt5_Core_check_file_exists(${_Qt5CTestMacros})
++
++!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
++set(_isExe $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>)
++# INTERFACE_LINK_LIBRARIES is used to pass a linker flag '-static' and library ws2_32
++set_target_properties(${IMPORTED_TARGET_NAME} PROPERTIES \"INTERFACE_LINK_LIBRARIES\" \"$<${_isExe}:-static;ws2_32>\")
++unset(_isExe)
++!!ENDIF
+--
+2.16.1
+
diff --git a/0025-Use-correct-pkg-config-static-flag.patch b/0025-Use-correct-pkg-config-static-flag.patch
new file mode 100644
index 000000000000..db588595a429
--- /dev/null
+++ b/0025-Use-correct-pkg-config-static-flag.patch
@@ -0,0 +1,26 @@
+From db3d86b75f473d02c5ce6410f7d054f320c7d8f9 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 18 Sep 2016 18:50:21 +0200
+Subject: [PATCH 25/32] Use correct pkg-config --static flag
+
+---
+ configure.pri | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/configure.pri b/configure.pri
+index 9da756fb3a..fa2719bb0c 100644
+--- a/configure.pri
++++ b/configure.pri
+@@ -311,6 +311,9 @@ defineTest(qtConfTest_detectPkgConfig) {
+ qtLog("Found pkg-config from path: $$pkgConfig")
+ }
+ }
++ !isEmpty(pkgConfig):qtConfig(static) {
++ pkgConfig = "$$pkgConfig --static"
++ }
+
+ $$qtConfEvaluate("features.cross_compile") {
+ # cross compiling, check that pkg-config is set up sanely
+--
+2.16.1
+
diff --git a/0026-Fix-macro-invoking-moc-rcc-and-uic.patch b/0026-Fix-macro-invoking-moc-rcc-and-uic.patch
new file mode 100644
index 000000000000..eedb6ba5282a
--- /dev/null
+++ b/0026-Fix-macro-invoking-moc-rcc-and-uic.patch
@@ -0,0 +1,74 @@
+From 14e1e2026e3e5bc255c717ecde076f54e0e107b1 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sun, 4 Dec 2016 20:35:47 +0100
+Subject: [PATCH 26/32] Fix macro invoking moc, rcc and uic
+
+* Otherwise the arguments aren't passed correctly leading to errors like
+ ```
+ [ 3%] Generating qca_core.moc
+ moc: Too many input files specified: 'Qt5::moc' '/build/qca-qt5/src/qca-2.1.3/include/QtCrypto/qca_safetimer.h'
+ ```
+* Just a workaround, not sure what is causing the issue (maybe a CMake bug?)
+* See https://github.com/Martchus/PKGBUILDs/issues/11
+
+Change-Id: I6fde86d0a3ade37b4376604a1eb6d5723eda8b4c
+---
+ src/corelib/Qt5CoreMacros.cmake | 9 ++++++---
+ src/widgets/Qt5WidgetsMacros.cmake | 3 ++-
+ 2 files changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
+index 8d3dbe3ecf..f0f0d69309 100644
+--- a/src/corelib/Qt5CoreMacros.cmake
++++ b/src/corelib/Qt5CoreMacros.cmake
+@@ -132,8 +132,9 @@ function(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target
+ endif()
+
+ set(_moc_extra_parameters_file @${_moc_parameters_file})
++ get_target_property(MOC_LOC ${Qt5Core_MOC_EXECUTABLE} IMPORTED_LOCATION)
+ add_custom_command(OUTPUT ${outfile}
+- COMMAND ${Qt5Core_MOC_EXECUTABLE} ${_moc_extra_parameters_file}
++ COMMAND ${MOC_LOC} ${_moc_extra_parameters_file}
+ DEPENDS ${infile} ${moc_depends}
+ ${_moc_working_dir}
+ VERBATIM)
+@@ -254,8 +255,9 @@ function(QT5_ADD_BINARY_RESOURCES target )
+ set(rc_depends ${rc_depends} ${_rc_depends})
+ endforeach()
+
++ get_target_property(RCC_LOC ${Qt5Core_RCC_EXECUTABLE} IMPORTED_LOCATION)
+ add_custom_command(OUTPUT ${rcc_destination}
+- COMMAND ${Qt5Core_RCC_EXECUTABLE}
++ COMMAND ${RCC_LOC}
+ ARGS ${rcc_options} --binary --name ${target} --output ${rcc_destination} ${infiles}
+ DEPENDS ${rc_depends} ${out_depends} ${infiles} VERBATIM)
+ add_custom_target(${target} ALL DEPENDS ${rcc_destination})
+@@ -287,8 +289,9 @@ function(QT5_ADD_RESOURCES outfiles )
+ _QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends)
+ set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON)
+
++ get_target_property(MOC_LOC ${Qt5Core_RCC_EXECUTABLE} IMPORTED_LOCATION)
+ add_custom_command(OUTPUT ${outfile}
+- COMMAND ${Qt5Core_RCC_EXECUTABLE}
++ COMMAND ${MOC_LOC}
+ ARGS ${rcc_options} --name ${outfilename} --output ${outfile} ${infile}
+ MAIN_DEPENDENCY ${infile}
+ DEPENDS ${_rc_depends} "${out_depends}" VERBATIM)
+diff --git a/src/widgets/Qt5WidgetsMacros.cmake b/src/widgets/Qt5WidgetsMacros.cmake
+index 737371a5ad..d103278cdf 100644
+--- a/src/widgets/Qt5WidgetsMacros.cmake
++++ b/src/widgets/Qt5WidgetsMacros.cmake
+@@ -55,8 +55,9 @@ function(QT5_WRAP_UI outfiles )
+ get_filename_component(outfile ${it} NAME_WE)
+ get_filename_component(infile ${it} ABSOLUTE)
+ set(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
++ get_target_property(UIC_LOC ${Qt5Widgets_UIC_EXECUTABLE} IMPORTED_LOCATION)
+ add_custom_command(OUTPUT ${outfile}
+- COMMAND ${Qt5Widgets_UIC_EXECUTABLE}
++ COMMAND ${UIC_LOC}
+ ARGS ${ui_options} -o ${outfile} ${infile}
+ MAIN_DEPENDENCY ${infile} VERBATIM)
+ set_source_files_properties(${infile} PROPERTIES SKIP_AUTOUIC ON)
+--
+2.16.1
+
diff --git a/0027-Ignore-errors-about-missing-feature-static.patch b/0027-Ignore-errors-about-missing-feature-static.patch
new file mode 100644
index 000000000000..2c7ef03220dd
--- /dev/null
+++ b/0027-Ignore-errors-about-missing-feature-static.patch
@@ -0,0 +1,36 @@
+From 98d20d4f7bdf5a8b364dbfbccfd17caa12092feb Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Wed, 25 Jan 2017 20:59:54 +0100
+Subject: [PATCH 27/32] Ignore errors about missing feature static
+
+Not sure why this error occurs, let's hope for the best
+---
+ mkspecs/features/qt_build_config.prf | 2 +-
+ mkspecs/features/qt_functions.prf | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/mkspecs/features/qt_build_config.prf b/mkspecs/features/qt_build_config.prf
+index 76e1d15319..9a1c5cd8b6 100644
+--- a/mkspecs/features/qt_build_config.prf
++++ b/mkspecs/features/qt_build_config.prf
+@@ -138,5 +138,5 @@ defineTest(qtConfig) {
+ contains(QT.$${module}.disabled_features, $$1): \
+ return(false)
+ }
+- error("Could not find feature $${1}.")
++ !equals($$1, "static"): error("Could not find feature $${1}.")
+ }
+diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf
+index 1903e509c8..1fcb597fa3 100644
+--- a/mkspecs/features/qt_functions.prf
++++ b/mkspecs/features/qt_functions.prf
+@@ -348,5 +348,5 @@ defineTest(qtConfig) {
+ contains(QT.$${module}.disabled_features, $$1): \
+ return(false)
+ }
+- error("Could not find feature $${1}.")
++ !equals($$1, "static"): error("Could not find feature $${1}.")
+ }
+--
+2.16.1
+
diff --git a/0028-Enable-and-fix-use-of-iconv.patch b/0028-Enable-and-fix-use-of-iconv.patch
new file mode 100644
index 000000000000..3ad2c176f785
--- /dev/null
+++ b/0028-Enable-and-fix-use-of-iconv.patch
@@ -0,0 +1,83 @@
+From d7e459560199395f4ee339490ca5afebb7b5168a Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Wed, 25 Jan 2017 21:08:20 +0100
+Subject: [PATCH 28/32] Enable and fix use of iconv
+
+Change-Id: I5f0ab27afca0800dec11c7af74d196190820ae5c
+---
+ config.tests/gnu-libiconv/gnu-libiconv.cpp | 2 +-
+ src/corelib/codecs/qiconvcodec.cpp | 7 +++----
+ src/corelib/configure.json | 4 ++--
+ 3 files changed, 6 insertions(+), 7 deletions(-)
+
+diff --git a/config.tests/gnu-libiconv/gnu-libiconv.cpp b/config.tests/gnu-libiconv/gnu-libiconv.cpp
+index fe4b87b923..be4236436f 100644
+--- a/config.tests/gnu-libiconv/gnu-libiconv.cpp
++++ b/config.tests/gnu-libiconv/gnu-libiconv.cpp
+@@ -43,7 +43,7 @@ int main(int, char **)
+ {
+ iconv_t x = iconv_open("", "");
+
+- const char *inp;
++ char *inp;
+ char *outp;
+ size_t inbytes, outbytes;
+ iconv(x, &inp, &inbytes, &outp, &outbytes);
+diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp
+index d6362b6fbc..4da4546a24 100644
+--- a/src/corelib/codecs/qiconvcodec.cpp
++++ b/src/corelib/codecs/qiconvcodec.cpp
+@@ -49,7 +49,6 @@ QT_REQUIRE_CONFIG(iconv);
+ #include <errno.h>
+ #include <locale.h>
+ #include <stdio.h>
+-#include <dlfcn.h>
+
+ // unistd.h is needed for the _XOPEN_UNIX macro
+ #include <unistd.h>
+@@ -182,7 +181,7 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState
+ IconvState *state = *pstate;
+ size_t inBytesLeft = len;
+ // best case assumption, each byte is converted into one UTF-16 character, plus 2 bytes for the BOM
+-#if !QT_CONFIG(posix_libiconv)
++#if !QT_CONFIG(posix_libiconv) && !defined(Q_OS_WIN)
+ // GNU doesn't disagree with POSIX :/
+ const char *inBytes = chars;
+ #else
+@@ -281,7 +280,7 @@ static bool setByteOrder(iconv_t cd)
+ size_t outBytesLeft = sizeof buf;
+ size_t inBytesLeft = sizeof bom;
+
+-#if !QT_CONFIG(posix_libiconv)
++#if !QT_CONFIG(posix_libiconv) && !defined(Q_OS_WIN)
+ const char **inBytesPtr = const_cast<const char **>(&inBytes);
+ #else
+ char **inBytesPtr = &inBytes;
+@@ -303,7 +302,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
+ char *outBytes;
+ size_t inBytesLeft;
+
+-#if !QT_CONFIG(posix_libiconv)
++#if !QT_CONFIG(posix_libiconv) && !defined(Q_OS_WIN)
+ const char **inBytesPtr = const_cast<const char **>(&inBytes);
+ #else
+ char **inBytesPtr = &inBytes;
+diff --git a/src/corelib/configure.json b/src/corelib/configure.json
+index 8cd73d6ce4..dd259157e3 100644
+--- a/src/corelib/configure.json
++++ b/src/corelib/configure.json
+@@ -521,9 +521,9 @@
+ },
+ "gnu-libiconv": {
+ "label": "GNU iconv",
+- "enable": "input.iconv == 'gnu'",
++ "enable": "'enabling via -gnu-iconv fails' == 'enabling via -gnu-iconv fails'",
+ "disable": "input.iconv == 'posix' || input.iconv == 'sun' || input.iconv == 'no'",
+- "condition": "!config.win32 && !config.qnx && !config.android && !config.darwin && !features.posix-libiconv && !features.sun-libiconv && libs.gnu_iconv",
++ "condition": "!config.qnx && !config.android && !config.darwin && !features.posix-libiconv && !features.sun-libiconv && libs.gnu_iconv",
+ "output": [ "privateFeature" ]
+ },
+ "icu": {
+--
+2.16.1
+
diff --git a/0029-Ignore-failing-pkg-config-test.patch b/0029-Ignore-failing-pkg-config-test.patch
new file mode 100644
index 000000000000..16250b8d137d
--- /dev/null
+++ b/0029-Ignore-failing-pkg-config-test.patch
@@ -0,0 +1,25 @@
+From 519d6c020b8daa90bd64b4556f603c657cd30594 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Wed, 25 Jan 2017 21:08:48 +0100
+Subject: [PATCH 29/32] Ignore failing pkg-config test
+
+Didn't investigate why it fails, let's hope for the best
+---
+ configure.json | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/configure.json b/configure.json
+index 7e0b7ffb56..0f098e7b3f 100644
+--- a/configure.json
++++ b/configure.json
+@@ -725,7 +725,6 @@
+ "pkg-config": {
+ "label": "Using pkg-config",
+ "autoDetect": "!config.darwin && !config.win32",
+- "condition": "tests.pkg-config",
+ "output": [
+ "publicFeature",
+ { "type": "publicQtConfig", "negative": true },
+--
+2.16.1
+
diff --git a/0030-Prevent-qmake-from-messing-static-lib-dependencies.patch b/0030-Prevent-qmake-from-messing-static-lib-dependencies.patch
new file mode 100644
index 000000000000..33aee858ed8f
--- /dev/null
+++ b/0030-Prevent-qmake-from-messing-static-lib-dependencies.patch
@@ -0,0 +1,43 @@
+From 8f96fb6b8b9ebeb7643cbab4420bef214b617aae Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Tue, 7 Feb 2017 18:25:28 +0100
+Subject: [PATCH 30/32] Prevent qmake from messing static lib dependencies
+
+In particular, it messes resolving cyclic dependency between
+static freetype2 and harfbuzz
+---
+ qmake/generators/unix/unixmake.cpp | 3 +++
+ qmake/generators/win32/winmakefile.cpp | 3 +++
+ 2 files changed, 6 insertions(+)
+
+diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp
+index 30f99174f8..154edd67d4 100644
+--- a/qmake/generators/unix/unixmake.cpp
++++ b/qmake/generators/unix/unixmake.cpp
+@@ -414,6 +414,9 @@ UnixMakefileGenerator::fixLibFlag(const ProString &lib)
+ bool
+ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
+ {
++ if(project->isActiveConfig("staticlib")) {
++ return false; // prevent qmake from messing static lib dependencies
++ }
+ QList<QMakeLocalFileName> libdirs, frameworkdirs;
+ int libidx = 0, fwidx = 0;
+ for (const ProString &dlib : project->values("QMAKE_DEFAULT_LIBDIRS"))
+diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
+index 2e6d5d94a9..a8320bae09 100644
+--- a/qmake/generators/win32/winmakefile.cpp
++++ b/qmake/generators/win32/winmakefile.cpp
+@@ -87,6 +87,9 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
+ impexts.append(project->values("QMAKE_EXTENSION_IMPORTLIB"));
+ impexts.append(project->values("QMAKE_EXTENSION_STATICLIB"));
+ }
++ if(project->isActiveConfig("staticlib")) {
++ return false; // prevent qmake from messing static lib dependencies
++ }
+ QList<QMakeLocalFileName> dirs;
+ static const char * const lflags[] = { "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", 0 };
+ for (int i = 0; lflags[i]; i++) {
+--
+2.16.1
+
diff --git a/0031-Hardcode-linker-flags-for-platform-plugins.patch b/0031-Hardcode-linker-flags-for-platform-plugins.patch
new file mode 100644
index 000000000000..807a40e7441f
--- /dev/null
+++ b/0031-Hardcode-linker-flags-for-platform-plugins.patch
@@ -0,0 +1,110 @@
+From 299bb52899d3970ff33698305e4de8ae3ac26dae Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Wed, 25 Jan 2017 23:42:30 +0100
+Subject: [PATCH 31/32] Hardcode linker flags for platform plugins
+
+Otherwise incorrect order of libs leads to errors
+when building libqminimal.dll, libqoffscreen.dll
+and libqwindows.dll
+---
+ src/plugins/platforms/minimal/minimal.pro | 15 +++++++++++--
+ src/plugins/platforms/offscreen/offscreen.pro | 14 ++++++++++--
+ src/plugins/platforms/windows/windows.pro | 32 +++++++++++++++++++--------
+ 3 files changed, 48 insertions(+), 13 deletions(-)
+
+diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro
+index 8cfb68824e..46834a71fc 100644
+--- a/src/plugins/platforms/minimal/minimal.pro
++++ b/src/plugins/platforms/minimal/minimal.pro
+@@ -1,8 +1,19 @@
+ TARGET = qminimal
+
+ QT += \
+- core-private gui-private \
+- eventdispatcher_support-private fontdatabase_support-private
++ core-private gui-private
++
++# Fix linker error when building libqminimal.dll by specifying linker flags for
++# required modules manually (otherwise order is messed)
++LIBS += \
++ -lQt5EventDispatcherSupport \
++ -lQt5FontDatabaseSupport \
++ -lfreetype -lole32 -lgdi32 -luuid
++# However, this workaround leads to the necessity of specifying include dirs manually
++INCLUDEPATH += \
++ $$QT_SOURCE_TREE/include/QtEventDispatcherSupport/$${QT_VERSION} \
++ $$QT_SOURCE_TREE/include/QtFontDatabaseSupport/$${QT_VERSION}
++
+
+ DEFINES += QT_NO_FOREACH
+
+diff --git a/src/plugins/platforms/offscreen/offscreen.pro b/src/plugins/platforms/offscreen/offscreen.pro
+index 6652cefd86..a322b17cc5 100644
+--- a/src/plugins/platforms/offscreen/offscreen.pro
++++ b/src/plugins/platforms/offscreen/offscreen.pro
+@@ -1,8 +1,18 @@
+ TARGET = qoffscreen
+
+ QT += \
+- core-private gui-private \
+- eventdispatcher_support-private fontdatabase_support-private
++ core-private gui-private
++
++# Fix linker error when building libqoffscreen.dll by specifying linker flags for
++# required modules manually (otherwise order is messed)
++LIBS += \
++ -lQt5EventDispatcherSupport \
++ -lQt5FontDatabaseSupport \
++ -lfreetype -lole32 -lgdi32 -luuid
++# However, this workaround leads to the necessity of specifying include dirs manually
++INCLUDEPATH += \
++ $$QT_SOURCE_TREE/include/QtEventDispatcherSupport/$${QT_VERSION} \
++ $$QT_SOURCE_TREE/include/QtFontDatabaseSupport/$${QT_VERSION}
+
+ DEFINES += QT_NO_FOREACH
+
+diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro
+index 174bc7b609..e66488e364 100644
+--- a/src/plugins/platforms/windows/windows.pro
++++ b/src/plugins/platforms/windows/windows.pro
+@@ -1,14 +1,28 @@
+ TARGET = qwindows
+
+-QT += \
+- core-private gui-private \
+- eventdispatcher_support-private \
+- fontdatabase_support-private theme_support-private
+-
+-qtConfig(accessibility): QT += accessibility_support-private
+-qtConfig(vulkan): QT += vulkan_support-private
+-
+-LIBS += -lgdi32 -ldwmapi
++QT += core-private gui-private
++
++# Fix linker error when building libqwindows.dll by specifying linker flags for
++# required modules manually (otherwise order is messed)
++LIBS += \
++ -lQt5EventDispatcherSupport \
++ -lQt5FontDatabaseSupport \
++ -lQt5ThemeSupport \
++ -lfreetype -lole32 -lgdi32 -ldwmapi
++# However, this workaround leads to the necessity of specifying include dirs manually
++INCLUDEPATH += \
++ $$QT_SOURCE_TREE/include/QtEventDispatcherSupport/$${QT_VERSION} \
++ $$QT_SOURCE_TREE/include/QtFontDatabaseSupport/$${QT_VERSION} \
++ $$QT_SOURCE_TREE/include/QtThemeSupport/$${QT_VERSION}
++# Same for private support libs for accessibility and vulkan, if those are enabled
++qtConfig(accessibility) {
++ LIBS += -lQt5AccessibilitySupport
++ INCLUDEPATH += $$QT_SOURCE_TREE/include/QtAccessibilitySupport/$${QT_VERSION}
++}
++qtConfig(vulkan) {
++ LIBS += -lQt5VulkanSupport
++ INCLUDEPATH += $$QT_SOURCE_TREE/include/QtVulkanSupport/$${QT_VERSION}
++}
+
+ include(windows.pri)
+
+--
+2.16.1
+
diff --git a/0032-Fix-linking-against-static-plugins-with-qmake.patch b/0032-Fix-linking-against-static-plugins-with-qmake.patch
new file mode 100644
index 000000000000..6b7b9f0df8c1
--- /dev/null
+++ b/0032-Fix-linking-against-static-plugins-with-qmake.patch
@@ -0,0 +1,37 @@
+From 715c87c76624306c9b9410dc4efa7b6d64ca6788 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Fri, 25 Aug 2017 17:07:17 +0200
+Subject: [PATCH 32/32] Fix linking against static plugins with qmake
+
+Required because qtConfig(static) does not work
+with 'Merge shared and static library trees'
+approach
+---
+ mkspecs/features/qt.prf | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf
+index 6eebd068f1..310b8713f0 100644
+--- a/mkspecs/features/qt.prf
++++ b/mkspecs/features/qt.prf
+@@ -69,7 +69,7 @@ all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_d
+
+ QTPLUGIN = $$unique($$list($$lower($$QTPLUGIN)))
+
+-import_plugins:qtConfig(static) {
++import_plugins:static {
+ manualplugs = $$QTPLUGIN # User may specify plugins. Mostly legacy.
+ autoplugs = # Auto-added plugins.
+ # First round: explicitly specified modules.
+@@ -139,7 +139,7 @@ import_plugins:qtConfig(static) {
+ }
+
+ # Only link against plugins in static builds
+-!isEmpty(QTPLUGIN):qtConfig(static) {
++!isEmpty(QTPLUGIN):static {
+ for (plug, QTPLUGIN) {
+ # Check if the plugin is known to Qt. We can use this to determine
+ # the plugin path. Unknown plugins must rely on the default link path.
+--
+2.16.1
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..dc0b5dc301b7
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,438 @@
+# Maintainer: Martchus <martchus@gmx.net>
+# Contributor: ant32 <antreimer@gmail.com>
+# Contributor: Filip Brcic <brcha@gna.org>
+# Contributor: jellysheep <max.mail@dameweb.de>
+
+# All my PKGBUILDs are managed at https://github.com/Martchus/PKGBUILDs where
+# you also find the URL of a binary repository.
+
+# All patches are managed at https://github.com/Martchus/qtbase
+
+# There are different variants of the package which can be selected by simply adjusting pkgname:
+# - mingw-w64-qt5-base or mingw-w64-qt5-base-opengl: using native OpenGL
+# - mingw-w64-qt5-base-angle: using ANGLE rather than native OpenGL
+# - mingw-w64-qt5-base-dynamic: allows choosing between ANGLE and native OpenGL dynamically at runtime
+# - mingw-w64-qt5-base-noopenql: no OpenGL support
+# The variants are conflicting (and hence can not be installed at the same time).
+# See also: http://doc.qt.io/qt-5/windows-requirements.html#dynamically-loading-graphics-drivers
+
+# The variants listed above only contain dynamic libraries. For building static libraries
+# just append '-static' to the package name, eg. mingw-w64-qt5-base-static or mingw-w64-qt5-base-angle-static.
+# The static variants rely on the corresponding dynamic variant for headers and tools.
+# I only tested the static variant using native OpenGL so far (mingw-w64-qt5-base-static).
+# Note that ANGLE will still be loaded as dynamic library in mingw-w64-qt5-base-dynamic-static.
+
+# By default CMake and qmake will link against the dynamic Qt libraries.
+
+# To use the static Qt libraries with CMake prepend the Qt module name with Static:
+# eg. find_package(Qt5Core) becomes find_package(StaticQt5Core)
+# To use a static module, add the corresponding imported target, eg.
+# target_link_libraries(target ... StaticQt5::Core)
+# and using
+# This approach allows installing dynamic and static Qt in the same prefix
+# and using both variants in the same CMake project.
+
+# To use a static plugin, add the corresponding imported target, eg.
+# target_link_libraries(target ... StaticQt5::QWindowsIntegrationPlugin)
+# Automatically importing static plugins is currently not possible, though. Hence it is required to use Q_IMPORT_PLUGIN, eg.
+# #include<QtPlugin>
+# Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
+
+# It is also possible to use static Qt libraries with CMake by setting the
+# variable USE_STATIC_QT_BY_DEFAULT: set(USE_STATIC_QT_BY_DEFAULT ON)
+# In this case the regular imported targets (eg. Qt5::Core) will be static.
+# This approach does *not* allow to use dynamic and static Qt in the same
+# CMake project.
+
+# To use the static Qt libraries with qmake add 'static' to the project config (either inside the *.pro file or as qmake argument):
+# CONFIG+=static
+
+# Further Qt modules (those not found in the base repository and hence not included in this package) include by default
+# static and dynamic libraries; if only one version is requried, just set NO_STATIC_LIBS or NO_SHARED_LIBS when building
+# the package, eg. by adding 'NO_STATIC_LIBS=1' to /etc/makepkg.conf.
+
+# By default, executables will not be removed because I find them useful when testing. To remove executables
+# set NO_EXECUTABLES (or NO_STATIC_EXECUTABLES to remove statically linked executables only) when building the package.
+# If Qt modules containing tools are built as static and as dynamic library only the dynamically linked tools will be present
+# in the package.
+
+# Qt packages can be built in the following order (for example):
+# qt5-base qt5-base-static qt5-declarative qt5-tools qt5-xmlpatterns qt5-script qt5-location qt5-multimedia qt5-sensors qt5-webchannel qt5-3d qt5-imageformats qt5-quickcontrols qt5-quickcontrols2 qt5-translations qt5-svg qt5-websockets qt5-winextras qt5-serialport qt5-canvas3d qt5-connectivity qt5-charts qt5-gamepad qt5-scxml qt5-datavis3s qt5-virtualkeyboard qt5-activeqt qt5-webkit
+
+# Helper functions for the split builds
+isDefault() {
+ [[ $pkgname = 'mingw-w64-qt5-base' ]] || [[ $pkgname = 'mingw-w64-qt5-base-static' ]]
+}
+isStatic() {
+ [ "${pkgname##*-}" = 'static' ]
+}
+isOpenGL() {
+ # Currently use native OpenGL by default
+ isDefault || \
+ [[ $pkgname = 'mingw-w64-qt5-base-opengl' ]] || [[ $pkgname = 'mingw-w64-qt5-base-opengl-static' ]]
+}
+isANGLE() {
+ [[ $pkgname = 'mingw-w64-qt5-base-angle' ]] || [[ $pkgname = 'mingw-w64-qt5-base-angle-static' ]] || \
+ [[ $pkgname = 'mingw-w64-qt5-base-dynamic' ]] || [[ $pkgname = 'mingw-w64-qt5-base-dynamic-static' ]]
+ # Treat dynamic version like ANGLE version, correct?
+}
+isDynamic() {
+ [[ $pkgname = 'mingw-w64-qt5-base-dynamic' ]] || [[ $pkgname = 'mingw-w64-qt5-base-dynamic-static' ]]
+}
+isNoOpenGL() {
+ [[ $pkgname = 'mingw-w64-qt5-base-noopengl' ]] || [[ $pkgname = 'mingw-w64-qt5-base-noopengl-static' ]]
+}
+
+pkgname=mingw-w64-qt5-base-nostatx
+pkgver=5.10.1
+pkgrel=1
+pkgdesc='A cross-platform application and UI framework (mingw-w64)'
+# The static variant doesn't contain any executables which need to be executed on the build machine
+isStatic && arch=('any') || arch=('i686' 'x86_64')
+url='https://www.qt.io/'
+license=('GPL3' 'LGPL3' 'FDL' 'custom')
+depends=('mingw-w64-crt' 'mingw-w64-zlib' 'mingw-w64-libjpeg-turbo' 'mingw-w64-sqlite'
+ 'mingw-w64-libpng' 'mingw-w64-openssl' 'mingw-w64-dbus' 'mingw-w64-harfbuzz'
+ 'mingw-w64-pcre2')
+groups=('mingw-w64-qt5')
+optdepends=('mingw-w64-postgresql: PostgreSQL support' 'mingw-w64-mariadb-connector-c: MySQL support')
+makedepends=('mingw-w64-gcc' 'mingw-w64-postgresql' 'mingw-w64-mariadb-connector-c' 'mingw-w64-pkg-config')
+options=('!strip' '!buildflags' 'staticlibs' '!emptydirs')
+_pkgfqn="qtbase-everywhere-src-${pkgver}"
+source=("https://download.qt.io/official_releases/qt/${pkgver%.*}/${pkgver}/submodules/${_pkgfqn}.tar.xz"
+ '0001-Add-profile-for-cross-compilation-with-mingw-w64.patch'
+ '0002-Ensure-GLdouble-is-defined-when-using-dynamic-OpenGL.patch'
+ '0003-Use-external-ANGLE-library.patch'
+ '0004-Fix-too-many-sections-assemler-error-in-OpenGL-facto.patch'
+ '0005-Make-sure-.pc-files-are-installed-correctly.patch'
+ '0006-Don-t-add-resource-files-to-LIBS-parameter.patch'
+ '0007-Prevent-debug-library-names-in-pkg-config-files.patch'
+ '0008-Fix-linking-against-shared-static-libpng.patch'
+ '0009-Fix-linking-against-static-D-Bus.patch'
+ '0010-Don-t-try-to-use-debug-version-of-D-Bus-library.patch'
+ '0011-Fix-linking-against-static-freetype2.patch'
+ '0012-Fix-linking-against-static-harfbuzz.patch'
+ '0013-Fix-linking-against-static-pcre.patch'
+ '0014-Fix-linking-against-shared-static-MariaDB.patch'
+ '0015-Fix-linking-against-shared-static-PostgreSQL.patch'
+ '0016-Rename-qtmain-to-qt5main.patch'
+ '0017-Build-dynamic-host-libraries.patch'
+ '0018-Enable-rpath-for-build-tools.patch'
+ '0019-Use-system-zlib-for-build-tools.patch'
+ '0020-Use-.dll.a-as-import-lib-extension.patch'
+ '0021-Merge-shared-and-static-library-trees.patch'
+ '0022-Pull-dependencies-of-static-libraries-in-CMake-modul.patch'
+ '0023-Allow-usage-of-static-version-with-CMake.patch'
+ '0024-Adjust-linker-flags-for-static-build-with-cmake-ming.patch'
+ '0025-Use-correct-pkg-config-static-flag.patch'
+ '0026-Fix-macro-invoking-moc-rcc-and-uic.patch'
+ '0027-Ignore-errors-about-missing-feature-static.patch'
+ '0028-Enable-and-fix-use-of-iconv.patch'
+ '0029-Ignore-failing-pkg-config-test.patch'
+ '0030-Prevent-qmake-from-messing-static-lib-dependencies.patch'
+ '0031-Hardcode-linker-flags-for-platform-plugins.patch'
+ '0032-Fix-linking-against-static-plugins-with-qmake.patch'
+ qt-no-statx.patch
+)
+sha256sums=('d8660e189caa5da5142d5894d328b61a4d3ee9750b76d61ad74e4eee8765a969'
+ '6b29d7a3751a506c15155425d6dc213e9f4654ee5b833007a0119bda6a050b28'
+ 'ca10438f4a2d309f496e85d7b974d9eeb88115e068e146ca511b9784db95b822'
+ '75bf0d8b155f95bad2dfbc5c046f88afd6a5f2233336a1f6d148583ba445fca6'
+ 'd70dcd1c44e751b0120f514af9db4ff20ebb0a327a22a371cf5e8d9453f66953'
+ 'cbad834340bc9e9261704034e9192bd0d7306f9ff02a99fd73fc348948c37ed9'
+ '3c7cd1839a6f0891b871c75824b8ebeb05e4e61884c342d6b6ab583f10819138'
+ 'c923da99871dac4fc58b8e70bd76c70fba0f421fc676a53bcb8c0187190ba737'
+ 'f9be656281652f72297f1e573f23298c22f4849857d92106096feb4b3fe9244f'
+ '5add111a9e521159e31ecef4d85ebef86285bbbe2adce5d8cec94fd22822731e'
+ '7d38e79bc6b2e5d74515291bf78c3a6168f8bc834f7f59bda2c013f65e45bd3e'
+ '9ab62cc8cd1cf68ee5e87e276d5a2f19c43b04a1c50c10341794924277cfcca5'
+ 'f1926bd51376a95ea1deee933dadd62166296e5780e24ce8312637c9d3eda27b'
+ '03f7a178af6b630f48da79c76e1239695d96137fd8394ba814e4bdf8c7e0a826'
+ 'dc3e0e3fe4ba979f74ff9dc343b235d32473edb18ca7f8afea3076f613564a95'
+ 'ef64b965a19e1e2848761829a6817dcb9f3ad616faa666f9e52736d810190c66'
+ '9e0c3848df586ec7decd9b7a6dab86a9e7e5cc7bf5ac06ff97d7d63e370bb05b'
+ '7dc90045a838f9ebcb7933d582abb3e8bba250644602e1019bf1a03e74cc3b09'
+ 'b5cc23a29e80ec8185da8ca0950ab8a2f12f4ef4b998c763334d352e68b53fc2'
+ '944cfdbfd9d13285aefb4305596950d2880cc1023b5ad241af08e3d6995daa69'
+ '5f7498a98912542c39b081c2df1930246df3bdb533c2e30204bf795cea8b885f'
+ '0b8408d70a4544e43fd573e5b9ac751fb2732d3e4490f21e1737ac09ece25b62'
+ '08155a41f22c03741096145bf201d5503e38495c2f255f3c81ea658948258cd3'
+ '7b30d46f739dffa20a1964e09958a92af1749104fe7a88d7ea255aa54e553b25'
+ 'c92d6a124b7b0333175122555ef9f647817eb54563480cf3eaaf47decfd907c3'
+ '0818c4d59aabb898fed8f313e21085cc8fc576d3f4975383eb73ba3f758c302e'
+ 'ce5d416a3404199072062063d8038084c23bbfe8aa45ed3340c4afb4dfa461e4'
+ '8d1e93bea1cdcdf1b965f4c061975668334cef6a65130f1b4b528f2b6952a602'
+ '298ffdcd378e2b07fe8e978cfb5faac29c117a5f79288273545a6938b905f33a'
+ '7514edba8ecd28b27715650bbafa8649492b68efba1df9c9fa70f06a924fea14'
+ '7c232c385303b447e17270b946d333b56274312b08b4e76439a5f77cb77aa909'
+ 'acfdf70ae8738a0373bbd93e42048d1c699f666dd72933ad3c09b09620fb0715'
+ 'c3df40da9b2494e59aae786a26ba93d88128b69971d10a64cb6d610045a101f8'
+ 'fb4c2d464cd7c3fbd1bf488cf694dcfdc6cb515a8d7ddb9b41d9b6bef5da3be2')
+
+_architectures='i686-w64-mingw32 x86_64-w64-mingw32'
+
+isStatic && depends+=(${pkgname%-static})
+if isANGLE; then
+ if isDynamic; then
+ makedepends+=('mingw-w64-angleproject')
+ optdepends+=('mingw-w64-angleproject: use ANGLE instead of native OpenGL')
+ else
+ depends+=('mingw-w64-angleproject')
+ fi
+fi
+if ! isDefault; then
+ if isStatic; then
+ provides+=('mingw-w64-qt5-base-static')
+ conflicts+=('mingw-w64-qt5-base-static' 'mingw-w64-qt5-base-angle-static' 'mingw-w64-qt5-base-noopengl-static'
+ 'mingw-w64-qt5-base-dynamic-static' 'mingw-w64-qt5-base-openql-static')
+ else
+ provides+=('mingw-w64-qt5-base')
+ conflicts+=('mingw-w64-qt5-base' 'mingw-w64-qt5-base-angle' 'mingw-w64-qt5-base-noopengl'
+ 'mingw-w64-qt5-base-dynamic' 'mingw-w64-qt5-base-openql')
+ fi
+fi
+
+patch() {
+ local input_found=
+ local patch_file=
+ for arg in $@; do
+ if [[ $input_found ]]; then
+ patch_file="$arg"
+ break
+ fi
+ [[ $arg == -i ]] && input_found=1
+ done
+ msg2 "Applying patch $patch_file"
+ /usr/bin/patch $@
+}
+
+prepare() {
+ cd "${srcdir}/${_pkgfqn}"
+
+ # Apply patches; further descriptions can be found in patch files itself
+ for patch in "$srcdir/"*.patch; do
+ patch -p1 -i "$patch"
+ done
+
+ # Make sure the Qt5 build system uses our external ANGLE library
+ rm -rf src/3rdparty/angle include/QtANGLE/{EGL,GLES2,GLES3,KHR}
+
+ # As well as our external PCRE library and zlib
+ rm -rf src/3rdparty/{pcre,zlib}
+}
+
+build() {
+ cd "${srcdir}/${_pkgfqn}"
+
+ # Do not set any flags here, flags are configured via mkspec
+ # Setting flags here is not appropriate as it does not allow to
+ # distinguish between flags for native compiler and cross compiler
+ unset CFLAGS
+ unset CXXFLAGS
+ unset LDFLAGS
+ unset PKG_CONFIG_PATH
+
+ for _arch in ${_architectures}; do
+ # To prevent conflicts with the mingw-w64-qt4 package we have
+ # to put tools in a dedicated folder
+
+ # The last device option allows using ccache despite the use of
+ # pre-compile header
+ # (sloppiness must be set to pch_defines,time_macros in ccache config)
+
+ local qt_configure_args="\
+ -xplatform mingw-w64-g++ \
+ -optimized-qmake \
+ -verbose \
+ -opensource \
+ -confirm-license \
+ -force-pkg-config \
+ -force-debug-info \
+ -system-zlib \
+ -system-libpng \
+ -system-libjpeg \
+ -system-sqlite \
+ -system-freetype \
+ -system-harfbuzz \
+ -system-pcre \
+ -no-fontconfig \
+ -sql-mysql \
+ -sql-psql \
+ -sql-sqlite \
+ -dbus-linked \
+ -no-glib \
+ -no-icu \
+ -iconv \
+ -nomake examples \
+ -make tools \
+ -hostprefix /usr/${_arch} \
+ -hostdatadir /usr/${_arch}/lib/qt \
+ -hostbindir /usr/${_arch}/lib/qt/bin \
+ -prefix /usr/${_arch} \
+ -bindir /usr/${_arch}/bin \
+ -archdatadir /usr/${_arch}/lib/qt \
+ -datadir /usr/${_arch}/share/qt \
+ -docdir /usr/${_arch}/share/doc/qt \
+ -examplesdir /usr/${_arch}/share/qt/examples \
+ -headerdir /usr/${_arch}/include/qt \
+ -libdir /usr/${_arch}/lib \
+ -plugindir /usr/${_arch}/lib/qt/plugins \
+ -sysconfdir /usr/${_arch}/etc \
+ -translationdir /usr/${_arch}/share/qt/translations \
+ -device-option CROSS_COMPILE=${_arch}- \
+ -device-option CROSS_COMPILE_PREFIX=/usr/${_arch} \
+ -device-option CROSS_COMPILE_CFLAGS=-fpch-preprocess"
+
+ # Fix include directory of freetype2 and dbus
+ qt_configure_args+=" $(${_arch}-pkg-config --cflags-only-I freetype2 dbus-1)"
+
+ # Enable debug build if MINGW_W64_QT_DEBUG_BUILD is set (in /etc/makepkg.config)
+ [[ $MINGW_W64_QT_DEBUG_BUILD ]] \
+ && qt_configure_args+=' -debug-and-release' \
+ || qt_configure_args+=' -release'
+
+ # Configure usage of ANGLE/OpenGL
+ if isOpenGL; then
+ msg2 'Using native OpenGL backend'
+ qt_configure_args+=' -opengl desktop'
+ elif isNoOpenGL; then
+ msg2 'Building without OpenGL support'
+ qt_configure_args+=' -no-opengl'
+ elif isANGLE; then
+ if isDynamic; then
+ msg2 'Using dynamic OpenGL backend'
+ qt_configure_args+=' -opengl dynamic'
+ else
+ msg2 'Using ANGLE as OpenGL backend'
+ qt_configure_args+=' -angle'
+ fi
+ # GL_GLEXT_PROTOTYPES must be defined to enable declarations of GLES functions
+ qt_configure_args+=' -DGL_GLEXT_PROTOTYPES'
+ fi
+
+ # Fix MariaDB
+ qt_configure_args+=" -I/usr/${_arch}/include/mariadb"
+
+ msg2 'Configure and build qmake'
+ mkdir -p ../build-${_arch} && pushd ../build-${_arch}
+ if isStatic; then
+ export OPENSSL_LIBS="/usr/${_arch}/lib/libssl.a /usr/${_arch}/lib/libcrypto.a -lws2_32 -lgdi32 -lcrypt32"
+ ../${_pkgfqn}/configure \
+ $qt_configure_args \
+ -static \
+ -openssl-linked
+ msg2 'Build static Qt libraries'
+ make
+ else
+ # The LD_LIBRARY_PATH override is needed because libQt5Bootstrap* are shared
+ # libraries which various compiled tools (like moc) use. As the libQt5Bootstrap*
+ # libraries aren't installed at this point yet, we have to workaround this
+ ../${_pkgfqn}/configure \
+ $qt_configure_args \
+ -shared \
+ -openssl-runtime \
+ -device-option 'CROSS_COMPILE_CUSTOM_CONFIG=actually_a_shared_build'
+ msg2 'Build shared Qt libraries'
+ LD_LIBRARY_PATH="$PWD/lib" LDFLAGS="-L$PWD/lib" make
+ fi
+ popd
+ done
+}
+
+package() {
+ for _arch in ${_architectures}; do
+ cd "$srcdir/${_pkgfqn}"
+ make install -C ../build-${_arch} INSTALL_ROOT="${pkgdir}"
+
+ # Use prl files from build directory since installed prl files seem to have incorrect QMAKE_PRL_LIBS_FOR_CMAKE
+ pushd "$srcdir/build-${_arch}/lib"
+ find -iname '*.static.prl' -exec cp --target-directory "${pkgdir}/usr/${_arch}/lib" --parents {} +
+ popd
+ pushd "$srcdir/build-${_arch}/plugins"
+ find -iname '*.static.prl' -exec cp --target-directory "${pkgdir}/usr/${_arch}/lib/qt/plugins" --parents {} +
+ popd
+
+ if isStatic; then
+ # The static release contains only the static libs itself but relies on the
+ # shared release for Qt5Bootstrap library and tools (qmake, uic, ...)
+
+ # Drop Qt5Bootstrap and libraries which are only provided as static lib
+ # and are hence already present in shared build (such as Qt5OpenGLExtensions)
+ rm -f \
+ "${pkgdir}/usr/${_arch}/lib/"{lib,}qt5main* \
+ "${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5AccessibilitySupport* \
+ "${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5DeviceDiscoverySupport* \
+ "${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5EdidSupport* \
+ "${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5EventDispatcherSupport* \
+ "${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5FbSupport* \
+ "${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5FontDatabaseSupport* \
+ "${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5PlatformCompositorSupport* \
+ "${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5ThemeSupport* \
+ "${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5OpenGLExtensions* \
+ "${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5PlatformSupport* \
+ "${pkgdir}/usr/${_arch}/lib/"libQt5Bootstrap* \
+
+ # Also ensure config files don't conflict with shared version
+ pushd "${pkgdir}/usr/${_arch}/lib/cmake"
+ for cmake_dir in $(find . ! -path . -type d ! -name 'Static*'); do
+ mkdir -p "./Static${cmake_dir:2}";
+ mv "${cmake_dir}/"* "./Static${cmake_dir:2}";
+ rm -r "${cmake_dir}"
+ done
+ rm -r "./StaticQt5OpenGLExtensions"
+ popd
+ rm "${pkgdir}/usr/${_arch}/lib/pkgconfig/StaticQt5OpenGLExtensions.pc"
+
+ # Create links to static plugins in lib directory
+ pushd "${pkgdir}/usr/${_arch}/lib/" && ln -s "./qt/plugins/"*/*.a . && popd
+
+ # Keep a couple pri files not found in base
+ mv "${pkgdir}/usr/${_arch}/lib/qt/mkspecs/modules/qt_plugin_"*.pri "${pkgdir}/usr/${_arch}"
+
+ # Delete duplicate files that are in the base package
+ rm -fR "${pkgdir}/usr/${_arch}/"{include,share}
+ rm -fR "${pkgdir}/usr/${_arch}/lib/"{qt/bin,qt/mkspecs}
+
+ # Move pri files back
+ mkdir -p "${pkgdir}/usr/${_arch}/lib/qt/mkspecs/modules"
+ mv "${pkgdir}/usr/${_arch}/"*.pri "${pkgdir}/usr/${_arch}/lib/qt/mkspecs/modules"
+
+ else # Shared release
+ # The .dll's are installed in both bindir and libdir, one copy of the .dll's is sufficient
+ find "${pkgdir}/usr/${_arch}/lib" -maxdepth 1 -name "*.dll" -exec rm {} \;
+
+ # The Qt5OpenGLExtensions module is only available as static library and hence part of the
+ # shared build
+
+ # Create symlinks for tools
+ mkdir -p "${pkgdir}/usr/bin"
+ for tool in qmake moc rcc uic qdbuscpp2xml qdbusxml2cpp qdoc syncqt.pl; do
+ ln -s "../${_arch}/lib/qt/bin/${tool}" "${pkgdir}/usr/bin/${_arch}-${tool}-qt5"
+ done
+ fi
+
+ # Drop QMAKE_PRL_BUILD_DIR because reference the build dir
+ find "${pkgdir}/usr/${_arch}/lib" -type f -name '*.prl' -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;
+
+ # Remove doc
+ rm -rf "${pkgdir}/usr/${_arch}/share/doc"
+
+ # Strip the binaries
+ if ! isStatic; then
+ strip --strip-all "${pkgdir}/usr/${_arch}/lib/qt/bin/"*[!.pl]
+ strip --strip-unneeded "${pkgdir}/usr/${_arch}/lib/libQt5Bootstrap"{,DBus}.so.${pkgver}
+ fi
+
+ # Applications might be useful as well; keeping them by default will not hurt anybody I suppose
+ if isStatic || [[ $NO_EXECUTABLES ]]; then
+ find "${pkgdir}/usr/${_arch}" -name "*.exe" -exec rm {} \;
+ else
+ find "${pkgdir}/usr/${_arch}" -name "*.exe" -exec ${_arch}-strip --strip-all {} \;
+ fi
+ # No use for these files though
+ find "${pkgdir}/usr/${_arch}" \( -name "*.bat" -o -name "*.def" -o -name "*.exp" \) -exec rm {} \;
+ # Strip binaries
+ find "${pkgdir}/usr/${_arch}" -name "*.dll" -exec ${_arch}-strip --strip-unneeded {} \;
+ find "${pkgdir}/usr/${_arch}" -name "*.a" -exec ${_arch}-strip -g {} \;
+ done
+}
diff --git a/qt-no-statx.patch b/qt-no-statx.patch
new file mode 100644
index 000000000000..bbcb11856490
--- /dev/null
+++ b/qt-no-statx.patch
@@ -0,0 +1,24 @@
+From b47e6c6fc2f5eaf489458fcf5930015f6baf3281 Mon Sep 17 00:00:00 2001
+From: Martchus <martchus@gmx.net>
+Date: Sat, 9 Dec 2017 00:36:56 +0100
+Subject: [PATCH] Don't use the statx syscall
+
+Otherwise Qt can not be built in a systemd
+container
+---
+ src/corelib/io/qfilesystemengine_unix.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
+index 77d154c6b4..6036bae4f1 100644
+--- a/src/corelib/io/qfilesystemengine_unix.cpp
++++ b/src/corelib/io/qfilesystemengine_unix.cpp
+@@ -95,7 +95,7 @@ static int renameat2(int oldfd, const char *oldpath, int newfd, const char *newp
+ { return syscall(SYS_renameat2, oldfd, oldpath, newfd, newpath, flags); }
+ # endif
+
+-# if !QT_CONFIG(statx) && defined(SYS_statx) && QT_HAS_INCLUDE(<linux/stat.h>)
++# if 0
+ # include <linux/stat.h>
+ static int statx(int dirfd, const char *pathname, int flag, unsigned mask, struct statx *statxbuf)
+ { return syscall(SYS_statx, dirfd, pathname, flag, mask, statxbuf); }