aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO94
-rw-r--r--PKGBUILD460
-rw-r--r--qt5-add-angle-and-dynamic-support.patch75
-rw-r--r--qt5-allow-usage-of-static-qt-with-cmake.patch444
-rw-r--r--qt5-customize-extensions-for-static-build.patch15
-rw-r--r--qt5-disable-default-lib-include-detection.patch11
-rw-r--r--qt5-dont-add-resource-files-to-qmake-libs.patch11
-rw-r--r--qt5-dont-build-host-libs-static.patch19
-rw-r--r--qt5-enable-rpath-for-host-tools.patch18
-rw-r--r--qt5-fix-implib-ext.patch84
-rw-r--r--qt5-fix-linking-against-static-dbus.patch26
-rw-r--r--qt5-fix-linking-against-static-pcre.patch13
-rw-r--r--qt5-fix-opengl-to-many-sections.patch10
-rw-r--r--qt5-fix-static-psql-mysql.patch15
-rw-r--r--qt5-fixes-from-mxe.patch91
-rw-r--r--qt5-merge-static-and-shared-library-trees.patch50
-rw-r--r--qt5-pkgconfig-static-library-name-workaround.patch19
-rw-r--r--qt5-prevent-debug-library-names-in-pkgconfig-files.patch12
-rw-r--r--qt5-rename-qtmain-to-qt5main.patch35
-rw-r--r--qt5-use-correct-pkg-config-static-flags.patch14
-rw-r--r--qt5-use-external-angle-library.patch77
-rw-r--r--qt5-use-pkgconfig-for-harfbuzz.patch31
-rw-r--r--qt5-use-system-zlib-in-host-libs.patch11
-rw-r--r--qt5-use-win32-g++-mkspecs-profile.patch58
-rw-r--r--qt5-win32-static-cmake-link-ws2_32-and--static.patch15
-rw-r--r--qt5-workaround-pkgconfig-install-issue.patch46
26 files changed, 1754 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..2139a57e4ddd
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,94 @@
+# Generated by mksrcinfo v8
+# Tue Sep 6 20:39:10 UTC 2016
+pkgbase = mingw-w64-qt5-base-dynamic
+ pkgdesc = A cross-platform application and UI framework (mingw-w64)
+ pkgver = 5.7.0
+ pkgrel = 5
+ url = https://www.qt.io/
+ arch = i686
+ arch = x86_64
+ groups = mingw-w64-qt
+ groups = mingw-w64-qt5
+ license = GPL3
+ license = LGPL3
+ license = FDL
+ license = custom
+ makedepends = mingw-w64-gcc
+ makedepends = mingw-w64-postgresql-libs
+ makedepends = mingw-w64-mariadb-connector-c
+ makedepends = mingw-w64-pkg-config
+ makedepends = mingw-w64-angleproject
+ 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-pcre
+ optdepends = mingw-w64-postgresql-libs: PostgreSQL support
+ optdepends = mingw-w64-mariadb-connector-c: MySQL support
+ optdepends = qtchooser
+ optdepends = mingw-w64-angleproject: use ANGLE instead of native OpenGL
+ 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.7/5.7.0/submodules/qtbase-opensource-src-5.7.0.tar.xz
+ source = qt5-add-angle-and-dynamic-support.patch
+ source = qt5-use-external-angle-library.patch
+ source = qt5-workaround-pkgconfig-install-issue.patch
+ source = qt5-merge-static-and-shared-library-trees.patch
+ source = qt5-fix-linking-against-static-pcre.patch
+ source = qt5-rename-qtmain-to-qt5main.patch
+ source = qt5-dont-build-host-libs-static.patch
+ source = qt5-enable-rpath-for-host-tools.patch
+ source = qt5-dont-add-resource-files-to-qmake-libs.patch
+ source = qt5-prevent-debug-library-names-in-pkgconfig-files.patch
+ source = qt5-fix-linking-against-static-dbus.patch
+ source = qt5-use-win32-g++-mkspecs-profile.patch
+ source = qt5-use-system-zlib-in-host-libs.patch
+ source = qt5-fix-opengl-to-many-sections.patch
+ source = qt5-fix-static-psql-mysql.patch
+ source = qt5-fixes-from-mxe.patch
+ source = qt5-fix-implib-ext.patch
+ source = qt5-disable-default-lib-include-detection.patch
+ source = qt5-win32-static-cmake-link-ws2_32-and--static.patch
+ source = qt5-allow-usage-of-static-qt-with-cmake.patch
+ source = qt5-customize-extensions-for-static-build.patch
+ source = qt5-use-correct-pkg-config-static-flags.patch
+ source = qt5-use-pkgconfig-for-harfbuzz.patch
+ md5sums = 184f9460b40752d71b15b827260580c2
+ md5sums = 55a11d8ea5db9ca0cced06b06655b417
+ md5sums = 1f7aea5e8bed840b3efc9172081ddb45
+ md5sums = bc99c4cc6998295d76f37ed681c20d47
+ md5sums = e2ffff39673b37c4d9974e92fcf7213c
+ md5sums = 4fe6523dd1c34398df3aa5a8763530cc
+ md5sums = f32a768e1acb9785c79c8e93aa266db2
+ md5sums = 3bd322551924543553a2bf81b4419a09
+ md5sums = 30fa9ddf8d842b1392e8d63868940657
+ md5sums = 99bb9f51ec684803768f36e407baf486
+ md5sums = 6a6bc88f35ac8080869de39bc128ce5b
+ md5sums = 261d9071a6af3f1d5c3f955da3781573
+ md5sums = 0524dc5427a6c5338ebd45ab08c6ce80
+ md5sums = c15d9f480d0248648fa52aeacb46e3c7
+ md5sums = 612a4dfb9f1a3898a1920c28bb999159
+ md5sums = d0eb81aef1a21c65813fe4ddabbc4206
+ md5sums = 1e8c03872062fe8499ed7786475ed4e0
+ md5sums = 83139869355c2d46921adb25e47cf0fa
+ md5sums = b9565219e9252a17fc1b8fb9ee30662c
+ md5sums = 20de722808e8a3fb684b0212bef8de46
+ md5sums = 1dc792faa7761d8d7d2f17170da04d6b
+ md5sums = 41ec67d9e5e70e0d6d93b42aebd0e12a
+ md5sums = 61c0f9d0095c5a6dec8d14e9ec35a608
+ md5sums = 16a7d505b503bb1087fc00fad819f64b
+
+pkgname = mingw-w64-qt5-base-dynamic
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..df57a7baf394
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,460 @@
+# 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.
+
+# 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 version 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 set the following variable before calling find_package for finding a Qt module:
+# set(USE_STATIC_QT_BUILD ON)
+# To use a static plugin, add the corresponding imported target, eg.
+# target_link_libraries(target ... Qt5::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)
+
+# To use the static Qt libraries with qmake set the following variables (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.
+
+# 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).
+# However, 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-dynamic
+pkgver=5.7.0
+pkgrel=5
+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-pcre')
+groups=('mingw-w64-qt' 'mingw-w64-qt5')
+optdepends=('mingw-w64-postgresql-libs: PostgreSQL support' 'mingw-w64-mariadb-connector-c: MySQL support'
+ 'qtchooser')
+makedepends=('mingw-w64-gcc' 'mingw-w64-postgresql-libs' 'mingw-w64-mariadb-connector-c' 'mingw-w64-pkg-config')
+options=(!strip !buildflags staticlibs !emptydirs)
+_pkgfqn="qtbase-opensource-src-${pkgver}"
+source=("https://download.qt.io/official_releases/qt/${pkgver:0:3}/${pkgver}/submodules/${_pkgfqn}.tar.xz"
+ "qt5-add-angle-and-dynamic-support.patch"
+ "qt5-use-external-angle-library.patch"
+ "qt5-workaround-pkgconfig-install-issue.patch"
+ "qt5-merge-static-and-shared-library-trees.patch"
+ "qt5-fix-linking-against-static-pcre.patch"
+ "qt5-rename-qtmain-to-qt5main.patch"
+ "qt5-dont-build-host-libs-static.patch"
+ "qt5-enable-rpath-for-host-tools.patch"
+ "qt5-dont-add-resource-files-to-qmake-libs.patch"
+ "qt5-prevent-debug-library-names-in-pkgconfig-files.patch"
+ "qt5-fix-linking-against-static-dbus.patch"
+ "qt5-use-win32-g++-mkspecs-profile.patch"
+ "qt5-use-system-zlib-in-host-libs.patch"
+ "qt5-fix-opengl-to-many-sections.patch"
+ "qt5-fix-static-psql-mysql.patch"
+ "qt5-fixes-from-mxe.patch"
+ "qt5-fix-implib-ext.patch"
+ "qt5-disable-default-lib-include-detection.patch"
+ "qt5-win32-static-cmake-link-ws2_32-and--static.patch"
+ "qt5-allow-usage-of-static-qt-with-cmake.patch"
+ "qt5-customize-extensions-for-static-build.patch"
+ "qt5-use-correct-pkg-config-static-flags.patch"
+ "qt5-use-pkgconfig-for-harfbuzz.patch")
+md5sums=('184f9460b40752d71b15b827260580c2'
+ '55a11d8ea5db9ca0cced06b06655b417'
+ '1f7aea5e8bed840b3efc9172081ddb45'
+ 'bc99c4cc6998295d76f37ed681c20d47'
+ 'e2ffff39673b37c4d9974e92fcf7213c'
+ '4fe6523dd1c34398df3aa5a8763530cc'
+ 'f32a768e1acb9785c79c8e93aa266db2'
+ '3bd322551924543553a2bf81b4419a09'
+ '30fa9ddf8d842b1392e8d63868940657'
+ '99bb9f51ec684803768f36e407baf486'
+ '6a6bc88f35ac8080869de39bc128ce5b'
+ '261d9071a6af3f1d5c3f955da3781573'
+ '0524dc5427a6c5338ebd45ab08c6ce80'
+ 'c15d9f480d0248648fa52aeacb46e3c7'
+ '612a4dfb9f1a3898a1920c28bb999159'
+ 'd0eb81aef1a21c65813fe4ddabbc4206'
+ '1e8c03872062fe8499ed7786475ed4e0'
+ '83139869355c2d46921adb25e47cf0fa'
+ 'b9565219e9252a17fc1b8fb9ee30662c'
+ '20de722808e8a3fb684b0212bef8de46'
+ '1dc792faa7761d8d7d2f17170da04d6b'
+ '41ec67d9e5e70e0d6d93b42aebd0e12a'
+ '61c0f9d0095c5a6dec8d14e9ec35a608'
+ '16a7d505b503bb1087fc00fad819f64b')
+
+_architectures='i686-w64-mingw32 x86_64-w64-mingw32'
+#_architectures='x86_64-w64-mingw32 i686-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}"
+
+ # Include fixes from MXE
+ patch -p1 -b -i ../qt5-fixes-from-mxe.patch
+
+ if isANGLE; then
+ # Add support for configure options '-opengl angle' and '-opengl dynamic'
+ # to the configure shell script
+ patch -p0 -i ../qt5-add-angle-and-dynamic-support.patch
+ # Make sure our external Angle package is used instead of the bundled one
+ patch -p1 -i ../qt5-use-external-angle-library.patch
+ fi
+
+ # Prevent too many sections / File too big assembler error
+ # (On x86_64 qopenglversionfunctionsfactory.o exceeds limit of 32768 sections
+ # otherwise.)
+ patch -p0 -i ../qt5-fix-opengl-to-many-sections.patch
+
+ # Make sure the .pc files of the Qt5 modules are installed correctly
+ patch -p0 -i ../qt5-workaround-pkgconfig-install-issue.patch
+
+ # Prevents resource files from being added to the LIBS parameter
+ # This solves an issue where the generated pkg-config files contained
+ # invalid Libs.private references like .obj/debug/Qt5Cored_resource_res.o
+ patch -p1 -i ../qt5-dont-add-resource-files-to-qmake-libs.patch
+
+ # 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
+ patch -p1 -i ../qt5-prevent-debug-library-names-in-pkgconfig-files.patch
+
+ # Fix linking against static DBus
+ patch -p0 -i ../qt5-fix-linking-against-static-dbus.patch
+
+ # Patch the win32-g++ mkspecs profile to match our environment
+ patch -p0 -i ../qt5-use-win32-g++-mkspecs-profile.patch
+
+ # Use pkgconfig for harfbzz dependency
+ # (must be applied after qt5-use-win32-g++-mkspecs-profile.patch)
+ patch -p0 -i ../qt5-use-pkgconfig-for-harfbuzz.patch
+
+ # The bundled pcre is built as static library by default
+ # As we're not using the bundled copy but our own copy
+ # we need to do some fiddling to fix compilation issues
+ # when trying to build static qmake projects
+ patch -p1 -i ../qt5-fix-linking-against-static-pcre.patch
+
+ # Make sure the qtmain (static) library doesn't conflict with the one
+ # provided by the mingw-qt (qt4) package. The mkspecs profile is already
+ # updated by patch100 to reflect this change
+ # https://bugzilla.redhat.com/show_bug.cgi?id=1092465
+ patch -p1 -i ../qt5-rename-qtmain-to-qt5main.patch
+
+ # Upstream always wants the host libraries to be static instead of
+ # shared libraries. This causes issues and is against the Fedora
+ # packaging guidelines so disable this 'feature'
+ patch -p0 -i ../qt5-dont-build-host-libs-static.patch
+
+ # Build host tools with rpath enabled
+ # We have to use rpath here as the library which the
+ # various tools depend on (libQt5Bootstrap.so) resides
+ # in the folder /usr/${_arch}/lib
+ # We can't use the regular lib dir for this as we
+ # want to avoid conflicts with the native qt5 packages
+ patch -p1 -i ../qt5-enable-rpath-for-host-tools.patch
+
+ # Build host libs with system zlib. This patch cannot be upstreamed as-is
+ # due to the other host-libs patches.
+ patch -p0 -i ../qt5-use-system-zlib-in-host-libs.patch
+
+ # Determine the compiler's default include and lib directories at qmake time
+ # see https://codereview.qt-project.org/#/c/157817
+ patch -p1 -i ../qt5-disable-default-lib-include-detection.patch
+
+ # Fix qmake to append .dll.a extension to import libs
+ patch -p1 -i ../qt5-fix-implib-ext.patch
+
+ # Allow use of static version via CMake
+ patch -p0 -i ../qt5-win32-static-cmake-link-ws2_32-and--static.patch
+ patch -p0 -i ../qt5-allow-usage-of-static-qt-with-cmake.patch
+
+ # Allow installation of static Qt in the same prefix as the shared version
+ patch -p0 -i ../qt5-merge-static-and-shared-library-trees.patch
+ isStatic && patch -p0 -i ../qt5-customize-extensions-for-static-build.patch
+
+ # Use correct pkg-config --static flag
+ isStatic && patch -p1 -i ../qt5-use-correct-pkg-config-static-flags.patch
+
+ # Fix detection of static mariadb client
+ isStatic && patch -p0 -i ../qt5-fix-static-psql-mysql.patch
+
+ # 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
+
+ for _arch in ${_architectures}; do
+ # Phonon is disabled for now because we lack the directx headers
+ # The odd paths for the -hostbindir argument are on purpose
+ # The qtchooser tool assumes that the tools 'qmake', 'moc' and others
+ # are all available in the same folder with these exact file names
+ # To prevent conflicts with the mingw-w64-qt4 package we have
+ # to put these tools in a dedicated folder
+ local qt_configure_args="\
+ -xplatform win32-g++ \
+ -optimized-qmake \
+ -verbose \
+ -opensource \
+ -confirm-license \
+ -force-pkg-config \
+ -force-debug-info \
+ -audio-backend \
+ -system-zlib \
+ -system-libpng \
+ -system-libjpeg \
+ -system-sqlite \
+ -system-freetype \
+ -system-harfbuzz \
+ -system-pcre \
+ -no-fontconfig \
+ -iconv \
+ -openssl \
+ -dbus-linked \
+ -no-glib \
+ -no-icu \
+ -release \
+ -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}-"
+
+ # Fix include directory of freetype2 and dbus
+ qt_configure_args+=" $(${_arch}-pkg-config --cflags-only-I freetype2 dbus-1)"
+
+ # 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+=' -opengl angle'
+ fi
+ # GL_GLEXT_PROTOTYPES must be defined to enable declarations of GLES functions
+ qt_configure_args+=' -DGL_GLEXT_PROTOTYPES'
+ fi
+
+ unset PKG_CONFIG_PATH
+
+ # Fix MySQL
+ if ! isStatic; then
+ export QT_LFLAGS_MYSQL="-L/usr/${_arch}/lib -lmysql"
+ fi
+ # Qt doesn't detect mysql correctly, so use this:
+ export QT_CFLAGS_MYSQL="-I/usr/${_arch}/include/mariadb"
+ # Hardcode MySQL flags into configure (really nice solution :( )
+ sed -e "s|^QT_CFLAGS_MYSQL=.*$|QT_CFLAGS_MYSQL=\"${QT_CFLAGS_MYSQL}\"|g" -i "${srcdir}/${_pkgfqn}/configure"
+ sed -e "s|^QT_LFLAGS_MYSQL=.*$|QT_LFLAGS_MYSQL=\"${QT_LFLAGS_MYSQL}\"|g" -i "${srcdir}/${_pkgfqn}/configure"
+ #sed -e "s|^QT_LFLAGS_MYSQL_R=.*$|QT_LFLAGS_MYSQL_R=\"${QT_LFLAGS_MYSQL_R}\"|g" -i "${srcdir}/${_pkgfqn}/configure"
+ qt_configure_args_mysql="-mysql_config /this/file/should/not/exist"
+ # TODO: test whether this workaround is still requried
+
+ mkdir -p ../build-${_arch} && pushd ../build-${_arch}
+
+ if isStatic; then
+ ../${_pkgfqn}/configure -static $qt_configure_args $qt_configure_args_mysql
+ 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 -shared $qt_configure_args $qt_configure_args_mysql
+ 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}"
+
+ 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 static form in the shared version
+ rm -f "${pkgdir}/usr/${_arch}/lib/"{lib,}qt5main* \
+ "${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5OpenGLExtensions* \
+ "${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5PlatformSupport* \
+ "${pkgdir}/usr/${_arch}/lib/"libQt5Bootstrap*
+
+ # Keep various Qt 5 plugins to be used in static builds
+ 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}"
+
+ # remove CMake which are also in base
+ find "${pkgdir}/usr/${_arch}/lib/cmake" -not -name "Static*.cmake" -exec rm {} \;
+
+ # 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 {} \;
+
+ # Add qtchooser support
+ [[ ${_arch} == i686-w64-mingw32 ]] && mingwn='mingw32' || mingwn='mingw64'
+ mkdir -p "${pkgdir}/etc/xdg/qtchooser"
+ echo "/usr/${_arch}/lib/qt/bin" > "${pkgdir}/etc/xdg/qtchooser/$mingwn-qt5.conf"
+ echo "/usr/${_arch}/lib" >> "${pkgdir}/etc/xdg/qtchooser/$mingwn-qt5.conf"
+
+ # 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
+
+ # 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/qt5-add-angle-and-dynamic-support.patch b/qt5-add-angle-and-dynamic-support.patch
new file mode 100644
index 000000000000..f9b88685a00d
--- /dev/null
+++ b/qt5-add-angle-and-dynamic-support.patch
@@ -0,0 +1,75 @@
+--- configure.orig 2016-06-10 08:48:56.000000000 +0200
++++ configure 2016-09-04 20:38:55.345362982 +0200
+@@ -1287,6 +1287,7 @@
+ ;;
+ opengl)
+ if [ "$VAL" = "auto" ] || [ "$VAL" = "desktop" ] ||
++ [ "$VAL" = "angle" ] || [ "$VAL" = "dynamic" ] ||
+ [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] ||
+ [ "$VAL" = "es2" ]; then
+ CFG_OPENGL="$VAL"
+@@ -5312,7 +5313,7 @@
+ fi
+ if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then
+ if compileTest x11/opengl "OpenGL"; then
+- CFG_OPENGL=desktop
++ CFG_OPENGL=angle
+ elif compileTest unix/opengles2 "OpenGL ES 2.0"; then
+ CFG_OPENGL=es2
+ else
+@@ -5348,6 +5349,17 @@
+ echo " ${XQMAKESPEC}."
+ exit 1
+ fi
++ elif [ "$CFG_OPENGL" = "angle" ]; then
++ compileTest x11/opengl "OpenGL"
++ if [ $? != "0" ]; then
++ echo "The OpenGL functionality test failed!"
++ echo " You might need to modify the include and library search paths by editing"
++ echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in"
++ echo " ${XQMAKESPEC}."
++ exit 1
++ fi
++ elif [ "$CFG_OPENGL" = "dynamic" ]; then
++ true # FIXME: not sure whether/which test required
+ elif [ "$CFG_OPENGL" = "desktop" ]; then
+ # Desktop OpenGL support
+ compileTest x11/opengl "OpenGL"
+@@ -6423,6 +6435,16 @@
+ QT_CONFIG="$QT_CONFIG opengles2"
+ fi
+
++if [ "$CFG_OPENGL" = "angle" ]; then
++ QCONFIG_FLAGS="$QCONFIG_FLAGS QT_OPENGL_ES QT_OPENGL_ES_2"
++ QT_CONFIG="$QT_CONFIG opengles2 egl angle"
++fi
++
++if [ "$CFG_OPENGL" = "dynamic" ]; then
++ QCONFIG_FLAGS="$QCONFIG_FLAGS QT_OPENGL_DYNAMIC"
++ QT_CONFIG="$QT_CONFIG dynamicgl"
++fi
++
+ if [ "$CFG_SHARED" = "yes" ]; then
+ QT_CONFIG="$QT_CONFIG shared"
+ QTCONFIG_CONFIG="$QTCONFIG_CONFIG shared"
+@@ -7474,7 +7496,7 @@
+ report_support " NIS ...................." "$CFG_NIS"
+ report_support " OpenGL / OpenVG:"
+ report_support " EGL .................." "$CFG_EGL"
+-report_support " OpenGL ..............." "$CFG_OPENGL" yes "Desktop OpenGL" es2 "OpenGL ES 2.0+"
++report_support " OpenGL ..............." "$CFG_OPENGL" yes "Desktop OpenGL" es2 "OpenGL ES 2.0+" angle "ANGLE" dynamic "Dynamic OpenGL"
+ report_support " OpenVG ..............." "$CFG_OPENVG-$CFG_OPENVG_SHIVA" yes-yes "ShivaVG" yes-no "native"
+ report_support " PCRE ..................." "$CFG_PCRE" yes "system library" qt "bundled copy"
+ if [ -n "$PKG_CONFIG" ]; then
+--- src/gui/opengl/qopenglfunctions.h.orig 2016-06-10 08:48:56.000000000 +0200
++++ src/gui/opengl/qopenglfunctions.h 2016-09-04 20:36:07.801522904 +0200
+@@ -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>
diff --git a/qt5-allow-usage-of-static-qt-with-cmake.patch b/qt5-allow-usage-of-static-qt-with-cmake.patch
new file mode 100644
index 000000000000..844db1e7ce41
--- /dev/null
+++ b/qt5-allow-usage-of-static-qt-with-cmake.patch
@@ -0,0 +1,444 @@
+--- mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in.orig 2016-08-14 20:44:32.515151700 +0200
++++ mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in 2016-08-18 23:22:00.447257800 +0200
+@@ -59,19 +59,30 @@
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
+
+ !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+- set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
++ if(USE_STATIC_QT_BUILD)
++ 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 \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
++ if(USE_STATIC_QT_BUILD)
++ set(imported_location \"lib/${LIB_LOCATION}\")
++ else()
++ set(imported_location \"bin/${LIB_LOCATION}\")
++ endif()
+ !!ENDIF
+ _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
++ if (_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES)
++ set(_list_sep \";\")
++ endif()
+ set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
+- \"INTERFACE_LINK_LIBRARIES\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
++ \"INTERFACE_LINK_LIBRARIES_${Configuration}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}${_list_sep}${_Qt5$${CMAKE_MODULE_NAME}_STATIC_${Configuration}_LIB_DEPENDENCIES}\"
+ \"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
+ !!IF !isEmpty(CMAKE_LIB_SONAME)
+ \"IMPORTED_SONAME_${Configuration}\" \"$${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_${Configuration}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}${_list_sep}${_Qt5$${CMAKE_MODULE_NAME}_STATIC_${Configuration}_LIB_DEPENDENCIES}\"
+ )
+
+ !!IF !isEmpty(CMAKE_WINDOWS_BUILD)
+@@ -222,16 +233,50 @@
+ endif()
+ !!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")
+-!!ELSE
+ !!IF equals(TEMPLATE, aux)
+ add_library(Qt5::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
+ !!ELSE
+- add_library(Qt5::$${CMAKE_MODULE_NAME} SHARED IMPORTED)
++ if(USE_STATIC_QT_BUILD)
++ add_library(Qt5::$${CMAKE_MODULE_NAME} STATIC IMPORTED)
++ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
++
++ macro(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}\")
++ 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(macro_process_plugin_prl_file prl_file_location Configuration LIB_DIRECTORY LIB_LOCATION)
++ # First add the (static) plugin itself ...
++ 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}${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/${LIB_DIRECTORY}/${LIB_LOCATION}\")
++ # .. then its dependencies.
++ macro_process_prl_file(${prl_file_location} ${Configuration})
++ endmacro()
++
++!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
++ macro_process_prl_file(\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG_STATIC}\" DEBUG)
++!!ELSE
++ macro_process_prl_file(\"$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG_STATIC}\" DEBUG)
+ !!ENDIF
++!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
++ macro_process_prl_file(\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE_STATIC}\" RELEASE)
++!!ELSE
++ macro_process_prl_file(\"$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE_STATIC}\" RELEASE)
++!!ENDIF
++ else()
++ add_library(Qt5::$${CMAKE_MODULE_NAME} SHARED IMPORTED)
++ endif()
+ !!ENDIF
++
+ !!IF !equals(TEMPLATE, aux)
+ !!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1)
+@@ -240,67 +285,132 @@
+
+ set_property(TARGET 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_DEFINE})
++ set(interface_compile_definitions $${MODULE_DEFINE})
++ if(USE_STATIC_QT_BUILD)
++ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY
++ INTERFACE_COMPILE_DEFINITIONS $${CMAKE_INTERFACE_COMPILE_DEFINITIONS_STATIC} $${MODULE_DEFINE})
++ else()
++ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY
++ INTERFACE_COMPILE_DEFINITIONS $${MODULE_DEFINE})
++ endif()
++ if(USE_STATIC_QT_BUILD)
++ file(GLOB pluginTargetsMaybe \"${CMAKE_CURRENT_LIST_DIR}/StaticQt5$${CMAKE_MODULE_NAME}_*.cmake\")
++ else()
++ file(GLOB pluginTargetsMaybe \"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}_*.cmake\")
++ endif()
++ 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 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}
++ )
++ if(USE_STATIC_QT_BUILD)
++ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY STATIC_PLUGINS ${Plugin})
++ get_filename_component(_plugindir ${PLUGIN_LOCATION} PATH)
++ get_filename_component(_plugindirname ${_plugindir} NAME)
++ get_filename_component(_pluginname ${PLUGIN_LOCATION} NAME)
++ string(REGEX REPLACE \"^lib(.*)\\\\.a\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/lib/qt/plugins/${_plugindirname}/\\\\1-static.prl\" plugin_prl_file_location ${_pluginname})
++ macro_process_plugin_prl_file(${plugin_prl_file_location} ${Configuration} \"lib/qt/plugins\" ${PLUGIN_LOCATION})
++ endif()
++
++ endmacro()
++
++ if (pluginTargets)
++ foreach(pluginTarget ${pluginTargets})
++ include(${pluginTarget})
++ endforeach()
++ 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}\" \"\" )
+-!!ELSE
++!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
++ if(USE_STATIC_QT_BUILD)
++ _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE_STATIC}\" \"\" )
++ else()
++!!ENDIF // CMAKE_WINDOWS_BUILD
+ _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
++!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
++ endif()
++!!ENDIF // CMAKE_WINDOWS_BUILD
++
+
+ !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
+ !!IF isEmpty(CMAKE_DEBUG_TYPE)
+-!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
++!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
++ if(USE_STATIC_QT_BUILD)
+ !!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}\" )
++ 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(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG_STATIC}\" \"\" )
++ endif()
++ else()
++!!ENDIF // CMAKE_WINDOWS_BUILD
+ 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
+ endif()
++!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
++ endif()
++!!ENDIF // CMAKE_WINDOWS_BUILD
+ !!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}\" \"\" )
+-!!ELSE
++!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
++ if(USE_STATIC_QT_BUILD)
++ _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
++ else()
++!!ENDIF // CMAKE_WINDOWS_BUILD
+ _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
++!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
++ endif()
++!!ENDIF // CMAKE_WINDOWS_BUILD
+
+ !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
+ !!IF isEmpty(CMAKE_RELEASE_TYPE)
+-!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
++
++!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
++ if(USE_STATIC_QT_BUILD)
+ !!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(RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE_STATIC}\" \"\" )
++ else()
++!!ENDIF // CMAKE_WINDOWS_BUILD
+ if (EXISTS
+ !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+- \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
++ \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE_STATIC}\"
+ !!ELSE
+ \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
+ !!ENDIF
+@@ -311,8 +421,12 @@
+ \"$${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
+ endif()
++!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
++ endif()
++!!ENDIF // CMAKE_WINDOWS_BUILD
++
++
+ !!ENDIF // CMAKE_RELEASE_TYPE
+ !!ENDIF // CMAKE_FIND_OTHER_LIBRARY_BUILD
+
+@@ -323,28 +437,6 @@
+ )
+ !!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\")
+--- mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in.orig 2016-06-10 08:48:56.000000000 +0200
++++ mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in 2016-08-18 23:22:41.994211700 +0200
+@@ -2,10 +2,18 @@
+ add_library(Qt5::$$CMAKE_PLUGIN_NAME MODULE IMPORTED)
+
+ !!IF !isEmpty(CMAKE_RELEASE_TYPE)
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE_STATIC}\")
++!!ELSE
+ _populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
+ !!ENDIF
++!!ENDIF
+ !!IF !isEmpty(CMAKE_DEBUG_TYPE)
++!!IF !isEmpty(CMAKE_STATIC_TYPE)
++_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG_STATIC}\")
++!!ELSE
+ _populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
+ !!ENDIF
++!!ENDIF
+
+ list(APPEND Qt5$${CMAKE_MODULE_NAME}_PLUGINS Qt5::$$CMAKE_PLUGIN_NAME)
+--- mkspecs/features/create_cmake.prf.orig 2016-08-14 20:44:32.513342200 +0200
++++ mkspecs/features/create_cmake.prf 2016-08-18 22:47:39.606635000 +0200
+@@ -135,17 +135,19 @@
+ 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,7 +163,8 @@
+ }
+ }
+ 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
++ isEmpty(CMAKE_STATIC_TYPE): cmake_target_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}_$${PLUGIN_CLASS_NAME}.cmake
++ else: cmake_target_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/StaticQt5$${CMAKE_MODULE_NAME}_$${PLUGIN_CLASS_NAME}.cmake
+
+ !build_pass:QMAKE_SUBSTITUTES += \
+ cmake_target_file
+@@ -180,6 +183,8 @@
+ 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.
+@@ -197,10 +202,13 @@
+ CMAKE_QT5_MODULE_DEPS = $$join(lib_deps, ";")
+ CMAKE_INTERFACE_MODULE_DEPS = $$join(aux_mod_deps, ";")
+ CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";")
++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 +236,33 @@
+ 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_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 = $${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_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
+--- qmake/generators/makefile.cpp 2015-08-26 14:29:10.131124600 +0100
++++ qmake/generators/makefile.cpp 2015-08-26 15:06:33.375635900 +0100
+@@ -1006,6 +1006,13 @@
+ for (ProStringList::Iterator it = libs.begin(); it != libs.end(); ++it)
+ t << qv(project->values((*it).toKey()));
+ t << endl;
++ t << "QMAKE_PRL_LIBS_FOR_CMAKE = ";
++ QString sep;
++ for (ProStringList::Iterator it = libs.begin(); it != libs.end(); ++it) {
++ t << sep << project->values((*it).toKey()).join(';').replace('\\', "\\\\");
++ sep = ';';
++ }
++ t << endl;
+ }
+ }
diff --git a/qt5-customize-extensions-for-static-build.patch b/qt5-customize-extensions-for-static-build.patch
new file mode 100644
index 000000000000..d9398200ddcb
--- /dev/null
+++ b/qt5-customize-extensions-for-static-build.patch
@@ -0,0 +1,15 @@
+--- mkspecs/features/spec_pre.prf.orig 2016-06-10 08:48:56.000000000 +0200
++++ mkspecs/features/spec_pre.prf 2016-08-09 16:42:35.000000000 +0200
+@@ -14,9 +14,9 @@
+ 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_LIBTOOL = -static.la
++QMAKE_EXT_PKGCONFIG = -static.pc
++QMAKE_EXT_PRL = -static.prl
+ QMAKE_EXT_UI = .ui
+ QMAKE_EXT_YACC = .y
+
diff --git a/qt5-disable-default-lib-include-detection.patch b/qt5-disable-default-lib-include-detection.patch
new file mode 100644
index 000000000000..64475b7e7a0a
--- /dev/null
+++ b/qt5-disable-default-lib-include-detection.patch
@@ -0,0 +1,11 @@
+--- a/mkspecs/features/default_pre.prf 2016-06-25 18:44:50.952774100 +0200
++++ b/mkspecs/features/default_pre.prf 2016-06-25 18:42:00.416181500 +0200
+@@ -29,7 +29,7 @@
+ #
+ # Get default include and library paths from compiler
+ #
+- gcc {
++ !win32:gcc {
+ equals(QMAKE_DIR_SEP, /) {
+ cmd_prefix = "LC_ALL=C"
+ cmd_suffix = "</dev/null >/dev/null"
diff --git a/qt5-dont-add-resource-files-to-qmake-libs.patch b/qt5-dont-add-resource-files-to-qmake-libs.patch
new file mode 100644
index 000000000000..838f2467e541
--- /dev/null
+++ b/qt5-dont-add-resource-files-to-qmake-libs.patch
@@ -0,0 +1,11 @@
+--- qtbase-opensource-src-5.2.0/qmake/generators/win32/mingw_make.cpp.orig 2014-01-04 21:18:07.413328813 +0100
++++ qtbase-opensource-src-5.2.0/qmake/generators/win32/mingw_make.cpp 2014-01-04 21:18:55.740126515 +0100
+@@ -243,7 +243,7 @@
+
+ processVars();
+
+- project->values("QMAKE_LIBS") += project->values("RES_FILE");
++ project->values("OBJECTS") += project->values("RES_FILE");
+
+ if (project->isActiveConfig("dll")) {
+ QString destDir = "";
diff --git a/qt5-dont-build-host-libs-static.patch b/qt5-dont-build-host-libs-static.patch
new file mode 100644
index 000000000000..9e430e4ff71f
--- /dev/null
+++ b/qt5-dont-build-host-libs-static.patch
@@ -0,0 +1,19 @@
+--- mkspecs/features/qt_module.prf.orig 2013-07-31 20:37:56.789883201 +0200
++++ mkspecs/features/qt_module.prf 2013-07-31 20:38:06.013034478 +0200
+@@ -25,7 +25,7 @@
+
+ # 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
+--- src/tools/bootstrap-dbus/bootstrap-dbus.pro.orig 2013-12-08 11:09:47.000000000 -0600
++++ src/tools/bootstrap-dbus/bootstrap-dbus.pro 2014-01-05 23:06:13.575543400 -0600
+@@ -30,4 +30,4 @@
+ ../../dbus/qdbusunixfiledescriptor.cpp
+
+ lib.CONFIG = dummy_install
+-INSTALLS = lib
++INSTALLS += lib
diff --git a/qt5-enable-rpath-for-host-tools.patch b/qt5-enable-rpath-for-host-tools.patch
new file mode 100644
index 000000000000..2f2e96c75714
--- /dev/null
+++ b/qt5-enable-rpath-for-host-tools.patch
@@ -0,0 +1,18 @@
+--- qtbase-opensource-src-5.1.0/mkspecs/features/qt_app.prf.orig
++++ qtbase-opensource-src-5.1.0/mkspecs/features/qt_app.prf
+@@ -20,6 +20,7 @@
+ 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: CONFIG += release
+ contains(QT, core(-private)?|xml) {
+@@ -30,7 +30,6 @@
+ } else {
+ !build_pass:contains(QT_CONFIG, debug_and_release):contains(QT_CONFIG, build_all): CONFIG += release
+ target.path = $$[QT_INSTALL_BINS]
+- CONFIG += relative_qt_rpath # Qt's tools and apps should be relocatable
+ }
+ INSTALLS += target
+
diff --git a/qt5-fix-implib-ext.patch b/qt5-fix-implib-ext.patch
new file mode 100644
index 000000000000..65612d721fec
--- /dev/null
+++ b/qt5-fix-implib-ext.patch
@@ -0,0 +1,84 @@
+From f09d23b9cd22771e04f49b386e3b67df8ad108c3 Mon Sep 17 00:00:00 2001
+From: Ray Donnelly <mingw.android@gmail.com>
+Date: Mon, 10 Mar 2014 22:59:39 +0000
+Subject: [PATCH] win32-g++: Add QMAKE_EXTENSION_IMPORTLIB defaulting to 'a'
+
+This is to allow the MSYS2 project to set it to 'dll.a' so
+that static and shared Qt libraries can be installed into
+the same prefix without conflicting.
+
+To change it, you should pass -device-option to configure.
+
+Change-Id: I9ee49d2aef46e21f31b97611de2fc6d3070e288a
+---
+ mkspecs/features/create_cmake.prf | 5 +++--
+ qmake/generators/win32/mingw_make.cpp | 15 +++++++++++++--
+ qmake/generators/win32/mingw_make.h | 1 +
+ 3 files changed, 17 insertions(+), 4 deletions(-)
+
+diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
+index 82e2812..2d8a043 100644
+--- a/mkspecs/features/create_cmake.prf
++++ b/mkspecs/features/create_cmake.prf
+@@ -214,8 +214,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/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf
+index 6d5764f..77e910b 100644
+--- a/mkspecs/win32-g++/qmake.conf
++++ b/mkspecs/win32-g++/qmake.conf
+@@ -92,7 +92,7 @@
+ QMAKE_EXTENSION_SHLIB = dll
+ QMAKE_PREFIX_STATICLIB = lib
+ QMAKE_EXTENSION_STATICLIB = a
+-QMAKE_LIB_EXTENSIONS = a dll.a
++QMAKE_EXTENSION_IMPORTLIB = dll.a
+
+ QMAKE_LIBS =
+ QMAKE_LIBS_CORE = -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32
+diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
+index 6d5764f..77e910b 100644
+--- a/qmake/generators/win32/winmakefile.cpp
++++ b/qmake/generators/win32/winmakefile.cpp
+@@ -85,10 +85,14 @@
+ 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]);
+@@ -233,9 +237,12 @@
+ 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");
diff --git a/qt5-fix-linking-against-static-dbus.patch b/qt5-fix-linking-against-static-dbus.patch
new file mode 100644
index 000000000000..b17ac71cff45
--- /dev/null
+++ b/qt5-fix-linking-against-static-dbus.patch
@@ -0,0 +1,26 @@
+--- config.tests/unix/dbus/dbus.cpp.orig 2015-03-08 17:05:21.216593135 +0100
++++ config.tests/unix/dbus/dbus.cpp 2015-03-08 17:06:35.276826201 +0100
+@@ -31,6 +31,10 @@
+ **
+ ****************************************************************************/
+
++#ifdef QT_STATIC
++# define DBUS_STATIC_BUILD
++#endif
++
+ #define DBUS_API_SUBJECT_TO_CHANGE
+ #include <dbus/dbus.h>
+
+ --- src/dbus/qdbus_symbols_p.h.orig 2016-06-10 08:48:56.000000000 +0200
+ +++ src/dbus/qdbus_symbols_p.h 2016-08-14 00:23:15.325768622 +0200
+ @@ -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
diff --git a/qt5-fix-linking-against-static-pcre.patch b/qt5-fix-linking-against-static-pcre.patch
new file mode 100644
index 000000000000..3dd77468ed37
--- /dev/null
+++ b/qt5-fix-linking-against-static-pcre.patch
@@ -0,0 +1,13 @@
+--- qtbase-opensource-src-5.1.0/src/corelib/tools/qregularexpression.cpp.orig 2013-07-11 08:23:02.687691337 +0200
++++ qtbase-opensource-src-5.1.0/src/corelib/tools/qregularexpression.cpp 2013-07-11 08:23:27.231900674 +0200
+@@ -47,6 +47,10 @@
+ #include <QtCore/qatomic.h>
+ #include <QtCore/qdatastream.h>
+
++#ifdef QT_STATIC
++#define PCRE_STATIC
++#endif
++
+ #include <pcre.h>
+
+ QT_BEGIN_NAMESPACE
diff --git a/qt5-fix-opengl-to-many-sections.patch b/qt5-fix-opengl-to-many-sections.patch
new file mode 100644
index 000000000000..f83fc54368c5
--- /dev/null
+++ b/qt5-fix-opengl-to-many-sections.patch
@@ -0,0 +1,10 @@
+--- src/gui/opengl/opengl.pri.orig 2014-12-05 09:24:35.000000000 -0700
++++ src/gui/opengl/opengl.pri 2015-02-09 10:48:48.484071754 -0700
+@@ -4,6 +4,7 @@
+ contains(QT_CONFIG, opengles2):CONFIG += opengles2
+
+ contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles2) {
++ QMAKE_CXXFLAGS+="-Wa,-mbig-obj"
+
+ HEADERS += opengl/qopengl.h \
+ opengl/qopengl_p.h \
diff --git a/qt5-fix-static-psql-mysql.patch b/qt5-fix-static-psql-mysql.patch
new file mode 100644
index 000000000000..3c308c57805a
--- /dev/null
+++ b/qt5-fix-static-psql-mysql.patch
@@ -0,0 +1,15 @@
+--- config.tests/unix/psql/psql.pro.orig 2015-02-16 21:56:55.000000000 -0700
++++ config.tests/unix/psql/psql.pro 2015-03-09 21:45:44.746755052 -0600
+@@ -1,3 +1,3 @@
+ SOURCES = psql.cpp
+ CONFIG -= qt dylib
+-LIBS *= -lpq
++LIBS *= -lpq -lintl -liconv -lssl -lcrypto -lwldap32 -lshfolder -lwsock32 -lws2_32 -lsecur32 -lgdi32
+
+--- config.tests/unix/mysql/mysql.pro.orig 2015-02-16 21:56:55.000000000 -0700
++++ config.tests/unix/mysql/mysql.pro 2015-03-09 21:38:59.930405876 -0600
+@@ -1,3 +1,3 @@
+ SOURCES = mysql.cpp
+ CONFIG -= qt dylib
+-LIBS += -lmysqlclient
++LIBS += -lmariadbclient -lws2_32 -lpthread -lz -lm -lssl -lcrypto
diff --git a/qt5-fixes-from-mxe.patch b/qt5-fixes-from-mxe.patch
new file mode 100644
index 000000000000..c40231a639d1
--- /dev/null
+++ b/qt5-fixes-from-mxe.patch
@@ -0,0 +1,91 @@
+This file is part of MXE.
+See index.html for further information.
+
+Contains ad hoc patches for cross building.
+
+From 54b168c305f54e60de0e32501b166faa7f5913e0 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Thu, 6 Aug 2015 23:35:08 +0200
+Subject: [PATCH 1/8] fix qwindows plugin linking with system-freetype (MXE
+ specific)
+
+Change-Id: I8783e3ab2d19011b083dd3c471107298a17293c4
+
+diff --git a/src/3rdparty/freetype_dependency.pri b/src/3rdparty/freetype_dependency.pri
+index 39280de..e152b0d 100644
+--- a/src/3rdparty/freetype_dependency.pri
++++ b/src/3rdparty/freetype_dependency.pri
+@@ -4,4 +4,5 @@ contains(QT_CONFIG, freetype) {
+ } else:contains(QT_CONFIG, system-freetype) {
+ # pull in the proper freetype2 include directory
+ include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri)
++ win32:shared:LIBS_PRIVATE += -lfreetype
+ }
+--
+2.5.0
+
+
+From fa5ca49b4ffc1911a597b294ef2d4b5ecb983cad Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Mon, 8 Dec 2014 14:15:12 +0100
+Subject: [PATCH 3/8] fix oci config test on windows
+
+Change-Id: If1ce2241682259ca495b0ba68bf18410f8548922
+
+diff --git a/config.tests/unix/oci/oci.pro b/config.tests/unix/oci/oci.pro
+index 3ffda1d..39b6f3759 100644
+--- a/config.tests/unix/oci/oci.pro
++++ b/config.tests/unix/oci/oci.pro
+@@ -1,3 +1,3 @@
+ SOURCES = oci.cpp
+ CONFIG -= qt dylib
+-LIBS += -lclntsh
++!win32:LIBS += -lclntsh
+--
+2.5.0
+
+
+From 7fd641a032c7b4ce1b14d7ca02da646b0a0c34d5 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Thu, 6 Aug 2015 13:24:56 +0200
+Subject: [PATCH 4/8] configure: don't set QT_NO_SYSTEMSEMAPHORE for Windows
+
+Change-Id: I53c110ef40e3d14cc49fa23aa5d294611cac2ffa
+
+diff --git a/configure b/configure
+index 7651e29..4a4b478 100755
+--- a/configure
++++ b/configure
+@@ -4575,7 +4575,7 @@ fi
+ [ "$XPLATFORM_ANDROID" = "yes" ] && QMakeVar add styles "android"
+
+ # check IPC support
+-if ! compileTest unix/ipc_sysv "ipc_sysv" ; then
++if [ "$XPLATFORM_MINGW" = "no" ] && ! compileTest unix/ipc_sysv "ipc_sysv" ; then
+ # SYSV IPC is not supported - check POSIX IPC
+ if compileTest unix/ipc_posix "ipc_posix" ; then
+ QCONFIG_FLAGS="$QCONFIG_FLAGS QT_POSIX_IPC"
+--
+2.5.0
+
+
+From 959d3a71bced8c00967a16f23c6f9305e56fafcd Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Tue, 6 Oct 2015 09:53:20 +0200
+Subject: [PATCH 5/8] fix building mysql driver under mingw
+
+Change-Id: I9c4e821d5b3a6919566c6b684cb4916827feb6a9
+
+diff --git a/src/sql/drivers/mysql/qsql_mysql.pri b/src/sql/drivers/mysql/qsql_mysql.pri
+index 3cfb614..8b7063f 100644
+--- a/src/sql/drivers/mysql/qsql_mysql.pri
++++ b/src/sql/drivers/mysql/qsql_mysql.pri
+@@ -4,7 +4,7 @@ SOURCES += $$PWD/qsql_mysql.cpp
+ QMAKE_CXXFLAGS *= $$QT_CFLAGS_MYSQL
+ LIBS += $$QT_LFLAGS_MYSQL
+
+-unix {
++if (unix|mingw) {
+ isEmpty(QT_LFLAGS_MYSQL) {
+ !contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) {
+ use_libmysqlclient_r:LIBS += -lmysqlclient_r
diff --git a/qt5-merge-static-and-shared-library-trees.patch b/qt5-merge-static-and-shared-library-trees.patch
new file mode 100644
index 000000000000..9e6271a6ea63
--- /dev/null
+++ b/qt5-merge-static-and-shared-library-trees.patch
@@ -0,0 +1,50 @@
+--- mkspecs/features/qt.prf.orig 2016-03-27 17:38:28.396736835 +0200
++++ mkspecs/features/qt.prf 2016-03-27 18:09:17.061088857 +0200
+@@ -141,6 +141,18 @@
+ }
+ }
+ }
++
++ win32:CONFIG(static) {
++ isEqual(MODULE_NAME, QtCore) {
++ LIBS$$var_sfx += $$QMAKE_LIBS_CORE
++ } else:isEqual(MODULE_NAME, QtGui) {
++ LIBS$$var_sfx += $$QMAKE_LIBS_GUI
++ } else:isEqual(MODULE_NAME, QtNetwork) {
++ LIBS$$var_sfx += $$QMAKE_LIBS_NETWORK
++ } 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)")
+
+--- mkspecs/features/default_post.prf.orig 2012-09-05 23:28:56.827501401 +0200
++++ mkspecs/features/default_post.prf 2012-09-05 23:29:31.617923080 +0200
+@@ -47,3 +50,11 @@
+
+ QMAKE_INCDIR += $$QMAKE_INCDIR_POST
+ QMAKE_LIBDIR += $$QMAKE_LIBDIR_POST
++
++win32:contains(CONFIG, static) {
++ DEFINES += QT_STATIC QT_DESIGNER_STATIC
++ DEFINES -= QT_SHARED
++ contains(QT_CONFIG, angle): DEFINES += QT_OPENGL_ES_2_ANGLE_STATIC
++ QMAKE_LFLAGS += -static -static-libstdc++ -static-libgcc
++ QMAKE_EXT_PRL=-static.prl # prevents qmake from finding the prl file for shared libs
++}
+--- configure.orig 2012-12-10 23:51:02.920255366 +0100
++++ configure 2012-12-10 23:55:58.101753703 +0100
+@@ -6193,6 +6193,12 @@
+ }
+ QT_CONFIG += $QT_CONFIG
+
++contains(CONFIG, static) {
++ CONFIG -= shared
++ QT_CONFIG += static jpeg gif
++ QT_CONFIG -= shared
++}
++
+ #versioning
+ QT_VERSION = $QT_VERSION
+ QT_MAJOR_VERSION = $QT_MAJOR_VERSION
diff --git a/qt5-pkgconfig-static-library-name-workaround.patch b/qt5-pkgconfig-static-library-name-workaround.patch
new file mode 100644
index 000000000000..7065940164b6
--- /dev/null
+++ b/qt5-pkgconfig-static-library-name-workaround.patch
@@ -0,0 +1,19 @@
+--- qtbase-opensource-src-5.6.0/mkspecs/features/qt_module.prf.orig 2016-04-09 13:13:38.374286031 +0200
++++ qtbase-opensource-src-5.6.0/mkspecs/features/qt_module.prf 2016-04-09 13:24:04.292077922 +0200
+@@ -265,6 +265,16 @@
+ pclib_replace.replace = $$QMAKE_PKGCONFIG_LIBDIR
+ pclib_replace.CONFIG = path
+ QMAKE_PKGCONFIG_INSTALL_REPLACE += pclib_replace
++
++ pclib_replace2.CONFIG = path
++ pclib_replace2.match = " /lib"
++ pclib_replace2.replace = "-l"
++ QMAKE_PKGCONFIG_INSTALL_REPLACE += pclib_replace2
++
++ pclib_replace3.CONFIG = path
++ pclib_replace3.match = "\.dll\.a"
++ pclib_replace3.replace = ""
++ QMAKE_PKGCONFIG_INSTALL_REPLACE += pclib_replace3
+ }
+ !lib_bundle:unix {
+ CONFIG += create_libtool
diff --git a/qt5-prevent-debug-library-names-in-pkgconfig-files.patch b/qt5-prevent-debug-library-names-in-pkgconfig-files.patch
new file mode 100644
index 000000000000..7d6836d5ab06
--- /dev/null
+++ b/qt5-prevent-debug-library-names-in-pkgconfig-files.patch
@@ -0,0 +1,12 @@
+--- qtbase-opensource-src-5.2.0/qmake/generators/makefile.cpp.orig 2014-01-03 01:30:23.631353708 +0100
++++ qtbase-opensource-src-5.2.0/qmake/generators/makefile.cpp 2014-01-03 01:32:37.888625966 +0100
+@@ -3168,6 +3168,9 @@
+ 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()) {
diff --git a/qt5-rename-qtmain-to-qt5main.patch b/qt5-rename-qtmain-to-qt5main.patch
new file mode 100644
index 000000000000..e81082f21ab7
--- /dev/null
+++ b/qt5-rename-qtmain-to-qt5main.patch
@@ -0,0 +1,35 @@
+--- qtbase-opensource-src-5.2.1/src/winmain/winmain.pro.orig 2014-04-29 18:51:05.206296152 +0200
++++ qtbase-opensource-src-5.2.1/src/winmain/winmain.pro 2014-04-29 18:51:18.737512221 +0200
+@@ -2,7 +2,7 @@
+ !win32:error("$$_FILE_ is intended only for Windows!")
+
+ TEMPLATE = lib
+-TARGET = qtmain
++TARGET = qt5main
+ DESTDIR = $$QT.core.libs
+
+ CONFIG += static
+ --- qtbase-opensource-src-5.2.1/mkspecs/features/create_cmake.prf.orig 2014-04-29 18:53:49.511932034 +0200
+ +++ qtbase-opensource-src-5.2.1/mkspecs/features/create_cmake.prf 2014-04-29 18:54:44.515819011 +0200
+ @@ -203,8 +203,8 @@
+ 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"
+--- qtbase-opensource-src-5.3.1/mkspecs/features/win32/windows.prf.orig 2014-07-05 14:18:23.211155781 +0200
++++ qtbase-opensource-src-5.3.1/mkspecs/features/win32/windows.prf 2014-07-05 14:18:46.045390147 +0200
+@@ -5,7 +5,7 @@
+ 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/qt5-use-correct-pkg-config-static-flags.patch b/qt5-use-correct-pkg-config-static-flags.patch
new file mode 100644
index 000000000000..67b6a8e8dc3e
--- /dev/null
+++ b/qt5-use-correct-pkg-config-static-flags.patch
@@ -0,0 +1,14 @@
+--- qtbase-opensource-src-5.4.1/configure.orig 2015-02-17 05:56:22.000000000 +0100
++++ qtbase-opensource-src-5.4.1/configure 2015-03-21 17:08:54.138635641 +0100
+@@ -3884,6 +3884,11 @@
+ # See if PKG_CONFIG is set in the mkspec:
+ PKG_CONFIG="`"$outpath/bin/qmake" -E -nocache -spec "$XQMAKESPEC" "CONFIG=" $DEV_NULL 2>&1 | sed -n -e 's,^PKG_CONFIG = \(.*\),\1,p'`"
+ [ -n "$PKG_CONFIG" ] && [ "$OPT_VERBOSE" = "yes" ] && echo "Found pkg-config from mkspec: $PKG_CONFIG"
++
++ if [ "$CFG_SHARED" = "no" ] ; then
++ PKG_CONFIG="$PKG_CONFIG --static"
++ [ "$OPT_VERBOSE" = "yes" ] && echo "Using '$PKG_CONFIG' because we're doing a static build"
++ fi
+ fi
+ if [ -z "$PKG_CONFIG" ]; then
+ PKG_CONFIG=`"$WHICH" pkg-config 2>/dev/null`
diff --git a/qt5-use-external-angle-library.patch b/qt5-use-external-angle-library.patch
new file mode 100644
index 000000000000..383bb8c6f0d0
--- /dev/null
+++ b/qt5-use-external-angle-library.patch
@@ -0,0 +1,77 @@
+diff -U 3 -r a/src/gui/gui.pro b/src/gui/gui.pro
+--- a/src/gui/gui.pro 2015-06-29 14:04:55.000000000 -0600
++++ b/src/gui/gui.pro 2015-07-18 10:50:02.228227482 -0600
+@@ -17,10 +17,5 @@
+ imageformats \
+ egldeviceintegrations
+
+-# This is here only because the platform plugin is no module, obviously.
+-win32:contains(QT_CONFIG, angle)|contains(QT_CONFIG, dynamicgl) {
+- MODULE_AUX_INCLUDES = \
+- \$\$QT_MODULE_INCLUDE_BASE/QtANGLE
+-}
+
+ # Code coverage with TestCocoon
+@@ -35,6 +29,10 @@
+
+ mac:!ios: LIBS_PRIVATE += -framework Cocoa
+
++win32:contains(QT_CONFIG, angle) {
++ LIBS_PRIVATE += -lGLESv2
++}
++
+ CONFIG += simd optimize_full
+
+ include(accessible/accessible.pri)
+diff -U 3 -r a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in
+--- a/src/gui/Qt5GuiConfigExtras.cmake.in 2015-06-29 14:04:51.000000000 -0600
++++ b/src/gui/Qt5GuiConfigExtras.cmake.in 2015-07-18 10:51:09.666053970 -0600
+@@ -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 -U 3 -r a/src/opengl/opengl.pro b/src/opengl/opengl.pro
+--- a/src/opengl/opengl.pro 2015-06-29 14:04:05.000000000 -0600
++++ b/src/opengl/opengl.pro 2015-07-18 10:46:46.588388411 -0600
+@@ -12,6 +12,7 @@
+
+ contains(QT_CONFIG, opengl):CONFIG += opengl
+ contains(QT_CONFIG, opengles2):CONFIG += opengles2
++win32:contains(QT_CONFIG, angle): LIBS_PRIVATE += -lGLESv2
+
+ HEADERS += qgl.h \
+ qgl_p.h \
+
+diff -U 3 -r a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri
+--- a/src/plugins/platforms/windows/windows.pri 2015-06-29 14:04:40.000000000 -0600
++++ b/src/plugins/platforms/windows/windows.pri 2015-07-18 10:53:45.585348009 -0600
+@@ -3,6 +3,7 @@
+ !wince*:LIBS *= -luser32 -lwinspool -limm32 -lwinmm -loleaut32
+
+ contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2):!contains(QT_CONFIG, dynamicgl): LIBS *= -lopengl32
++contains(QT_CONFIG, angle):LIBS += -lGLESv2 -lEGL
+
+ mingw: LIBS *= -luuid
+ # For the dialog helpers:
+diff -U 3 -r a/src/src.pro b/src/src.pro
+--- a/src/src.pro 2015-06-29 14:05:06.000000000 -0600
++++ b/src/src.pro 2015-07-18 10:43:01.698195194 -0600
+@@ -155,10 +155,6 @@
+ SUBDIRS += src_3rdparty_harfbuzzng
+ src_gui.depends += src_3rdparty_harfbuzzng
+ }
+- win32:contains(QT_CONFIG, angle)|contains(QT_CONFIG, dynamicgl) {
+- SUBDIRS += src_angle
+- src_gui.depends += src_angle
+- }
+ contains(QT_CONFIG, freetype) {
+ SUBDIRS += src_3rdparty_freetype
+ src_platformsupport.depends += src_3rdparty_freetype
diff --git a/qt5-use-pkgconfig-for-harfbuzz.patch b/qt5-use-pkgconfig-for-harfbuzz.patch
new file mode 100644
index 000000000000..078538a008f3
--- /dev/null
+++ b/qt5-use-pkgconfig-for-harfbuzz.patch
@@ -0,0 +1,31 @@
+--- src/3rdparty/harfbuzz_dependency.pri.orig 2016-08-12 22:07:40.467953900 +0200
++++ src/3rdparty/harfbuzz_dependency.pri 2016-08-12 22:08:06.583981900 +0200
+@@ -2,5 +2,7 @@
+ INCLUDEPATH += $$PWD/harfbuzz-ng/include
+ LIBS_PRIVATE += -L$$QT_BUILD_TREE/lib -lqtharfbuzzng$$qtPlatformTargetSuffix()
+ } else:contains(QT_CONFIG, system-harfbuzz) {
+- LIBS_PRIVATE += -lharfbuzz
++ # can't use 'feature' link_pkgconfig here because it would add harfbuzz to LIBS rather than LIBS_PRIVATE
++ contains(QT_CONFIG, static): LIBS_PRIVATE += $$system($$PKG_CONFIG --static --libs harfbuzz)
++ else: LIBS_PRIVATE += $$system($$PKG_CONFIG --libs harfbuzz)
+ }
+
+--- config.tests/unix/harfbuzz/harfbuzz.pro.orig
++++ config.tests/unix/harfbuzz/harfbuzz.pro
+@@ -1,3 +1,4 @@
+ SOURCES = harfbuzz.cpp
+ CONFIG -= qt dylib
+-LIBS += -lharfbuzz
++contains(CONFIG, static): LIBS += $$system($$PKG_CONFIG --static --libs harfbuzz)
++else: LIBS += $$system($$PKG_CONFIG --libs harfbuzz)
+
+--- mkspecs/win32-g++/qmake.conf.orig 2016-08-11 22:48:02.000000000 +0200
++++ mkspecs/win32-g++/qmake.conf 2016-08-13 02:15:32.791706438 +0200
+@@ -97,6 +97,6 @@
+ QMAKE_LIBS =
+ QMAKE_LIBS_CORE = -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 -lz -lpcre16
+-QMAKE_LIBS_GUI = -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lws2_32 -lole32 -luuid -luser32 -ladvapi32 -ljpeg -lpng -lharfbuzz -lglib-2.0 -lintl -lwinmm
++QMAKE_LIBS_GUI = -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lws2_32 -lole32 -luuid -luser32 -ladvapi32 -ljpeg -lpng $$system($${CROSS_COMPILE}pkg-config --static --libs harfbuzz) $$system($${CROSS_COMPILE}pkg-config --static --libs freetype2)
+ QMAKE_LIBS_NETWORK = -lws2_32 -lcrypt32 -ldnsapi
+ QMAKE_LIBS_OPENGL = -lglu32 -lopengl32 -lgdi32 -luser32
+ QMAKE_LIBS_OPENGL_ES2 = -l$${LIBEGL_NAME} -l$${LIBGLESV2_NAME} -ld3d9 -ldxguid -lgdi32 -luser32
diff --git a/qt5-use-system-zlib-in-host-libs.patch b/qt5-use-system-zlib-in-host-libs.patch
new file mode 100644
index 000000000000..311e5a981d44
--- /dev/null
+++ b/qt5-use-system-zlib-in-host-libs.patch
@@ -0,0 +1,11 @@
+--- src/tools/bootstrap/bootstrap.pro.orig 2016-06-14 17:01:24.972134372 +0200
++++ src/tools/bootstrap/bootstrap.pro 2016-05-25 17:46:17.000000000 +0200
+@@ -132,7 +132,7 @@
+ ../../corelib/io/qstandardpaths_win.cpp
+ }
+
+-contains(QT_CONFIG, zlib)|cross_compile {
++contains(QT_CONFIG, zlib) {
+ include(../../3rdparty/zlib.pri)
+ } else {
+ CONFIG += no_core_dep
diff --git a/qt5-use-win32-g++-mkspecs-profile.patch b/qt5-use-win32-g++-mkspecs-profile.patch
new file mode 100644
index 000000000000..5fc41308adf4
--- /dev/null
+++ b/qt5-use-win32-g++-mkspecs-profile.patch
@@ -0,0 +1,58 @@
+--- mkspecs/win32-g++/qmake.conf.orig 2016-06-14 16:22:02.779947341 +0200
++++ mkspecs/win32-g++/qmake.conf 2016-06-14 16:38:56.298752668 +0200
+@@ -25,7 +25,7 @@
+ QMAKE_LEXFLAGS =
+ QMAKE_YACC = byacc
+ QMAKE_YACCFLAGS = -d
+-QMAKE_CFLAGS = -pipe -fno-keep-inline-dllexport
++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
+@@ -67,10 +67,10 @@
+
+ QMAKE_LINK = $${CROSS_COMPILE}g++
+ QMAKE_LINK_C = $${CROSS_COMPILE}gcc
+-QMAKE_LFLAGS =
++QMAKE_LFLAGS = -g
+ QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads
+ QMAKE_LFLAGS_EXCEPTIONS_OFF =
+-QMAKE_LFLAGS_RELEASE = -Wl,-s
++QMAKE_LFLAGS_RELEASE =
+ QMAKE_LFLAGS_DEBUG =
+ QMAKE_LFLAGS_CONSOLE = -Wl,-subsystem,console
+ QMAKE_LFLAGS_WINDOWS = -Wl,-subsystem,windows
+@@ -95,21 +95,26 @@
+ QMAKE_LIB_EXTENSIONS = a dll.a
+
+ QMAKE_LIBS =
+-QMAKE_LIBS_CORE = -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32
+-QMAKE_LIBS_GUI = -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lws2_32 -lole32 -luuid -luser32 -ladvapi32
+-QMAKE_LIBS_NETWORK = -lws2_32
++QMAKE_LIBS_CORE = -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 -lz -lpcre16
++QMAKE_LIBS_GUI = -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lws2_32 -lole32 -luuid -luser32 -ladvapi32 -ljpeg -lpng -lharfbuzz -lglib-2.0 -lintl -lwinmm
++QMAKE_LIBS_NETWORK = -lws2_32 -lcrypt32 -ldnsapi
+ QMAKE_LIBS_OPENGL = -lglu32 -lopengl32 -lgdi32 -luser32
+-QMAKE_LIBS_OPENGL_ES2 = -l$${LIBEGL_NAME} -l$${LIBGLESV2_NAME} -lgdi32 -luser32
+-QMAKE_LIBS_OPENGL_ES2_DEBUG = -l$${LIBEGL_NAME}d -l$${LIBGLESV2_NAME}d -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 -lqtmain
++QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqt5main
+
+-QMAKE_IDL = midl
++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
++
+ load(qt_config)
diff --git a/qt5-win32-static-cmake-link-ws2_32-and--static.patch b/qt5-win32-static-cmake-link-ws2_32-and--static.patch
new file mode 100644
index 000000000000..be20044903f1
--- /dev/null
+++ b/qt5-win32-static-cmake-link-ws2_32-and--static.patch
@@ -0,0 +1,15 @@
+--- src/corelib/Qt5CoreConfigExtras.cmake.in.orig 2014-11-09 00:54:20.852201500 +0000
++++ src/corelib/Qt5CoreConfigExtras.cmake.in 2014-11-09 00:55:52.437439900 +0000
+@@ -165,3 +165,12 @@
+ set(_Qt5CTestMacros \"${_Qt5CoreConfigDir}/Qt5CTestMacros.cmake\")
+
+ _qt5_Core_check_file_exists(${_Qt5CTestMacros})
++
++get_target_property(_libType Qt5::Core TYPE)
++if(_libType STREQUAL \"STATIC_LIBRARY\" AND WIN32)
++ set(_isExe $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>)
++ # INTERFACE_LINK_LIBRARIES is used to pass a linker flag (-static)
++ # and a library (ws2_32)
++ set_target_properties(Qt5::Core PROPERTIES \"INTERFACE_LINK_LIBRARIES\" \"$<${_isExe}:-static;ws2_32>\")
++ unset(_isExe)
++endif()
diff --git a/qt5-workaround-pkgconfig-install-issue.patch b/qt5-workaround-pkgconfig-install-issue.patch
new file mode 100644
index 000000000000..46e561aac048
--- /dev/null
+++ b/qt5-workaround-pkgconfig-install-issue.patch
@@ -0,0 +1,46 @@
+--- qmake/generators/makefile.cpp.pkgconfig 2013-01-29 20:03:12.000000000 +0100
++++ qmake/generators/makefile.cpp 2013-03-26 19:18:07.480722316 +0100
+@@ -3102,7 +3102,7 @@
+ }
+
+ QString
+-MakefileGenerator::pkgConfigFileName(bool fixify)
++MakefileGenerator::pkgConfigFileName(bool fixify, bool onlyPrependDestdir)
+ {
+ QString ret = project->first("QMAKE_PKGCONFIG_FILE").toQString();
+ if (ret.isEmpty()) {
+@@ -3134,7 +3134,11 @@
+ 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;
+ }
+--- qmake/generators/makefile.h.orig 2013-03-26 19:17:37.624199870 +0100
++++ qmake/generators/makefile.h 2013-03-26 19:17:56.327527157 +0100
+@@ -102,7 +102,7 @@
+ 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
+
+--- qmake/generators/win32/winmakefile.cpp.orig 2013-03-26 19:05:13.398183953 +0100
++++ qmake/generators/win32/winmakefile.cpp 2013-03-26 19:15:02.800490466 +0100
+@@ -822,7 +822,7 @@
+ }
+ 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));