Name:           cppcheck
Version:        1.83
Release:        7
Summary:        Tool for static C/C++ code analysis
License:        GPLv3+
URL:            http://cppcheck.wiki.sourceforge.net/
Source0:        http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz

Patch0000:      cppcheck-1.83-tinyxml.patch
Patch0001:      cppcheck-1.81-translations.patch
Patch0002:      cppcheck-1.78-cfgdir.patch
Patch0003:      cppcheck-1.83-cmake.patch

BuildRequires:  gcc-c++ pcre-devel docbook-style-xsl libxslt cmake desktop-file-utils tinyxml2-devel >= 2.1.0

Requires:       python3-pygments python3-unversioned-command
Provides:       %{name}-htmlreport = %{version}-%{release}
Obsoletes:      %{name}-htmlreport <  %{version}-%{release}

%description
Cppcheck is a static analysis tool for C/C++ code.
Cppcheck primarily detects only real errors in the code (i.e. have zero false positives)
instead of syntax errors which C/C++ compilers and many other analysis tools detect commonly.

%package        help
Summary:        Documentation for cppcheck
%description    help
Documentation for cppcheck

%prep
%autosetup -p1
rm -r externals/tinyxml

%build
%make_build DB2MAN=%{_datadir}/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl man
xsltproc --nonet -o man/manual.html \
    %{_datadir}/sgml/docbook/xsl-stylesheets/xhtml/docbook.xsl \
    man/manual.docbook

mkdir objdir-%{_target_platform}
cd objdir-%{_target_platform}
%cmake .. -DCMAKE_BUILD_TYPE=Release -DHAVE_RULES=1 -DBUILD_GUI=0 -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_TESTS=1 -DCFGDIR=%{_datadir}/CppCheck
%make_build cppcheck

%install
%make_install -C objdir-%{_target_platform}
install -D -p -m 644 cppcheck.1 %{buildroot}%{_mandir}/man1/cppcheck.1
install -D -p -m 755 htmlreport/cppcheck-htmlreport %{buildroot}%{_bindir}/cppcheck-htmlreport

%check
cd objdir-%{_target_platform}/bin
./testrunner -g -q

%files
%doc AUTHORS COPYING
%{_datadir}/CppCheck/
%{_bindir}/cppcheck
%{_bindir}/cppcheck-htmlreport

%files help
%doc man/manual.html
%{_mandir}/man1/cppcheck.1*

%changelog
* Thu Mar 04 2021 maminjie <maminjie1@huawei.com> - 1.83-7
- Add requires python3-unversioned-command to resolve compatibility

* Fri Sep 11 2020 wutao <wutao61@huawei.com> - 1.83-6
- change requires to python3

* Mon Nov 18 2019 lihao <lihao129@huawei.com> - 1.83-5
- Package Init
