Name:                tesseract
Version:             4.0.0
Release:             1
Summary:             Raw OCR Engine
License:             Apache 2.0 and BSD-2-Clause
URL:                 https://github.com/tesseract-ocr/%{name}
Source0:             https://github.com/tesseract-ocr/tesseract/archive/%{version}.tar.gz
Patch0:              tesseract_datadir.patch
BuildRequires:       automake autoconf-archive gcc-c++ libtool libtiff-devel leptonica-devel
BuildRequires:       cairo-devel libicu-devel pango-devel
BuildRequires:       tesseract-langpack-eng
Requires:            tesseract-langpack-eng

%description
A commercial quality OCR engine originally developed at HP between 1985 and
1995. In 1995, this engine was among the top 3 evaluated by UNLV. It was
open-sourced by HP and UNLV in 2005.

%package devel
Summary:             Development files for %{name}
Requires:            %{name}%{?_isa} = %{version}-%{release}
%description devel
The %{name}-devel package contains header file for
developing applications that use %{name}.

%package tools
Summary:             Training tools for %{name}
Requires:            %{name}%{?_isa} = %{version}-%{release}
%description tools
The %{name}-tools package contains tools for training %{name}.

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

%build
autoreconf -ifv
%configure --disable-static
%make_build
%make_build training

%install
%make_install
%make_install training-install
find %{buildroot}%{_libdir} -type f -name '*.la' -delete
mkdir -p %{buildroot}/%{_datadir}/%{name}/tessdata/
%ldconfig_scriptlets

%files
%license LICENSE
%doc AUTHORS ChangeLog README.md
%{_bindir}/%{name}
%dir %{_datadir}/%{name}
%dir %{_datadir}/%{name}/tessdata
%{_datadir}/%{name}/tessdata/configs/
%{_datadir}/%{name}/tessdata/tessconfigs/
%{_datadir}/%{name}/tessdata/pdf.ttf
%{_libdir}/lib%{name}*.so.4*

%files devel
%{_includedir}/%{name}
%{_libdir}/lib%{name}*.so
%{_libdir}/pkgconfig/%{name}.pc

%files tools
%{_bindir}/ambiguous_words
%{_bindir}/classifier_tester
%{_bindir}/cntraining
%{_bindir}/combine_lang_model
%{_bindir}/combine_tessdata
%{_bindir}/dawg2wordlist
%{_bindir}/language-specific.sh
%{_bindir}/lstmeval
%{_bindir}/lstmtraining
%{_bindir}/merge_unicharsets
%{_bindir}/mftraining
%{_bindir}/set_unicharset_properties
%{_bindir}/shapeclustering
%{_bindir}/tesstrain.sh
%{_bindir}/tesstrain_utils.sh
%{_bindir}/text2image
%{_bindir}/unicharset_extractor
%{_bindir}/wordlist2dawg

%changelog
* Fri Jan 8 2021 chengzihan <chengzihan2@huawei.com> - 4.0.0-1
- Package init
