%if ! (0%{?fedora} > 12 || 0%{?rhel} > 5)
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%endif
Name: zinnia
Version: 0.06
Release: 8%{?dist}
Summary: Online handwriting recognition system with machine learning
Group: System Environment/Libraries
License: BSD
URL: http://zinnia.sourceforge.net/
Source0: http://downloads.sourceforge.net/zinnia/%{name}-%{version}.tar.gz
Source1: http://zinnia.svn.sourceforge.net/viewvc/zinnia/zinnia/tomoe2s.pl
Source2: Makefile.tomoe
Patch0: zinnia-0.05-bindings.patch
Patch1: zinnia-0.06-fixes-ppc-float.patch
Patch2: always-store-data-in-little-endian-format.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: db4-devel, python2-devel
BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: tomoe
%description
Zinnia provides a simple, customizable, and portable dynamic OCR
system for hand-written input, based on Support Vector Machines.
Zinnia simply receives user pen strokes as coordinate data and outputs
the best matching characters sorted by SVM confidence. To maintain
portability, it has no rendering functionality. In addition to
recognition, Zinnia provides a training module capable of creating
highly efficient handwriting recognition models.
This package contains the shared libraries.
%package devel
Summary: Development files for %{name}
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
%package utils
Summary: Utils for the zinnia library
Group: Applications/System
Requires: %{name} = %{version}-%{release}
%description utils
The %{name}-utils package provides utilities for zinnia library that
use %{name}.
%package doc
Summary: Documents for the zinnia library
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
BuildArch: noarch
%description doc
The %{name}-doc package provide documents for zinnia library that
use %{name}.
%package perl
Summary: Perl bindings for %name
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
%description perl
This package contains perl bindings for %{name}.
%package python
Summary: Python bindings for %{name}
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%description python
This package contains python bindings for %{name}.
%package tomoe
Summary: Tomoe model file for %{name}
Group: System Environment/Libraries
Requires: %{name} = %{version}-%{release}
%description tomoe
This package contains tomoe model files for %{name}.
%prep
%setup -q -n %{name}-%{version}
%patch0 -p1 -b .bindings
%patch1 -p1 -b .ppc
%patch2 -p1 -R -b .little-endian
find . -type f -name ChangeLog -size 0c -exec rm -f {} ';'
find . -type f -name "*.pyc" -exec rm -f {} ';'
cp %{SOURCE1} .
cp %{SOURCE2} .
pushd doc
iconv -f latin1 -t utf8 zinnia.css > zinnia.css.bak
mv -f zinnia.css.bak zinnia.css
popd
%build
%configure --disable-static
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
make CFLAGS="%{optflags}" CXXFLAGS="%{optflags}" %{?_smp_mflags}
make -f Makefile.tomoe build
pushd perl
perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="$RPM_OPT_FLAGS"
make %{?_smp_mflags}
popd
pushd python
CFLAGS="$RPM_OPT_FLAGS -I../" LDFLAGS="-L../.libs" python setup.py build
popd
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
make -f Makefile.tomoe install DESTDIR=$RPM_BUILD_ROOT
#install -d -m 0755 -p $RPM_BUILD_ROOT%{_docdir}/%{name}
#cp -pfr doc $RPM_BUILD_ROOT%{_docdir}/%{name}
pushd perl
make pure_install PERL_INSTALL_ROOT=$RPM_BUILD_ROOT
popd
pushd python
python setup.py install --root $RPM_BUILD_ROOT
pushd
#remove something unnecessary
find $RPM_BUILD_ROOT -type f -name "*.la" -exec rm -f {} ';'
find $RPM_BUILD_ROOT -type f -name "*.bs" -size 0c -exec rm -f {} ';'
find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} ';'
#change the privilege of some files
chmod 0755 $RPM_BUILD_ROOT%{perl_vendorarch}/auto/%{name}/%{name}.so
%clean
rm -rf $RPM_BUILD_ROOT
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root,-)
%doc README COPYING
%{_libdir}/*.so.*
%files devel
%defattr(-,root,root,-)
%{_includedir}/*
%{_libdir}/lib%{name}.so
%{_libdir}/pkgconfig/%{name}.pc
%files utils
%defattr(-,root,root,-)
%{_bindir}/zinnia
%{_bindir}/zinnia_convert
%{_bindir}/zinnia_learn
%files doc
%defattr(-,root,root,-)
%doc doc/*
%files perl
%defattr(-,root,root,-)
%{perl_vendorarch}/auto/%{name}/
%{perl_vendorarch}/%{name}.pm
%files python
%defattr(-,root,root,-)
%{python_sitearch}/_%{name}.so
%{python_sitearch}/%{name}*
%files tomoe
%defattr(-,root,root,-)
%dir %{_datadir}/zinnia/model/tomoe/
%{_datadir}/zinnia/model/tomoe/handwriting-ja.model
%{_datadir}/zinnia/model/tomoe/handwriting-zh_CN.model
%changelog
* Mon Jul 26 2010 Peng Wu <pwu@redhat.com> - 0.06-8
- Remove noarch from zinnia-tomoe sub-package for Fedora 12 ppc build.
* Thu Jul 22 2010 David Malcolm <dmalcolm@redhat.com> - 0.06-7
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild
* Fri Jul 16 2010 Peng Wu <pwu@redhat.com> - 0.06-6
- revert patch always-store-data-in-little-endian-format.patch for ppc build.
* Tue Jun 08 2010 Liang Suilong <liangsuilong@gmail.com> - 0.06-5
- Force to use default compiling macro
* Fri Jun 04 2010 Peng Wu <pwu@redhat.com> - 0.06-4
- Add a patch(zinnia-0.06-fixes-ppc-float.patch),
to fixes ppc/ppc64 zinnia tomoe model generating error.
* Wed Jun 02 2010 Marcela Maslanova <mmaslano@redhat.com> - 0.06-3
- Mass rebuild with perl-5.12.0
* Thu May 20 2010 Peng Wu <pwu@redhat.com> - 0.06-2
- Auto generate zinnia tomoe model files,
and includes all model files in zinnia-tomoe noarch sub-package.
* Thu May 20 2010 Peng Wu <pwu@redhat.com> - 0.06-1
- Update to version 0.06.
* Wed Mar 10 2010 Liang Suilong <liangsuilong@gmail.com> - 0.05-4
- Fix the bugs of SPEC file
* Fri Mar 04 2010 Liang Suilong <liangsuilong@gmail.com> - 0.05-3
- Fix something wrong of spec file
* Wed Mar 02 2010 Liang Suilong <liangsuilong@gmail.com> - 0.05-2
- Rename Subpackage for perl and python
* Tue Feb 02 2010 Liang Suilong <liangsuilong@gmail.com> - 0.05-1
- Initial Package