From ded63fbb94088c3b0fbbf9d3b3a421b2b934ab50 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Date: Tue, 10 Nov 2015 18:40:04 +0100
Subject: [PATCH] make a proper header-only module for QtZlib

that way other modules can use the headers without hacks.

this required making the base directory for paths in headers.pri
configurable in syncqt.

Change-Id: Id35cfe05bcf4c576d3f2d0d8d09590a5e23d21d3
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
---
 bin/syncqt.pl                          | 1 +
 mkspecs/features/qt_module_headers.prf | 5 +++--
 src/corelib/qtzlib.pro                 | 7 +++++++
 src/corelib/tools/tools.pri            | 4 ----
 src/src.pro                            | 4 ++++
 src/tools/bootstrap/bootstrap.pro      | 5 +----
 sync.profile                           | 2 +-
 7 files changed, 17 insertions(+), 11 deletions(-)
 create mode 100644 src/corelib/qtzlib.pro

diff --git a/bin/syncqt.pl b/bin/syncqt.pl
index ff539f5fe02..83e8350f819 100755
--- a/bin/syncqt.pl
+++ b/bin/syncqt.pl
@@ -812,6 +812,7 @@ foreach my $lib (@modules_to_sync) {
     my $is_qt = !($module =~ s/^!//);
     my @dirs = split(/;/, $module);
     my $dir = $dirs[0];
+    shift @dirs if ($dir =~ s/^>//);
 
     my $pathtoheaders = "";
     $pathtoheaders = $moduleheaders{$lib} if ($moduleheaders{$lib});
diff --git a/mkspecs/features/qt_module_headers.prf b/mkspecs/features/qt_module_headers.prf
index 3f2383c1200..78a1e38bb0e 100644
--- a/mkspecs/features/qt_module_headers.prf
+++ b/mkspecs/features/qt_module_headers.prf
@@ -38,6 +38,9 @@ git_build: \
 else: \
     INC_PATH = $$MODULE_BASE_INDIR
 include($$INC_PATH/include/$$MODULE_INCNAME/headers.pri, "", true)
+CONFIG += qt_install_headers
+
+alien_syncqt: return()
 
 for (injection, SYNCQT.INJECTIONS) {
     injects = $$split(injection, :)
@@ -82,8 +85,6 @@ SYNCQT.HEADER_FILES += $$MODULE_MASTER_DEPS_HEADER
     isEmpty(PRECOMPILED_HEADER): PRECOMPILED_HEADER = $$MODULE_MASTER_DEPS_HEADER
 }
 
-CONFIG += qt_install_headers
-
 headersclean:!internal_module {
     # Make sure that the header compiles with our strict options
     hcleanDEFS = -DQT_NO_CAST_TO_ASCII=1 \
diff --git a/src/corelib/qtzlib.pro b/src/corelib/qtzlib.pro
new file mode 100644
index 00000000000..744750fbbee
--- /dev/null
+++ b/src/corelib/qtzlib.pro
@@ -0,0 +1,7 @@
+TARGET = QtZlib
+MODULE = zlib
+MAKEFILE = Makefile.qtzlib
+CONFIG += internal_module header_module alien_syncqt
+QT =
+
+load(qt_module)
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index c43fd761d89..ed07f70e870 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -155,10 +155,6 @@ else:SOURCES += tools/qelapsedtimer_generic.cpp
 
 contains(QT_CONFIG, zlib) {
     include($$PWD/../../3rdparty/zlib.pri)
-    corelib_zlib_headers.files = $$PWD/../../3rdparty/zlib/zconf.h\
-                                 $$PWD/../../3rdparty/zlib/zlib.h
-    corelib_zlib_headers.path = $$[QT_INSTALL_HEADERS]/QtZlib
-    INSTALLS += corelib_zlib_headers
 } else {
     include($$PWD/../../3rdparty/zlib_dependency.pri)
 }
diff --git a/src/src.pro b/src/src.pro
index a970391382d..df5c85fa537 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -2,6 +2,9 @@ TEMPLATE = subdirs
 
 load(qfeatures)
 
+src_qtzlib.file = $$PWD/corelib/qtzlib.pro
+src_qtzlib.target = sub-zlib
+
 src_tools_bootstrap.subdir = tools/bootstrap
 src_tools_bootstrap.target = sub-bootstrap
 src_tools_bootstrap.CONFIG = host_build
@@ -125,6 +128,7 @@ src_plugins.depends = src_sql src_xml src_network
 src_android.subdir = $$PWD/android
 
 # this order is important
+contains(QT_CONFIG, zlib)|cross_compile: SUBDIRS += src_qtzlib
 SUBDIRS += src_tools_bootstrap src_tools_moc src_tools_rcc
 !contains(QT_DISABLED_FEATURES, regularexpression):pcre {
     SUBDIRS += src_3rdparty_pcre
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
index b6b16dcd3d3..ca05f804a2b 100644
--- a/src/tools/bootstrap/bootstrap.pro
+++ b/src/tools/bootstrap/bootstrap.pro
@@ -39,10 +39,7 @@ MODULE_PRIVATE_INCLUDES = \
 # We need the forwarding headers before their respective modules are built,
 # so do a minimal syncqt run.
 CONFIG += minimal_syncqt
-QMAKE_SYNCQT_OPTIONS = -module QtCore -module QtDBus -module QtXml
-contains(QT_CONFIG, zlib): \
-    QMAKE_SYNCQT_OPTIONS += -module QtZlib
-QMAKE_SYNCQT_OPTIONS += -version $$QT_VERSION
+QMAKE_SYNCQT_OPTIONS = -module QtCore -module QtDBus -module QtXml -version $$QT_VERSION
 
 load(qt_module)
 
diff --git a/sync.profile b/sync.profile
index 1700d94fff9..bba0ff2b2f7 100644
--- a/sync.profile
+++ b/sync.profile
@@ -16,7 +16,7 @@
     "QtANGLE/GLES2" => "!$basedir/src/3rdparty/angle/include/GLES2",
     "QtANGLE/GLES3" => "!$basedir/src/3rdparty/angle/include/GLES3",
     "QtANGLE/EGL" => "!$basedir/src/3rdparty/angle/include/EGL",
-    "QtZlib" => "!$basedir/src/3rdparty/zlib",
+    "QtZlib" => "!>$basedir/src/corelib;$basedir/src/3rdparty/zlib",
     "QtOpenGLExtensions" => "$basedir/src/openglextensions",
 );
 %moduleheaders = ( # restrict the module headers to those found in relative path
-- 
GitLab