Summary:	Online handwriting recognition system with machine learning
Summary:	機械学習ベースのポータブルなオンライン手書き文字認識エンジン
Name:		zinnia
Version:	0.06
Release:	3%{?_dist_release}
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
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires:	db4-devel, python-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.

%description -l ja
Zinniaは機械学習アルゴリズム SVM を用いたポータブルで汎用的なオンライン手書き文字認識
エンジンです。Zinniaは組み込みの容易さと汎用性を高めるために、文字のレンダリング機能は
持っていません。Zinniaは文字のストローク情報を座標の連続として受け取り、確からしい順に
スコア付きでN文字の認識結果を返すだけに機能を限定しています。また、認識エンジンは完全に
機械学習ベースであるために、文字のみならずユーザの任意のマウス・ペンストロークに対して
任意の文字列をマッピングするような認識エンジンを小コスト作成することができます。 

%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}
Provides:	tegaki-recognition-engine

%description 	python
This package contains python bindings for %{name}.

%package	tomoe
Summary:        Tomoe Ja model file for %{name}
Group:          System Environment/Libraries
Requires:       %{name} = %{version}-%{release}
Provides:	%{name}-model
Provides:	%{name}-tomoe-ja
#BuildArch:	noarch

%description	tomoe
This package contains tomoe Ja model files for %{name}.

%package	tomoe-zh_CN
Summary:        Tomoe model zh_CN file for %{name}
Group:          System Environment/Libraries
Requires:       %{name} = %{version}-%{release}
Provides:	%{name}-model
#BuildArch:	noarch

%description	tomoe-zh_CN
This package contains tomoe zh_CN model files for %{name}.

%prep
%setup -q -n %{name}-%{version}
%patch0 -p1 -b .bindings
%patch1 -p1 -b .ppc
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 %{?_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

%files tomoe-zh_CN
%defattr(-,root,root,-)
%dir %{_datadir}/zinnia/model/tomoe/
%{_datadir}/zinnia/model/tomoe/handwriting-zh_CN.model

%changelog
* Sun Apr  3 2011 IWAI, Masaharu <iwai@alib.jp> 0.06-3vl6
- build with perl 5.12.3

* Sun Sep 26 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.06-2
- rebuild with rpm-4.8.1 for pkg-config file

* Tue Jun  8 2010 IWAI, Masaharu <iwai@alib.jp> 0.06-1
- initial build for Vine Linux

* 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
