File mingw64-kdoctools.spec of Package mingw64-kdoctools

#
# spec file for package mingw64-kdoctools
#
# Copyright (c) 2019 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%define lname   libKF5DocTools5
%define _tar_path 5.103
# Full KF5 version (e.g. 5.33.0)
%{!?_mingw64_kf5_version: %global _mingw64_kf5_version %{version}}
# Last major and minor KF5 version (e.g. 5.33)
%{!?_mingw64_kf5_bugfix_version: %define _mingw64_kf5_bugfix_version %(echo %{_mingw64_kf5_version} | awk -F. '{print $1"."$2}')}
%bcond_without lang
%define _name   kdoctools
Name:           mingw64-%{_name}
Version:        5.103.0
Release:        0
Summary:        Tools to create documentation from DocBook
License:        LGPL-2.1-or-later AND MIT
Group:          System/GUI/KDE
URL:            https://www.kde.org
Source:         https://download.kde.org/stable/frameworks/%{_tar_path}/%{_name}-%{version}.tar.xz
%if %{with lang}
Source1:        https://download.kde.org/stable/frameworks/%{_tar_path}/%{_name}-%{version}.tar.xz.sig
Source2:        frameworks.keyring
%endif
# PATCH-FEATURE-OPENSUSE
Patch1:         0001-Also-return-KDE4-docs-in-documentationDirs.patch
Patch2:         0001-Let-docbookl10nhelper-executable-name-follow-conventio.patch
Patch3:         kdoctools-5.103.0-use-meinproc5_executable.patch
# for native build
BuildRequires:  cmake(Qt5Core)
BuildRequires:  docbook-xsl-stylesheets
BuildRequires:  docbook_4
BuildRequires:  mingw64-cross-extra-cmake-modules
BuildRequires:  mingw64-cross-karchive-devel
BuildRequires:  pkgconfig(libxslt)
BuildRequires:  pkgconfig(libxml-2.0)
# for mingw64 build
BuildRequires:  mingw64-cross-cmake
BuildRequires:  mingw64-cross-gcc-c++
BuildRequires:  mingw64-docbook-xsl-stylesheets
BuildRequires:  mingw64-docbook_4
BuildRequires:  mingw64-extra-cmake-modules >= %{_mingw64_kf5_bugfix_version}
BuildRequires:  mingw64-kf5-filesystem
BuildRequires:  mingw64-libxml2-devel
BuildRequires:  mingw64-libxslt-devel
BuildRequires:  perl-URI
BuildRequires:  mingw64(cmake:KF5Archive) >= %{_mingw64_kf5_bugfix_version}
BuildRequires:  mingw64(cmake:KF5I18n) >= %{_mingw64_kf5_bugfix_version}
BuildRequires:  mingw64(cmake:Qt5Core) >= 5.11.0
# The XSL templates reference files in here
Requires:       mingw64-docbook-xsl-stylesheets
Recommends:     %{name}-lang
%_mingw64_package_header_debug

%description
Provides tools to generate documentation in various format from DocBook files.

%package -n mingw64-%{lname}
Summary:        Library to create documentation from DocBook
Group:          System/Libraries
%requires_ge    mingw64-libQt5Core5
Recommends:     %{name} = %{version}
BuildArch:      noarch

%description -n mingw64-%{lname}
Provides tools to generate documentation in various format from DocBook files.

%package -n mingw64-cross-kdoctools-tools
Summary:        Native utilities for KDocTools
Group:          Development/Libraries/KDE
# have choice for libKF5Archive.so.5()(64bit) needed by mingw64-cross-kdoctools-tools: libKF5Archive5 mingw64-cross-libKF5Archive5
Requires:       mingw64-cross-libKF5Archive5

%description -n mingw64-cross-kdoctools-tools
Native utilities for KDoctools to generate documentation in various format from DocBook files.

%package devel
Summary:        Build environment for kdoctools
Group:          Development/Libraries/KDE
Requires:       mingw64-%{lname} = %{version}
Requires:       %{name} = %{version}
Requires:       mingw64-cross-kdoctools-tools
Requires:       mingw64-docbook-xsl-stylesheets
Requires:       mingw64-extra-cmake-modules >= 1.8.0
Requires:       mingw64-libxslt-devel
Requires:       mingw64(cmake:Qt5Core) >= 5.11.0
Provides:       %{name}-devel-static = %{version}
BuildArch:      noarch

%description devel
Provides tools to generate documentation in various format from DocBook files.
Development files.

%lang_package

%_mingw64_debug_package

%prep
%autosetup -p1 -n %{_name}-%{version}

%build
  # -DINSTALL_INTERNAL_TOOLS=1 added for installing docbookl10nhelper
  cmake -B native-build -DCMAKE_INSTALL_PREFIX=/usr/%{_mingw64_target} -DINSTALL_INTERNAL_TOOLS=1
  cmake --build native-build -t meinproc5
  cmake --build native-build -t checkXML5
  cmake --build native-build -t docbookl10nhelper

  OPTIONS="-DDOCBOOKL10NHELPER_EXECUTABLE=$PWD/native-build/bin/docbookl10nhelper5 -DMEINPROC5_EXECUTABLE=$PWD/native-build/bin/meinproc5 -DCHECKXML5_EXECUTABLE=$PWD/native-build/bin/checkXML5"
  %_mingw64_cmake_kf5 -d build -- -DINSTALL_INTERNAL_TOOLS=1 $OPTIONS
  %_mingw64_cmake_build

%install
  cmake --build native-build/src/ -t install/strip   DESTDIR=%{buildroot}
  rm -rf %{buildroot}%{_prefix}/%{_mingw64_target}/include %{buildroot}%{_prefix}/%{_mingw64_target}/lib64
  
  mkdir -p %{buildroot}%{_prefix}/bin
  for i in meinproc5 checkXML5 docbookl10nhelper5; do
    ln -s ../%{_mingw64_target}/bin/$i %{buildroot}%{_prefix}/bin/%{_mingw64_target}-$i
  done

  %_mingw64_kf5_makeinstall -C build

  # make references inside xml files relative
  for i in $(find %{buildroot} -type f -name '*.dtd' -o -name '*.xml' -o -name '*.xsl'); do
    sed -i "s,../../../../../../../../../share,../../../..,g" $i
    sed -i "s,../../../../../../../../share,../../..,g" $i
    sed -i "s,%{_mingw64_datadir},../../../..,g" $i
  done

%if %{with lang}
%_mingw64_find_lang %{_name} --with-man --all-name
%endif


%if %{with lang}
%files lang -f %{_name}.lang
%endif

%files
%license LICENSES/*
%doc README*
%{_mingw64_kf5_htmldir}/*/
%{_mingw64_kf5_datadir}/kdoctools/
%{_mingw64_kf5_bindir}/meinproc5.exe
%{_mingw64_kf5_bindir}/checkXML5.exe
%{_mingw64_kf5_bindir}/docbookl10nhelper5.exe
%doc %lang(en) %{_mingw64_kf5_mandir}/*/meinproc5.*
%doc %lang(en) %{_mingw64_kf5_mandir}/*/checkXML5.*
%doc %lang(en) %{_mingw64_kf5_mandir}/*/kf5options.*
%doc %lang(en) %{_mingw64_kf5_mandir}/*/qt5options.*

%files -n mingw64-%{lname}
%license LICENSES/*
%doc README*
%{_mingw64_kf5_bindir}/libKF5DocTools*.dll

%files -n mingw64-cross-kdoctools-tools
%{_prefix}/%{_mingw64_target}/bin/meinproc5
%{_prefix}/bin/%{_mingw64_target}-meinproc5
%{_prefix}/%{_mingw64_target}/bin/checkXML5
%{_prefix}/bin/%{_mingw64_target}-checkXML5
%{_prefix}/%{_mingw64_target}/bin/docbookl10nhelper5
%{_prefix}/bin/%{_mingw64_target}-docbookl10nhelper5
%{_prefix}/%{_mingw64_target}/share

%files devel
%{_mingw64_kf5_libdir}/cmake/KF5DocTools/
%dir %{_mingw64_kf5_includedir}/*/
%{_mingw64_kf5_includedir}/*/
%{_mingw64_libdir}/libKF5DocTools.dll.a

%changelog
openSUSE Build Service is sponsored by