%define _noVersionedDependencies        1
%define prereq_ge()  %(LC_ALL="C" rpm -q --queryformat 'PreReq:%%{NAME} >= %%{VERSION}' %1| grep -v "is not")
%define _libdir %{_prefix}/lib
%define       origver       4.0.6
%define       origname      tamago


Summary:      Tamago Version 4 -- EGG Input Method Architecture for Emacsen
Summary(ja):  たまご第4版 
Name:         %{origname}
Version:      %{origver}
Release:      9%{?_dist_release}

Source0:      ftp://ftp.m17n.org/pub/%{origname}/%{origname}-%{origver}.tar.gz
Source1:      %{origname}-install.sh
Source2:      %{origname}-remove.sh
Source3:      http://cgi18.plala.or.jp/nyy/canna/egg-canna.el
Source4:      egg-anthy.tar.gz
%define egg_anthy_version 20070606

Source10:     vine-default-%{origname}.el
Source11:     %{origname}-init.el

Patch0:	      tamago-4.0.6-cvshead.patch
Patch3:       tamago-4.0.6-eggrc.patch
Patch4:       tamago-4.0.6-makefile.patch
Patch5:	      tamago-4.0.6-canna-unix-domain-socket.patch

Patch10:      tamago-emcws.patch
Patch20:      tamago-4.0.6-vine-romakana.patch
Patch30:      tamago-4.0.6-egg-helper-path.patch
Patch40:      tamago-4.0.6-wnn8_rev2.patch

### for emacs
### from  http://www.m17n.org/mlarchive/mule-ja/200703/msg00018.html
Patch50:      tamago-4.0.6-emacs23.patch

License:      GPL
Group:        Applications/Editors/Emacs
BuildRoot:    %{_tmppath}/%{name}-%{version}-root

Requires:     emacsen
Requires:     emacsen-common
BuildPreReq:  apel
%prereq_ge    apel
Obsoletes:    tamago-el

Vendor:       Project Vine
Distribution: Vine Linux

%description
EGG Emacs20(Emacs21) Input Method Architecture.
All is written only with Emacs Lisp.
Egg can use FreeWnn (jserver, cserver, tserver) and Wnn6 as server doing 
character string conversion with the back end.
And can convert mixed sentence of Japanese and Chinese into.
.
There is the part which is not implemented yet.


%description -l ja
すべてのソースが Emacs Lisp で実現されており、GNU Emacs 20.5 以降で
多言語入力環境を提供します。バックエンドサーバとしては、FreeWnn (jserver,
cserver, tserver), Wnn6, SJ3 Ver.2,canna に対応しています。



%prep
%setup -n %{origname}-%{origver} -a 4
%patch0 -p1
%patch3 -p1
#% patch4 -p1
%patch5 -p1
# cp %{SOURCE3} .
%__cp -a %{SOURCE10} %{SOURCE11} .

#% patch10 -p1
%patch20 -p1
%patch30 -p1
%patch40 -p1
%patch50 -p1

# rename canna stuff
#mv egg/canna.el egg/canna-tamago.el

# copy egg-anthy stuff
cp egg-anthy-%{egg_anthy_version}/*.el egg/

%build

%configure

gcc %{optflags} -o helper/egg-helper helper/egg-helper.c


%install

[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
[ "${RPM_BUILD_ROOT}" != "/" ] && mkdir -p ${RPM_BUILD_ROOT}

mkdir -p $RPM_BUILD_ROOT/%{_datadir}/emacs/site-lisp/%{origname}
mkdir -p $RPM_BUILD_ROOT/%{_libdir}/emacsen-common/packages/install
mkdir -p $RPM_BUILD_ROOT/%{_libdir}/emacsen-common/packages/remove


#
# install el files
# 

cp -r eggrc *.el egg its* Makefile \
	$RPM_BUILD_ROOT/usr/share/emacs/site-lisp/%{origname}/

#
# install egg-helper
#
install -d $RPM_BUILD_ROOT%{_libexecdir}
install -m 755 helper/egg-helper $RPM_BUILD_ROOT%{_libexecdir}


#
# install  script( bytecompile el and install elc , remove )   
#

%_installemacsenscript %{origname} %{SOURCE1} 

%_removeemacsenscript  %{origname} %{SOURCE2}


#
# install info file
# 

mkdir -p ${RPM_BUILD_ROOT}/usr/info


%post 
#
# bytecompile and install 
#

if [ "$1" = 2 ]; then

%_emacsenPackageRemove %{origname}

fi

%_addemacsenlist %{origname}

%_emacsenPackageInstall %{origname}


%preun

if [ "$1" = 0 ]; then

%_emacsenPackageRemove %{origname}

%_removeemacsenlist %{origname}

fi



%clean
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}


%files
%defattr(-,root,root)
%doc README.ja.txt COPYING AUTHORS ChangeLog* PROBLEMS TODO
%doc egg-anthy-%{egg_anthy_version}/egg-anthy.readme doc/
%{_datadir}/emacs/site-lisp/%{origname}/
%{_libdir}/emacsen-common/packages/install/%{origname}
%{_libdir}/emacsen-common/packages/remove/%{origname}
%{_libexecdir}/egg-helper
 

%changelog
* Sun Jun  6 2010 IWAI, Masaharu <iwai@alib.jp> 4.0.6-9
- update to egg-anthy 20070606
- update vine-default-tamago.el: connect to anthy with utf-8

* Sat May 08 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 4.0.6-8
- update vine-default-tamago.el to support emacs >= 23.1.96

* Mon Nov 02 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 4.0.6-7
- update patch40 (tamago-4.0.6--wnn8_rev2.patch)
  - fix bugs on 64bit architecture.

* Sat May 09 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 4.0.6-6
- applied tamago-4.0.6-emacs23.patch

* Wed May 06 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 4.0.6-5
- updated tamago-install.sh
  - *-init.el: changed from hard copy to symbolic link 
    on /etc/emacs-XX.YY/site-start.d

* Wed Apr 22 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 4.0.6-4
- no applied: 
  - egg-canna.el
  - tamago-4.0.6-makefile.patch
  - tamago-emcws.patch
- added vine-default-tamago.el and tamago-init.el
- updated tamago-install.sh for vine-default-tamago.el

* Sun Aug 17 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 4.0.6-3
- change from noarch to per-arch for egg-helper.

* Sat Aug 16 2008 Shu KONNO <owa@bg.wakwak.com> 4.0.6-2vl5
- applied new versioning policy
- added %%define _libdir %%{_prefix}/lib

* Sat Apr 14 2007 Daisuke SUZUKI <daisuke@linux.or.jp> 4.0.6-1vl26
- add Patch40 to support wnn7 and wnn8 (taken from debian package)

* Fri Dec 29 2006 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 4.0.6-1vl25
- restration(cp %{SOURCE3} .)for compilation complete(and use it for emacs-21.4)

* Sat Nov 04 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 4.0.6-1vl24
- add Patch5
  tamago-canna backend connect to cannaserver using UNIX domain
  socket by default. (taken from debian package)
- add Patch30 to change egg-helper path.

* Thu Sep 28 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 4.0.6-1vl23
- modified its/hira.el to add some roma-kana conversion map.

* Tue Sep 12 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.0.6-1vl22
- changed Group to Appliations/Editors/Emacs <BTS:VineLinux:163>

* Sat Jun 24 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 4.0.6-1vl21
- update to cvs head
- add egg-anthy
  http://anthy.sourceforge.jp/cgi-bin/hiki/hiki.cgi?Emacs%A4%AB%A4%E9
- add documents to %%files
- use License: instead of Copyright:

* Fri May 16 2003 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 4.0.6-1vl20
- update tamago-install.sh
-   rm -f ${ELDIR}/*.elc, egg/*.elc, its/*.elc
-   rm -f ${ELCDIR}/*.el, egg/*.el, its/*.el

* Fri May  9 2003 IWAI Masaharu <iwai@alib.jp> 4.0.6-1vl19
- update tamago-remove.sh: delete ${SITELISP}/egg

* Wed Apr 30 2003 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.0.6-1vl18
- rebuild

* Tue Dec 10 2002 Daisuke SUZUKI <daisuke@linux.or.jp> 4.0.6-1vl17
- add patch10 to use with emcws

* Tue Dec 10 2002 Daisuke SUZUKI <daisuke@linux.or.jp> 4.0.6-1vl16
- remove conflicts to emacs-dl-*
- rename canna.el to canna-tamago.el (we use emcws for canna)

* Wed Sep 11 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 4.0.6-1vl14
- modified patch3 for Canna-3.5b2-41

* Tue Jul 09 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 4.0.6-1vl13
- added patch4

* Tue Jul 09 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 4.0.6-1vl12
- update source3

* Mon Jul 08 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 4.0.6-1vl11
- added patch3

* Fri Jun 21 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 4.0.6-1vl10
- update patch2
- added source3

* Mon Dec 31 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 4.0.6-1vl9
- tamago-el -> tamago again
- spec file cleaned up

* Mon Jul 23 2001 Kazuhisa TAKEI <takei@vinelinux.org> 4.0.6-1vl8
- fixed install time no-compile bug( edit tamago-{install,remove}.sh )

* Wed Jul 18 2001 Kazuhisa TAKEI <takei@vinelinux.org> 4.0.6-1vl5
- support emacsen 

* Sun Dec 17 2000 Kazuhisa TAKEI<takei@vinelinux.org> 4.0.6-1vl3
- canna support patch upgrade.

* Sat Dec 16 2000 Kazuhisa TAKEI<takei@vinelinux.org> 4.0.6-1vl2
- version 4.0.6
- merge  canna support patch.

* Fri Jan 14 2000 Kazuhisa TAKEI<ktakei@jaist.ac.jp>
- version 4.0.5

