%define __libtoolize :

%define emacsen_pkg     1
%{?without_emacsen: %define emacsen_pkg 0}

%if %{emacsen_pkg}
%undefine without_emacsen
%define anthy_el        anthy-el
%define anthy           anthy
%define emacsen_pkgdir /usr/lib/emacsen-common/packages
%else
%define without_emacsen 1
%endif

%define ut_patch_date	20100517

Summary: A Japanese character input system library (with dictionary).
Summary(ja): Anthy - 日本語入力システムおよび辞書
Name: anthy
Version: 9100h
Release: 11%{?_dist_release}
URL: http://www.sourceforge.jp/projects/anthy/
Source: %{name}-%{version}.tar.gz
Source1: anthy-el-install.sh
Source2: anthy-el-remove.sh
Source3: anthy-init.el
Source4: vine-default-anthy.el
# large dictionary and improvement patch made by UTSUMI at 
# http://www.geocities.jp/ep3797/anthy_dict_01.html
Source100: anthy-ut-patches-%{ut_patch_date}.tar.bz2
# anthy patches made by G-HAL
# http://www.fenix.ne.jp/~G-HAL/soft/nosettle/#anthy
Patch100: anthy-9100h.patch13B-23-iconv-ucdict.2010507.alt-depgraph-100120-patch100126.alt-cannadic-091230.patch
Patch110: anthy-9100h.patch13B-23-iconv-jisx0213.patch
Patch120: anthy-ut-patches-20100517-ANTHY_ENCODING_EUCJP.patch
License: GPL, LGPL, BSD
Group: Applications/System
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: automake, autoconf

Vendor: Project Vine
Distribution: Vine Linux
Packager: daisuke, kazutaka

%description
Anthy is free and secure Japanese input system.

%description -l ja
Anthy はフリーでセキュアな日本語入力システムです。

%if %{emacsen_pkg}
%package -n %{anthy_el}
Summary: Emacs-lisp frontend for Anthy
Summary(ja): Anthy 用 Emacs-lisp フロントエンド
Group: Applications/Editors/Emacs
BuildRequires: emacsen
Requires(post,preun): emacsen, emacsen-common >= 0.1
Requires: %{name} = %{version}-%{release}

%description -n %{anthy_el}
Emacs-lisp frontend for Anthy

%description -n %{anthy_el} -l ja
Anthy のための Emacs-lisp フロントエンド
%endif

%package devel
Summary: Development files for libanthy
Summary(ja): libanthy を使ったアプリケーションを開発するためのファイル
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig

%description devel
Devepment files for anthy libraries.

%description devel -l ja
libanthy を利用したアプリケーションを開発するために必要なヘッダやライブラリ
が含まれています。


%prep
%setup -q -a 100
%patch100 -p1
%patch110 -p1
%patch120 -p1

pushd anthy-ut-patches-%{ut_patch_date}
./apply-patches.sh
popd

# fix file permission...
chmod a+x ./depgraph/mkdepword \
          ./calctrans/divide.sh \
          ./mkworddic/mkucdic.pl

%build
#libtoolize --copy --force
autoreconf -f -i
%configure --localstatedir=%{_var}

#%__make %{?_smp_mflags}
# don't use smp option
%__make


%install
%__rm -rf ${RPM_BUILD_ROOT}
%makeinstall
%if %{emacsen_pkg}
%__mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{anthy}
#%__mkdir -p ${RPM_BUILD_ROOT}%{_prefix}/lib/emacsen-common/packages/install
#%__mkdir -p ${RPM_BUILD_ROOT}%{_prefix}/lib/emacsen-common/packages/remove
%__cp -af %{SOURCE3} %{SOURCE4} \
    ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{anthy}
%__mkdir -p ${RPM_BUILD_ROOT}%{emacsen_pkgdir}/install
%__mkdir -p ${RPM_BUILD_ROOT}%{emacsen_pkgdir}/remove
%endif

%if %{emacsen_pkg}
%{?emacsen_pkg: %_installemacsenscript %{anthy} %{SOURCE1}}
%{?emacsen_pkg: %_removeemacsenscript  %{anthy} %{SOURCE2}}
%else
%__rm -rf ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{anthy}
%endif

## remove unuse files
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la


%if %{emacsen_pkg}
%post -n %{anthy_el}
if [ "$1" = 2 ]; then
  %{?emacsen_pkg: %_emacsenPackageRemove %{anthy}}
fi
%{?emacsen_pkg: %_addemacsenlist %{anthy}}
%{?emacsen_pkg: %_emacsenPackageInstall %{anthy}}


%preun -n %{anthy_el}
if [ "$1" = 0 ]; then
  %{?emacsen_pkg: %_emacsenPackageRemove %{anthy}}

  %{?emacsen_pkg: %_removeemacsenlist %{anthy}}

fi
%endif


%clean
%__rm -rf ${RPM_BUILD_ROOT}


%post -p /sbin/ldconfig


%postun -p /sbin/ldconfig


%files
%defattr(-,root,root)
%{_bindir}/*
%{_sysconfdir}/*
%{_datadir}/anthy
%{_libdir}/libanthy*.so
%{_libdir}/libanthy*.so.*
%doc AUTHORS COPYING ChangeLog DIARY NEWS README doc Doxyfile README.en

%if %{emacsen_pkg}
%files -n %{anthy_el}
%defattr(-, root, root)
%{_datadir}/emacs/site-lisp/%{anthy}
#%{_prefix}/lib/emacsen-common/packages/install/%{anthy}
#%{_prefix}/lib/emacsen-common/packages/remove/%{anthy}
%{emacsen_pkgdir}/install/%{anthy}
%{emacsen_pkgdir}/remove/%{anthy}
%endif

%files devel
%defattr(-,root,root)
%{_includedir}/*
%{_libdir}/libanthy*.a
#%{_libdir}/libanthy*.la
%{_libdir}/pkgconfig/*.pc

%changelog
* Tue Sep 28 2010 Shu KONNO <owa@bg.wakwak.com> 9100h-11
- rebuilt with rpm-4.8.1 for pkg-config

* Sun Jun 06 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 9100h-10
- add patch110 to change EUCJP AS EUCJP/JISX0213
- add patch120 to change default encoding to EUCJP for compatibility

* Fri Jun 04 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 9100h-9
- move ut patch to Source100
- add Patch100 to add G-HAL's patches
  - diffed from G-HAL's modified anthy archive.
  - new ut patch does not include G-HAL's patches

* Wed May 19 2010 Kazutaka HARADA <kazutaka@vinelinux.org> 9100h-8
- update Patch100 (anthy-ut-patches-20100517.tar.bz2)
- run autoreconf at %%build section

* Tue Jul 07 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 9100h-7
- updated vine-default-anthy.el
  - set 1 for anthy-accept-timeout (because default timeout is too long)

* Sat Jun 27 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 9100h-6
- update Patch100 (anthy-ut-patches-20090604.tar.bz2)

* Mon May 11 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 9100h-5
- update Patch100 (anthy-ut-patches-20090507.tar.bz2)

* Wed May 06 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 9100h-4
- updated anthy-el-install.sh
  - *-init.el: changed from hard copy to symbolic link 
    on /etc/emacs-XX.YY/site-start.d
- corrected byte-compiling messages of emacs flaver

* Tue Apr 21 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 9100h-3
- added vine-default-anthy.el
- updated anthy-el-install.sh, anthy-el-remove.sh for vine-default-anthy.el

* Tue Apr 07 2009 Shu KONNO <owa@bg.wakwak.com> 9100h-2
- removed %%{?_smp_mflags} at make

* Sun Mar 15 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 9100h-1
- new upstream release
- update Patch100

* Wed Jan 21 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 9100e-3
- add patch100 to improve conversion logic and add large dirctionary
- add License LGPL and BSD for added patches
- 

* Fri Sep 26 2008 Shu KONNO <owa@bg.wakwak.com> 9100e-2vl5
- added %%emacsen_pkgdir
- removed *.la
- spec in utf-8

* Thu Mar 20 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 9100e-1vl5
- new upstream release

1* Fri Dec 28 2007 IWAI, Masaharu <iwai@alib.jp> 9100d-0vl1
- new upstream release

* Thu Aug 16 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 9100-0vl1
- new upstream release

* Fri Jun 15 2007 IWAI, Masaharu <iwai@alib.jp> 9011-0vl1
- new upstream release

* Tue Oct 17 2006 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 7900-0vl3
- use %%{_prefix}/lib instead of %%{_libdir} for elisp directory

* Mon Sep 11 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 7900-0vl2
- changed anthy-el Group to Appliations/Editors/Emacs <BTS:VineLinux:163>

* Fri Aug 11 2006 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 7900-0vl1
- new upstream release

* Fri Apr 28 2006 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 7500b-0vl1
- new upstream release

* Sat Mar 18 2006 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 7500-0vl1
- new upstream release

* Fri Dec 30 2005 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 7100b-0vl3
- add BuildRequires: emacsen instead of emacs
- add Requires: %%{name} to anthy-el package
- add libanthy*.la to devel package
- update anthy-el-install.sh
  - add anthy-azik.el, anthy-kyuri.el

* Sun Dec 18 2005 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 7100b-0vl2
- add BuildRequires: emacs

* Tue Dec 06 2005 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 7100b-0vl1
- new upstream release

* Mon Oct 17 2005 IWAI, Masaharu <iwai@alib.jp> 7015-0vl1
- new upstream release

* Mon Oct 10 2005 IWAI, Masaharu <iwai@alib.jp> 6829-0vl1
- new upstream release

* Sun Jul 31 2005 IWAI, Masaharu <iwai@alib.jp> 6724-0vl1
- new upstream release
- add documents: Doxyfile and README.en

* Sat Jul 30 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 6700b-0vl1
- new upstream release

* Tue May 10 2005 IWAI, Masaharu <iwai@alib.jp> 6508-0vl1
- new upstream release

* Sat Apr  9 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 6300d-0vl1
- new upstream release
- added %{_libdir}/pkgconfig/anthy.pc to devel package

* Fri Oct 15 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 5812-0vl1
- new upstream release

* Sat Oct 09 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 5714-0vl1
- new upstream release

* Sun Jul 04 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 5500-0vl1
- new upstream release

* Thu Jun  3 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 5323-0vl3
- move libanthy*.so to anthy main package. it is needed by some
  anthy application.

* Thu Jun  3 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 5323-0vl2
- split development files to anthy-devel

* Thu Jun  3 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 5323-0vl1
- new upstream release

* Wed Apr 21 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 5220-0vl1
- new upstream release

* Wed Mar 31 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 5122-0vl1
- new upstream release

* Sun Feb 29 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 5100-0vl1
- new upstream release

* Mon Feb 23 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 5021-0vl1
- new upstream release

* Wed Feb 11 2004 IWAI, Masaharu <iwai@alib.jp> 5008-0vl1
- new upstream release

* Tue Jan 27 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 4925-0vl1
- new upstream release

* Sun Jan 11 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 4901-0vl1
- new upstream release

* Thu Nov 27 2003 Daisuke SUZUKI <daisuke@linux.or.jp> 4723-0vl1
- new upstream release

* Mon Nov 10 2003 Daisuke SUZUKI <daisuke@linux.or.jp> 4708-0vl1
- new upstream release

* Fri Sep 26 2003 IWAI, Masaharu <iwai@alib.jp> 4524-0vl1
- new upstream release

* Mon Sep 22 2003 IWAI, Masaharu <iwai@alib.jp> 4520-0vl1
- new upstream release

* Tue Sep  9 2003 IWAI, Masaharu <iwai@alib.jp> 4507-0vl3
- update anthy-el-install.sh (Source1): [VineSeed-Plus:01834]
  - The files to byte-compile is made the same as the upstream.

* Tue Sep  9 2003 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 4507-0vl2
- not bytecompile leim-list.el for XEmacs

* Sun Sep 07 2003 Daisuke SUZUKI <daisuke@linux.or.jp> 4507-0vl1
- new upstream release

* Sun Aug 31 2003 IWAI, Masaharu <iwai@alib.jp> 4431-0vl1
- new upstream snapshot release
- create anthy-el package for emacsen

* Fri Aug 29 2003 Daisuke SUZUKI <daisuke@linux.or.jp> 4421-0vl1
- new upstream snapshot release

* Fri Jul 18 2003 Daisuke SUZUKI <daisuke@linux.or.jp> 4300-0vl1
- initial build for Vine Linux

* Thu Jul 10 2003 Yuhei Matsunaga <yuhei@users.sourceforge.jp>
- up to 4200.
- added description.

* Fri Nov 25 2002 OGUMA "dellin" Hironori <dellin@team-ct.org>
- 3500c-1
- up to 3500c.
- added some documents.

* Fri Nov 22 2002 OGUMA "dellin" Hironori <dellin@team-ct.org>
- up to 3500b.

* Thu Jan  3 2002 Yusuke Tabata <yusuke@kmc.gr.jp>
- changed my mail address and URL of web page

* Thu Nov 11 2001 Takayoshi Nobuoka <taka@trans-nt.com>
- add %{_sysconfdir}/* at %files

* Wed Sep  9 2001 Takayoshi Nobuoka <taka@trans-nt.com>
- use _bindir and so on.

* Sun Aug 19 2001 Tabatee <yusuke@kmc.kyoto-u.ac.jp>
- Initial build.

