File macros.mingw32-qt6 of Package mingw32-qt6-macros
#
# Macros for Qt6 packages
#
# SPDX-License-Identifier: MIT
#
####################################################################
# Provides the following macros:
#
# %%_mingw32_cmake_qt6
# Runs CMake using the default paths for Qt6 packages
#
# %%_mingw32_qt6_build
# Builds the project with the selected build tool
#
# %%_mingw32_qt6_install
# Installs the project once built
#
# %%_mingw32_qt6_use_make
# Use 'make' instead of 'ninja' for building
#
# Alternatively, you can add the following line in your spec file:
# %%global %%__mingw32_qt6_build_tool make
#
# %%_mingw32_qt6_build_docs
# Build the documentation for the package
#
# %%_mingw32_qt6_install_docs
# Install the generated documentation
#
# %%_mingw32_qt6_doc_packages
# Creates documentation packages.
# When using this macro, two subpackages will be defined for
# qch and html docs.
#
# See below for details about documentation packages
#
# %%_mingw32_qt6_examples_package
# If the package you're building contains examples, this macro
# will create a -examples subpackages and handle the installed
# files.
#
# %%_mingw32_qt6_link_executables
# Executables are installed in %%_mingw32_qt6_bindir.
# To avoid conflicts with older versions, symlinks are created
# in %%_mingw32_bindir with the '6' suffix.
# You may call this macro in your %install section to create the
# links.
#
# %%_mingw32_qmake6
# Configure a project using qmake
#
# %%_mingw32_qmake6_build
# Builds a project configured using the %%_mingw32_qmake6 macro
#
# %%qmake6_install
# Installs a project configured using the %%_mingw32_qmake6 macro
#
####################################################################
####################################################################
# Notes about documentation packages:
#
# There are different ways to create documentation packages.
#
# NOTE: all methods described below need a 'BuildRequires: mingw32-qt6-tools'
# line.
#
# Method #1: Build flavors (recommended)
# The build service allows building different packages with a
# single spec file.
#
# Create a _multibuild file containing:
# <multibuild>
# <flavor>docs</flavor>
# </multibuild>
#
# Add this to the spec file header, add:
#
# %global qt6_flavor @BUILD_FLAVOR@%{nil}
#
# The following code shall be added after the other build requirements:
#
# %if "%qt6_flavor" == "docs"
# BuildRequires: mingw32-qt6-tools
# %{_mingw32_qt6_doc_packages}
# %endif
#
# This will ensure the 'mingw32-qt6-tools' package is installed for building
# documentation and also define and populate the two documentation
# subpackages.
#
# Two commands are available to disable parts of the spec file that are
# not needed when building the 'docs' flavor:
# %if %{qt6_docs_flavor} : true if the docs flavor is built
# %if !%{qt6_docs_flavor} : true if the docs flavor is not built
# (note the position of the '!' sign)
#
# They shall be used to ignore:
# - non-docs packages descriptions
# - post-install actions
# - %files sections
#
#
# Method #2: doc subpackage
# Create a spec file for the documentation package.
# The %%_mingw32_qt6_doc_packages macro will create the %%package and
# %%files sections for both the QCH and HTML documentation
# packages.
#
# The %%_mingw32_qt6_build_docs and %%_mingw32_qt6_install_docs macros will
# respectively replace the %%_mingw32_qt6_build and %%_mingw32_qt6_install
# invokations.
#
# When using a documentation subpackage, it is recommended to copy
# the 'BuildRequires' and '%%bcond' lines from the main package
# spec file.
#
# Example:
# In mingw32-qt6-svg-docs.spec, use %%_mingw32_qt6_doc_packages, %%_mingw32_qt6_build_docs
# and %%_mingw32_qt6_install_docs.
# 2 subpackages will be defined (mingw32-qt6-svg-docs-html and mingw32-qt6-svg-docs-qch)
# and the respective %files sections will be populated automatically.
#
####################################################################
#--------------------------------------------------------------
%qt6_docs_flavor ("%qt6_flavor" == "docs")
#--------------------------------------------------------------
# Default paths
%__mingw32_qt6_sourcedir .
%__mingw32_qt6_builddir build
# Use 'ninja' by default.
# Alternative: Use the %%qt6_use_make macro
%__mingw32_qt6_build_tool %__ninja
# Default build type
%__mingw32_qt6_build_type RelWithDebInfo
# Module name (without the 'qt6-' prefix)
%__mingw32_qt6_module_name %(echo %{name} | cut -d'-' -f2)
# _mingw32_qt6_<variable> shall be used in files sections
%_mingw32_qt6_prefix %{_mingw32_prefix}
%_mingw32_qt6_libdir %{_mingw32_libdir}
%_mingw32_qt6_includedir %{_mingw32_includedir}/qt6
%_mingw32_qt6_sharedir %{_mingw32_datadir}
%_mingw32_qt6_archdatadir %{_mingw32_qt6_libdir}/qt6
%_mingw32_qt6_bindir %{_mingw32_qt6_archdatadir}/bin
%_mingw32_qt6_examplesdir %{_mingw32_qt6_archdatadir}/examples
%_mingw32_qt6_importsdir %{_mingw32_qt6_archdatadir}/imports
%_mingw32_qt6_libexecdir %{_mingw32_qt6_archdatadir}/libexec
%_mingw32_qt6_mkspecsdir %{_mingw32_qt6_archdatadir}/mkspecs
%_mingw32_qt6_pluginsdir %{_mingw32_qt6_archdatadir}/plugins
%_mingw32_qt6_qmldir %{_mingw32_qt6_archdatadir}/qml
%_mingw32_qt6_testsdir %{_mingw32_qt6_archdatadir}/tests
%_mingw32_qt6_datadir %{_mingw32_qt6_sharedir}/qt6
%_mingw32_qt6_docdir %{_mingw32_qt6_datadir}/doc
%_mingw32_qt6_descriptionsdir %{_mingw32_qt6_datadir}/modules
%_mingw32_qt6_translationsdir %{_mingw32_qt6_datadir}/translations
# Use %%{_mingw32_sysconfdir}/xdg if %%{_mingw32_distconfdir} is undefined
%_mingw32_qt6_sysconfdir %{?_mingw32_distconfdir:%{_mingw32_distconfdir}/xdg}%{!?_mingw32_distconfdir:%{_mingw32_sysconfdir}/xdg}
# Variables only used for packaging
%_mingw32_qt6_cmakedir %{_mingw32_qt6_libdir}/cmake
%_mingw32_qt6_metatypesdir %{_mingw32_qt6_libdir}/metatypes
# mingw32 specific
%_mingw32_build_requires BuildRequires: mingw32-cross-pkgconf
#--------------------------------------------------------------
%_mingw32_qt6_use_make %global __mingw32_qt6_build_tool %__make
#--------------------------------------------------------------
%_mingw32_cmake_qt6 \
%_mingw32_cmake -DCMAKE_BUILD_TYPE:STRING=%{__mingw32_qt6_build_type} \\\
-DCMAKE_INSTALL_PREFIX:STRING=%{_mingw32_qt6_prefix} \\\
-DINSTALL_MKSPECSDIR:STRING=%{_mingw32_qt6_mkspecsdir} \\\
-DINSTALL_ARCHDATADIR:STRING=%{_mingw32_qt6_archdatadir} \\\
-DINSTALL_DATADIR:STRING=%{_mingw32_qt6_datadir} \\\
-DINSTALL_INCLUDEDIR:STRING=%{_mingw32_qt6_includedir} \\\
-DPKG_CONFIG_EXECUTABLE=/usr/bin/%{_mingw32_target}-pkgconf \\\
-S %__mingw32_qt6_sourcedir \\\
-B %__mingw32_qt6_builddir \\\
%if "%__mingw32_qt6_build_tool" == "%__ninja" \
-GNinja \\\
%else \
-G"Unix Makefiles" \\\
%endif
#--------------------------------------------------------------
%__mingw32_qt6_build_options %__mingw32_qt6_builddir %{?_smp_mflags}
#--------------------------------------------------------------
%_mingw32_qt6_build \
%if %{qt6_docs_flavor} \
%{_mingw32_qt6_build_docs} \
%else \
cmake --build %{__mingw32_qt6_build_options} -v \
%endif
#--------------------------------------------------------------
# NOTE:
# The tools used to build building qch docs need to find
# the 'minimal' QPA plugin and the path to the sqlite plugin location
%_mingw32_qt6_build_docs \
export QT_QPA_PLUGIN_PATH="%{_mingw32_qt6_pluginsdir}/platforms" \
export QT_PLUGIN_PATH="%{_mingw32_qt6_pluginsdir}" \
%_mingw32_cmake --build %{__mingw32_qt6_build_options} -t docs \
%{nil}
#--------------------------------------------------------------
# Note: The 'ninja' generator doesn't create 'install/fast' targets.
%_mingw32_qt6_install \
%if %{qt6_docs_flavor} \
%{_mingw32_qt6_install_docs} \
%else \
DESTDIR=%{buildroot} cmake --build %{__mingw32_qt6_build_options} -v \\\
%if "%__mingw32_qt6_build_tool" == "%__make" \
-t install/fast \
%else \
-t install \
%endif \
%endif
#--------------------------------------------------------------
%_mingw32_qt6_install_docs \
DESTDIR=%{buildroot} cmake --build %{__mingw32_qt6_build_options} -t install_docs \
# in Qt 6.0.0, %%{_mingw32_qt6_docdir}/*.qch are folders which contain \
# files with the same name. \
# Starting with 6.0.1, the file is installed in %%{_qt6_docdir} directly. \
# We need a %%pre scriptlet to remove the old folder before upgrading. \
_current_dir=`pwd` \
pushd %{buildroot}%{_mingw32_qt6_docdir} \
for qch_file in *.qch ; do \
echo "if [ -d %{_mingw32_qt6_docdir}/${qch_file} ] ; then rm -r %{_mingw32_qt6_docdir}/${qch_file} ; fi" >> ${_current_dir}/qch.pre \
done \
popd \
%{nil}
#--------------------------------------------------------------
%_mingw32_qt6_link_executables \
mkdir -p %{buildroot}%{_mingw32_bindir} \
pushd %{buildroot}%{_mingw32_qt6_bindir} \
for i in * ; do \
ln -s %{_mingw32_qt6_bindir}/$i %{buildroot}%{_mingw32_bindir}/${i}6 \
done \
popd \
%{nil}
#--------------------------------------------------------------
# The %%_mingw32_qt6_doc_packages macro shall produce packages with
# correct names if invoked in qt6-foo-docs.spec but also if
# called from qt6-foo.spec
%__mingw32_qt6_doc_package_name mingw32-qt6-%{__mingw32_qt6_module_name}-docs
%_mingw32_qt6_doc_packages \
%package -n %{__mingw32_qt6_doc_package_name}-html \
Summary: Documentation for qt6-%{__mingw32_qt6_module_name} in HTML format \
License: GFDL-1.3-or-later \
\
%description -n %{__mingw32_qt6_doc_package_name}-html \
This package contains documentation for qt6-%{__mingw32_qt6_module_name} in HTML format. \
\
%package -n %{__mingw32_qt6_doc_package_name}-qch \
Summary: Documentation for qt6-%{__mingw32_qt6_module_name} in QCH format \
License: GFDL-1.3-or-later \
\
%description -n %{__mingw32_qt6_doc_package_name}-qch \
This package contains documentation for qt6-%{__mingw32_qt6_module_name} in QCH format. \
\
%pre -n %{__mingw32_qt6_doc_package_name}-qch -f qch.pre \
\
%files -n %{__mingw32_qt6_doc_package_name}-html \
%dir %{_mingw32_qt6_docdir} \
%{_mingw32_qt6_docdir}/* \
%exclude %{_mingw32_qt6_docdir}/*.qch \
\
%files -n %{__mingw32_qt6_doc_package_name}-qch \
%dir %{_mingw32_qt6_docdir} \
%{_mingw32_qt6_docdir}/*.qch \
%{nil}
#--------------------------------------------------------------
%_mingw32_qt6_examples_package \
%package examples \
Summary: Examples for the %{name} modules \
\
%description examples \
Examples for the %{name} modules. \
\
%files examples \
%{_mingw32_qt6_examplesdir}/* \
%{nil}
#--------------------------------------------------------------
# qmake still exists in Qt6
%__mingw32_qt6_qmake %{_mingw32_qt6_bindir}/qmake
#--------------------------------------------------------------
%_mingw32_qmake6 \
%__mingw32_qt6_qmake \\\
QMAKE_CXXFLAGS="$CXXFLAGS %{optflags}" \\\
QMAKE_CFLAGS="$CFLAGS %{optflags}" \\\
QMAKE_LFLAGS="$LDFLAGS -Wl,--as-needed -Wl,--no-undefined"
#--------------------------------------------------------------
%_mingw32_qmake6_build \
%{__make} %{?_smp_mflags} VERBOSE=1
#--------------------------------------------------------------
%_mingw32_qmake6_install \
%{__make} INSTALL_ROOT=%{buildroot} install
#--------------------------------------------------------------