File mingw32-libqt5-qtbase.spec of Package mingw32-libqt5-qtbase

#
# spec file for package mingw32-libqt5-qtbase
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


#%%global pre beta1
%global platform_win32 win32-g++-cross
%global source_folder qtbase-opensource-src-%{version}%{?pre:-%pre}
Name:           mingw32-libqt5-qtbase-meta
Version:        5.4.0
Release:        0
Summary:        Qt5 for Windows - QtBase component
License:        GPL-3.0 or SUSE-LGPL-2.1-with-digia-exception-1.1
Group:          Development/Libraries
Url:            http://www.qt-project.org/
Source0:        qtbase-opensource-src-%{version}%{?pre:-%pre}.tar.xz
Source1:        qt.conf

# Fedora patches, not from us:
Patch1:         qt5-workaround-pkgconfig-install-issue.patch
Patch2:         qt5-dont-add-resource-files-to-qmake-libs.patch
Patch3:         qt5-prevent-debug-library-names-in-pkgconfig-files.patch
Patch4:         qt5-qmake-implib-dll-a.patch
Patch6:         qt5-dont-search-ssleay.diff

# Patches from Fedora for mingw builds
Patch100:       qt5-use-win32-g++-mkspecs-profile.patch
Patch102:       qt5-add-angle-support.patch
Patch103:       qt5-use-external-angle-library.patch
Patch104:       qt5-qtbase-fix-linking-against-static-pcre.patch
Patch105:       qt5-dont-build-host-libs-static.patch
Patch106:       qt5-enable-rpath-for-host-tools.patch
Patch107:       qt5-use-system-zlib-in-host-libs.patch

# Platform specific patches done by danimo
Patch1001:      qt5-rename-icuin-lib.patch
Patch1002:      qt5-dont-use-winflex.patch
Patch1003:      qt5-qt5main-name-fix.patch

# qt5-detect-proxy-change.patch => 0017-Win32-Re-init-system-proxy-if-internet-settings-chan.patch
Patch1004:      qt5-detect-proxy-change.patch

# qt5-ssl-cert-download-crash.patch => 0018-Windows-Do-not-crash-if-SSL-context-is-gone-after-ro.patch
Patch1005:      qt5-ssl-cert-download-crash.patch

# qt5-correctly-handle-connection-closed.patch => 0007-X-Network-Fix-up-previous-corruptio
Patch1007:      qt5-correctly-handle-connection-closed.patch

# another platform patch for gcc 5 
Patch1008:      qt5-gcc5.patch

# qt5-socketclose.patch => 0010-Don-t-let-closed-http-sockets-pass-as-valid-connecti.patch
Patch1010:      qt5-socketclose.patch

# need to come from git, with the same name 
Patch2000:      0007-QNAM-Fix-upload-corruptions-when-server-closes-conne.patch
Patch2001:      0008-QNAM-Fix-reply-deadlocks-on-server-closing-connectio.patch
Patch2002:      0009-QNAM-Assign-proper-channel-before-sslErrors-emission.patch
Patch2003:      0011-Make-sure-to-report-correct-NetworkAccessibility.patch
Patch2004:      0012-Make-sure-networkAccessibilityChanged-is-emitted.patch
Patch2005:      0013-Make-UnknownAccessibility-not-block-requests.patch

BuildRequires:  binutils
BuildRequires:  bison
BuildRequires:  dos2unix
BuildRequires:  flex
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  mingw32-angleproject-devel
BuildRequires:  mingw32-cross-binutils
BuildRequires:  mingw32-cross-gcc
BuildRequires:  mingw32-cross-gcc-c++
BuildRequires:  mingw32-cross-pkg-config
BuildRequires:  mingw32-dbus-1-devel
BuildRequires:  mingw32-filesystem
BuildRequires:  mingw32-libicu-devel
BuildRequires:  mingw32-libjpeg-devel
BuildRequires:  mingw32-libopenssl-devel
BuildRequires:  mingw32-libpng-devel
BuildRequires:  mingw32-libtiff-devel
BuildRequires:  mingw32-pcre-devel
BuildRequires:  mingw32-sqlite-devel
BuildRequires:  mingw32-win_iconv-devel
BuildRequires:  mingw32-zlib-devel
BuildRequires:  xz
BuildRequires:  zip
BuildRequires:  zlib-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%{_mingw32_package_header_debug}
#!BuildIgnore: post-build-checks

%description -n mingw32-libqt5-qtbase-meta
This is a meta-package.

%package -n mingw32-cross-libqt5-qmake
Summary:        Qt5 for native tools
Group:          Development/Libraries

%description -n mingw32-cross-libqt5-qmake
This package contains the build environment for cross compiling
applications with the MinGW Qt Library and cross-compiler.

%package -n mingw32-libqt5-qtbase
Summary:        Qt5 for Windows build environment
Group:          Development/Libraries
#Requires:      mingw32-libqt5-qttools-lrelease
BuildArch:      noarch

%description -n mingw32-libqt5-qtbase
This package contains the Qt software toolkit for developing
cross-platform applications.

This is the Windows version of Qt, for use in conjunction with the
MinGW cross-compiler.

%package -n mingw32-libqt5-qtbase-devel
Summary:        Qt5 for Windows build environment
Group:          Development/Libraries
Requires:       mingw32-libqt5-qtbase = %{version}-%{release}
BuildArch:      noarch

%description -n mingw32-libqt5-qtbase-devel
Contains the files required to get various Qt tools built
which are part of the mingw-qt5-qttools package

%_mingw32_debug_package

%prep
%setup -q -n %{source_folder}
cp -p %SOURCE1 .

# Note: some patches don't have a -b argument here
# This was done on purpose as the Qt build infrastructure
# automatically copies the entire mkspecs folder to
# the RPM_BUILD_ROOT. To prevent patch backups from
# appearing in the resulting RPMs we have to avoid
# using the -b argument here while applying patches
%patch1 -p1 -b .pkgconfig
%patch2 -p1 -b .res
%patch3 -p1 -b .pkgconfig_debug
%patch4 -p1 -b .qmake_implib
%patch6 -p1

%patch100
#%%patch101
%patch102 -p0 -b .angle
%patch103 -p0 -b .external_angle
%patch104 -p1 -b .pcre
%patch105
%patch106 -p1
%patch107 -p1 -b .host_system_zlib

%patch1001 -p1
%patch1002 -p1
%patch1003 -p1
%patch1004 -p1
%patch1005 -p1
%patch2000 -p1
%patch1007 -p1
%patch1008 -p1
%patch1010 -p1

%patch2001 -p1
%patch2002 -p1
%patch2003 -p1
%patch2004 -p1
%patch2005 -p1


# Make sure the Qt5 build system uses our external ANGLE library
## Disabled in OBS as long as there's no external ANGLE package
rm -rf src/3rdparty/angle include/QtANGLE/{EGL,GLES2,KHR}

# As well as our external PCRE library
rm -rf src/3rdparty/pcre

%build
# Generic configure arguments
qt_configure_args_generic="\
    -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 \
    -no-fontconfig \
    -iconv \
    -openssl \
    -no-glib \
    -no-gtkstyle \
    -icu \
    -release \
    -nomake examples \
    -opengl \
    -dbus-linked \
    -make tools"

qt_configure_args_win32="\
    -hostprefix %{_prefix}/%{_mingw32_target} \
    -hostbindir %{_prefix}/%{_mingw32_target}/bin/qt5 \
    -hostdatadir %{_mingw32_datadir}/qt5 \
    -prefix %{_mingw32_prefix} \
    -bindir %{_mingw32_bindir} \
    -archdatadir %{_mingw32_datadir}/qt5 \
    -datadir %{_mingw32_datadir}/qt5 \
    -docdir %{_mingw32_docdir}/qt5 \
    -examplesdir %{_mingw32_datadir}/qt5/examples \
    -headerdir %{_mingw32_includedir}/qt5 \
    -libdir %{_mingw32_libdir} \
    -plugindir %{_mingw32_libdir}/qt5/plugins \
    -sysconfdir %{_mingw32_sysconfdir} \
    -translationdir %{_mingw32_datadir}/qt5/translations \
    -device-option CROSS_COMPILE=%{_mingw32_target}-"

# RPM automatically sets the environment variable PKG_CONFIG_PATH
# to point to the native pkg-config files, but while cross compiling
# we don't want to have this environment variable set
unset PKG_CONFIG_PATH

###############################################################################
# Win32
#

# The LD_LIBRARY_PATH override is needed because libQt5Bootstrap is a shared
# library which various compiled tools (like moc) use. As the libQt5Bootstrap
# library isn't installed at this point yet, we have to workaround this
rm -rf ../build_release_shared_win32
mkdir ../build_release_shared_win32
pushd ../build_release_shared_win32
../%{source_folder}/configure \
    -shared \
    $qt_configure_args_win32 $qt_configure_args_generic
LD_LIBRARY_PATH=`pwd`/lib make %{?_smp_mflags}
popd

%install
make install -C ../build_release_shared_win32$BUILDDIR INSTALL_ROOT=%{buildroot}

# The mingw gcc compiler assumes that %%{_prefix}/%%{_mingw32_target}/lib and
# %%{prefix}/%%{mingw64_target}/lib are paths which need to be searched
# during linking for cross-compiled libraries. As this isn't intended and
# introduces unwanted side effects (related to building mingw-qt5-qttools)
# remove the reference to it
sed -i s@'"%{_prefix}/%{_mingw32_target}/lib" '@@g %{buildroot}%{_mingw32_datadir}/qt5/mkspecs/qconfig.pri

# Rename qtmain.a to a non-conflicting file name
# The updated filename is already set correctly in the bundled mkspecs profiles
mv %{buildroot}%{_mingw32_libdir}/libqtmain.a %{buildroot}%{_mingw32_libdir}/libqt5main.a

# The .dll's are installed in both %%{_mingw32_bindir} and %%{_mingw32_libdir}
# One copy of the .dll's is sufficient
rm -f %{buildroot}%{_mingw32_libdir}/*.dll

# Drop all the files which we don't need
rm -f  %{buildroot}%{_mingw32_libdir}/*.prl

rm -f  %{buildroot}%{_prefix}/%{_mingw32_target}/lib/libQt5Bootstrap.la
rm -f  %{buildroot}%{_prefix}/%{_mingw32_target}/lib/libQt5Bootstrap*.prl
rm -rf %{buildroot}%{_prefix}/%{_mingw32_target}/lib/pkgconfig

# drop all dbus debug symbols
rm -rf %{buildroot}%{_prefix}/lib/debug

# Add qtchooser support
mkdir -p %{buildroot}%{_sysconfdir}/xdg/qtchooser
echo "%{_prefix}/%{_mingw32_target}/bin/qt5" >  %{buildroot}%{_sysconfdir}/xdg/qtchooser/mingw32-qt5.conf
echo "%{_mingw32_prefix}" >> %{buildroot}%{_sysconfdir}/xdg/qtchooser/mingw32-qt5.conf

# Manually install qmake and other native tools so we don't depend anymore on
# the version of the native Qt and also fix issues as illustrated at
# http://stackoverflow.com/questions/6592931/building-for-windows-under-linux-using-qt-creator
#
# Also make sure the tools can be found by CMake
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_prefix}/%{_mingw32_target}/bin

for tool in qmake moc rcc uic qdoc qdbuscpp2xml qdbusxml2cpp syncqt.pl; do
    ln -s ../%{_mingw32_target}/bin/qt5/$tool %{buildroot}%{_bindir}/%{_mingw32_target}-$tool-qt5
done

ln -s %{_mingw32_target}-qmake-qt5 %{buildroot}%{_bindir}/mingw32-qmake-qt5

# install qt.conf for correct install pathes on runtime
cp ../%{source_folder}/qt.conf %{buildroot}/%{_mingw32_bindir}

%post -n mingw32-cross-libqt5-qmake -p /sbin/ldconfig

%postun -n mingw32-cross-libqt5-qmake -p /sbin/ldconfig

%files -n mingw32-libqt5-qtbase
%defattr(-, root, root)
%{_mingw32_bindir}/Qt5*.dll
%{_mingw32_bindir}/qt.conf
%{_mingw32_libdir}/qt5/
%exclude %{_mingw32_libdir}/qt5/*/*/*.debug

%files -n mingw32-libqt5-qtbase-devel
%defattr(-, root, root)
%{_mingw32_libdir}/libQt5*.a
%{_mingw32_libdir}/libqt*.a
%{_mingw32_libdir}/pkgconfig/*.pc
%{_mingw32_libdir}/cmake/
%{_mingw32_includedir}/qt5/
%{_mingw32_docdir}/qt5/

%files -n mingw32-cross-libqt5-qmake
%defattr(-, root, root)
%doc LGPL_EXCEPTION.txt LICENSE.FDL LICENSE.LGPLv21 LICENSE.LGPLv3 LICENSE.PREVIEW.COMMERCIAL
%{_bindir}/*-qt5
%{_prefix}/%{_mingw32_target}/bin/qt5/
%{_prefix}/%{_mingw32_target}/lib/libQt5Bootstrap*.so*
%{_mingw32_datadir}/qt5/

# qtchooser
%dir %{_sysconfdir}/xdg/qtchooser/
# not editable config files, so not using %%config here
%{_sysconfdir}/xdg/qtchooser/mingw32-qt5.conf

%changelog
openSUSE Build Service is sponsored by