%global xapian_core_support ON
%global BuildDir Out
Name:                doxygen
Epoch:               1
Version:             1.8.17
Release:             8
Summary:             A documentation system for C/C++
License:             GPL+
Url:                 http://www.doxygen.nl
Source0:             https://nchc.dl.sourceforge.net/project/%{name}/rel-%{version}/%{name}-%{version}.src.tar.gz
Source1:             doxywizard.desktop

Patch1:              test_suite_is_failing.patch
Patch2:              RTFGenerator-should-exit-with-0-when-gengrate-file-s.patch
Patch3:              backport-issue-7474-1.8.16-regression-HTML-output-varies-from-ASLR.patch
Patch4:              backport-issue-7706-Md5-hash-does-not-match-for-two-different-runs.patch
Patch5:              backport-issue-7583-External-Links-in-Inheritance-Diagrams-open-in-the-Image-Frame.patch
Patch6:              backport-issue-7706-Md5-hash-does-not-match-for-two-different-runs-part2.patch
Patch7:              backport-Incorrect-label-in-map-of-dot-files-in-xhtml.patch
Patch8:              backport-Incorrect-label-name-in-case-regeneration-of-HTML-without_regeneration_of_dot_files.patch
Patch9:              CVE-2020-11022_CVE-2020-11023_CVE-2020-23064.patch

BuildRequires:       python3 ImageMagick gcc-c++ gcc perl-interpreter
BuildRequires:       tex(dvips) tex(latex) tex(multirow.sty) tex(sectsty.sty) tex(tocloft.sty)
BuildRequires:       tex(xtab.sty) tex(import.sty) tex(tabu.sty) tex(appendix.sty)
BuildRequires:       tex(adjustbox.sty) /usr/bin/epstopdf texlive-epstopdf ghostscript gettext
BuildRequires:       desktop-file-utils graphviz flex bison cmake git
%if %{xapian_core_support} == "ON"
BuildRequires:       xapian-core-devel zlib-devel
%endif
Requires:            perl-interpreter graphviz
Provides:            doxygen-help
Obsoletes:           doxygen-help
%description
Doxygen is the de facto standard tool for generating documentation from
annotated C++ sources, but it also supports other popular programming
languages such as C, Objective-C, C#, PHP, Java, Python, IDL (Corba,
Microsoft, and UNO/OpenOffice flavors), Fortran, VHDL, Tcl, and to some
extent D.

%package doxywizard
Summary:             A GUI for creating and editing configuration files
Requires:            %{name} = %{epoch}:%{version}-%{release}
BuildRequires:       qt5-qtbase-devel
%description doxywizard
Doxywizard is a graphical front-end to read/edit/write doxygen
configuration files.

%prep
%autosetup -p1
iconv --from=ISO-8859-1 --to=UTF-8 LANGUAGE.HOWTO > LANGUAGE.HOWTO.new
touch -r LANGUAGE.HOWTO LANGUAGE.HOWTO.new
mv LANGUAGE.HOWTO.new LANGUAGE.HOWTO

%build
install -d %{BuildDir}
cd %{BuildDir}
%cmake \
      -DPYTHON_EXECUTABLE=%{_bindir}/python3 \
      -Dbuild_doc=OFF \
      -Dbuild_wizard=ON \
      -Dbuild_xmlparser=ON \
      -Dbuild_search=%{xapian_core_support} \
      -DMAN_INSTALL_DIR=%{_mandir}/man1 \
      -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \
      -DBUILD_SHARED_LIBS=OFF \
      ..
cd -
%make_build -C %{BuildDir}

%install
%make_install -C %{BuildDir}
convert addon/doxywizard/doxywizard.ico doxywizard.png
icondir=%{buildroot}%{_datadir}/icons/hicolor
install -m755 -d $icondir/{16x16,32x32,48x48,128x128}/apps
install -m644 -p -D doxywizard-6.png $icondir/16x16/apps/doxywizard.png
install -m644 -p -D doxywizard-5.png $icondir/32x32/apps/doxywizard.png
install -m644 -p -D doxywizard-4.png $icondir/48x48/apps/doxywizard.png
install -m644 -p -D doxywizard-3.png $icondir/128x128/apps/doxywizard.png
install -d %{buildroot}/%{_mandir}/man1
cp doc/*.1 %{buildroot}/%{_mandir}/man1/
%if %{xapian_core_support} == "OFF"
rm -f %{buildroot}/%{_mandir}/man1/doxyindexer.1* %{buildroot}/%{_mandir}/man1/doxysearch.1*
%endif
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE1}

%check
make tests -C %{BuildDir}

%files
%doc LANGUAGE.HOWTO README.md
%license LICENSE
%{_bindir}/doxygen
%{_mandir}/man1/doxygen.1*
%if %{xapian_core_support} == "ON"
%{_bindir}/{doxyindexer,doxysearch*}
%{_mandir}/man1/{doxyindexer.1*,doxysearch.1*}
%endif
%exclude %{_docdir}/packages

%files doxywizard
%{_bindir}/doxywizard
%{_mandir}/man1/doxywizard*
%{_datadir}/applications/doxywizard.desktop
%{_datadir}/icons/hicolor/*/apps/doxywizard.png

%changelog
* Wed Jul 26 2023 yaoxin <yao_xin001@hoperun.com> - 1:1.8.17-8
- Fix CVE-2020-11022,CVE-2020-11023 and CVE-2020-23064

* Fri Jun 4 2021 wangchen<wangchen137@huawei.com> - 1.8.17-7
- Fix Md5 hash does not match for two different runs.
  Fix Incorrect label name in case regeneration of HTML without regeneration of dot files.

* Sat May 22 2021 zoulin<zoulin13@huawei.com> - 1.8.17-6
- Modify version number

* Tue May 11 2021 wangchen<wangchen137@huawei.com> - 1.8.17-5
- RTFGenerator should exit with 0 when gengrate file success

* Thu Dec 10 2020 shixuantong<shixuantong@huawei.com> - 1.8.17-4
- Modify Source0

* Wed Dec 02 2020 shixuantong <shixuantong@huawei.com> - 1.8.17-3
- fix test suite fail

* Tue Dec 01 2020 shixuantong <shixuantong@huawei.com> - 1.8.17-2
- add doxygen-help to provides and obsoletes

* Mon Aug 03 2020 pengyeqing <pengyeqing@huawei.com> - 1.8.17-1
- Update to 1.8.17

* Tue Dec 10 2019 mengxian <mengxian@huawei.com> - 1:1.8.14-8
- Package init

* Mon May 6 2019 fanmenggang <fanmenggang@huawei.com> - 1:1.8.14-7.h1
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:Eliminate PDF file Differences
