%define with_python	0

# build ruby extension
%define with_ruby	%{?_with_ruby:1}%{!?_with_ruby:0}

%define	__libtoolize	/bin/true

Summary:	Japanese handwritten input system
Summary(ja):	日本語手書き文字認識エンジン
Name:		tomoe
Version:	0.6.0
Release:	2%{?_dist_release}
Group:		System Environment/Libraries
License:	LGPL
URL:		http://tomoe.sourceforge.jp/
Source0:	tomoe-%{version}.tar.gz
Patch0:         tomoe-0.6.0-multiarch-conflict.patch
BuildRoot:	%{_tmppath}/%{name}-%{version}-root
BuildRequires:	gtk-doc >= 1.4, libxslt
BuildRequires:	glib2-devel >= 2.4.0
#BuildRequires:	neon-devel
#BuildRequires:	apr-devel, subversion-devel
#BUildRequires:	MySQL-devel
BuildRequires:	unzip
Requires:	glib2 >= 2.4.0
Requires:		ldconfig

%description
A program which does Japanese handwriting recognition.

%description -l ja
日本語の手書き文字を認識するエンジンです。

%package devel
Summary:	Header files for developing tomoe applications
Summary(ja):	tomoe アプリケーション開発用ヘッダファイル
Group:		Development/Libraries
Requires:	%{name} = %{version}-%{release}
Requires:	pkgconfig

%description devel
The tomoe-devel package includes the header files for the tomoe package.
Install this package if you want to develop programs which use tomoe.

%description -l ja devel
tomoe-devel パッケージには、tomoe を使うアプリケーションを開発するための
ヘッダファイルが含まれています。

%if %{with_python}
%package -n python-tomoe
Summary:	Tomoe library for Python
Summary(ja):	Python から巴を使うためのライブラリ
Group:		System Environment/Libraries
Requires:	%{name} = %{version}-%{release}
Requires:	python
BuildRequires:  python-devel

%description -n python-tomoe
Python extension library to use Tomoe

%description -l ja -n python-tomoe
Python から巴を使うための拡張ライブラリです。
%endif


%if %{with_ruby}
%package -n ruby-tomoe
Summary:	Tomoe library for Ruby
Summary(ja):	Ruby から巴を使うためのライブラリ
Group:		System Environment/Libraries
Requires:	%{name} = %{version}-%{release}
Requires:	ruby
BuildRequires:	ruby-devel, ruby-gnome2-devel

%description -n ruby-tomoe
Ruby extension library to use Tomoe

%description -l ja -n ruby-tomoe
Ruby から巴を使うための拡張ライブラリです。

%package -n ruby-tomoe-devel
Summary:	Header files for developing ruby-tomoe applications
Summary(ja):	ruby-tomoe アプリケーション開発用ヘッダファイル
Group:		Development/Libraries
Requires:	ruby-tomoe = %{version}-%{release}
Requires:	%{name}-devel = %{version}-%{release}

%description -n ruby-tomoe-devel
The ruby-tomoe-devel package includes the header files for the ruby-tomoe
package.
Install this package if you want to develop programs which use ruby-tomoe.

%description -l ja -n ruby-tomoe-devel
ruby-tomoe-devel パッケージには、ruby-tomoe を使うアプリケーションを開発
するためのヘッダファイルが含まれています。
%endif

%prep
%setup -q
%patch0 -p0 -b .multiarch-conflict

%build
autoreconf -vif
%configure \
	--disable-static \
	--with-ruby-extdir=%{rarchdir} \
	--with-ruby-libdir=%{rlibdir}
%__make %{?_smp_mflags}

%install
%__rm -rf $RPM_BUILD_ROOT
%__make DESTDIR=%{buildroot} install

%if !%{with_ruby}
rm -f $RPM_BUILD_ROOT%{_libdir}/ruby/site_ruby/*/tomoe.rb $RPM_BUILD_ROOT%{_libdir}/ruby/site_ruby/*/*-linux/*
%endif
chmod 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/xml2est.rb

# remove unneeded files
%__rm -f %{buildroot}%{_libdir}/tomoe/module/dict/libmysql.*
%__rm -f %{buildroot}%{_libdir}/tomoe/module/dict/libsvn.*
find ${RPM_BUILD_ROOT} -name '*.la' | xargs rm

%if !%{with_python}
%__rm -f %{buildroot}%{_libdir}/python?.?/site-packages/tomoe.so
%endif

%if !%{with_ruby}
%__rm -rf %{buildroot}%{rarchdir}
%__rm -rf %{buildroot}%{rlibdir}
%endif

%find_lang %{name}

%clean
%__rm -rf %{buildroot}

%post
%{_syssbindir}/ldconfig

%postun
%{_syssbindir}/ldconfig

%files -f %{name}.lang
%defattr(-,root,root,-)
%doc AUTHORS COPYING ChangeLog NEWS README TODO
%dir %{_sysconfdir}/tomoe
%config(noreplace) %{_sysconfdir}/tomoe/config
%{_libdir}/*.so.*
%dir %{_libdir}/tomoe
%dir %{_libdir}/tomoe/module
%dir %{_libdir}/tomoe/module/dict
%{_libdir}/tomoe/module/dict/*.so
%dir %{_libdir}/tomoe/module/recognizer
%{_libdir}/tomoe/module/recognizer/*.so
%{_datadir}/tomoe


%files devel
%defattr(-,root,root,-)
%{_includedir}/tomoe
%{_libdir}/pkgconfig/*.pc
%{_libdir}/*.so
%{_datadir}/gtk-doc/html/tomoe


%if %{with_python}
%files -n python-tomoe
%defattr(-,root,root,-)
%{_libdir}/python?.?/site-packages/tomoe.so
%endif


%if %{with_ruby}
%files -n ruby-tomoe
%defattr(-,root,root,-)
%{rarchdir}/*.so.*
%{rlibdir}/tomoe.rb

%files -n ruby-tomoe-devel
%defattr(-,root,root,-)
%{rarchdir}/*.h
%{rarchdir}/*.so
%endif

%changelog
* Sun Oct 03 2010 Shu KONNO <owa@bg.wakwak.com> 0.6.0-2
- rebuilt with rpm-4.8.1 for pkg-config

* Sun May 31 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 0.6.0-1
- new upstream release
- added --disable-static in %%configure
- applied tomoe-0.6.0-multiarch-conflict.patch

* Sun Oct 12 2008 Shu KONNO <owa@bg.wakwak.com> 0.5.1-1vl5
- applied new versioning policy, spec in utf-8
- remove *.la

* Sun Mar 11 2007 KAZUKI SHIMURA <kazuki@ma.ccna.ne.jp> 0.5.1-0vl1
- new upstream release

* Sun Jan 07 2007 KAZUKI SHIMURA <kazuki@ma.ccna.ne.jp> 0.5.0-0vl3
- disable ruby extension by default

* Fri Jan 05 2007 KAZUKI SHIMURA <kazuki@ma.ccna.ne.jp> 0.5.0-0vl2
- move from tomoe-devel to tomoe
  - %%{_libdir}/tomoe/module/dict/*.so
  - %%{_libdir}/tomoe/module/recognizer/*.so

* Sat Dec 31 2006 KAZUKI SHIMURA <kazuki@ma.ccna.ne.jp> 0.5.0-0vl1
- new upstream release
- add BuildRequires: unzip
- update %%files section

* Mon Dec 18 2006 KAZUKI SHIMURA <kazuki@ma.ccna.ne.jp> 0.4.0-0vl1
- new upstream release
- update dependencies
  - drop BuildRequires: libxml2-devel, libxslt-devel, doxygen
  - add BuildRequires:
    - gtk-doc, libxslt, glib2-devel
    - ruby-devel, ruby-gnome2-devel
  - drop Requires: libxml2, libxslt
  - add Requires: glib2
- add new sub-package: ruby-tomoe

* Sat Nov 25 2006 KAZUKI SHIMURA <kazuki@ma.ccna.ne.jp> 0.3.0-0vl2
- oops, add Requires: libxml2, libxslt instead of *-devel

* Fri Nov 24 2006 KAZUKI SHIMURA <kazuki@ma.ccna.ne.jp> 0.3.0-0vl1
- new upstream release
- add BuildRequires: libxml2-devel, libxslt-devel, doxygen
- add Requires: pkgconfig to -devel package
- update %%files

* Mon Nov 07 2005 KAZUKI SHIMURA <kazuki@ma.ccna.ne.jp> 0.2.1-3vl1
- initial release for Vine Linux
- disable %%__libtoolize
- add Japanase summary and description

* Sat Sep 3 2005 Warren Togami <wtogami@redhat.com> - 0.2.1-3
- some spec cleanup

* Sat Sep 2 2005 Ryo Dairiki <ryo-dairiki@mbm.nifty.com> - 0.2.1-2
- Sync with Jens's spec file

* Wed Aug 31 2005 Ryo Dairiki <ryo-dairiki@mbm.nifty.com> - 0.2.1-1
- Initial packaging for Extras

* Fri Jul  1 2005 Ichiro Nakai <ichiro@n.email.ne.jp>
- (0.2.0-1m)
- version 0.2.0
- add a package tomoe-devel
- add %%post and %%postun sections

* Wed Mar  2 2005 Ichiro Nakai <ichiro@n.email.ne.jp>
- (0.1.1-1m)
- initial package for Momonga Linux
- import %%description from cooker
