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

Summary:      Liece is emacs based irc client
Summary(ja):  Liece は Emacsen 上で動作する IRC のクライアント
Name:         %{origname}
Version:      %{origver}
Release:      1%{?_dist_release}

Source0:      http://www.unixuser.org/~ueno/liece/dist/%{origname}-%{origver}.tar.gz
Source1:      %{origname}-install.sh
Source2:      %{origname}-remove.sh
Source3:      plum-support.el
Patch1:       liece-dsa341.patch
Patch10:      liece-1.4.10-emacs22.patch

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

PreReq: emacsen
%prereq_ge emacsen-common
%prereq_ge flim

Provides:     %{origname} = %{origver}
Conflicts:    liece-el


%description
 Liece is based on Irchat, simple IRC client running under Emacsen,
 nevertheless nothing to do with irchat-2.4jp which has various features added
 by Japanese contributers (e.g. Mule support, channel buffers).  We are going
 to full-replace to redesign thoroughly, and to stand up to extension against
 arbitrary protocol backend. The most recent version of this program has been
 almost completely rewritten from Irchat.


%description -l ja
Liece はEmacsen 上で動作するシンプルなIRC クライアントであるIrchat をベースに
しています。にもかかわらず 日本人コントリビュータがたくさん機能を追加した
irchat-2.4jp はまったくとりこまれていません。liece では全体的に再デザインし、
完全におきかえをしてます。


%prep
%setup  -n %{origname}-%{origver}
%patch1 -p1
%patch10 -p1


%build

./configure --prefix=$RPM_BUILD_ROOT%{_prefix} \
            --with-lispdir=$RPM_BUILD_ROOT%{_datadir}/emacs/site-lisp \
            --with-emacs=emacs

make -C dcc
make -C doc
make -C etc
(cd etc/po && msgfmt -o ja.mo ja.po)

%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
mkdir -p ${RPM_BUILD_ROOT}%{_infodir}
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{origname}/icons
mkdir -p ${RPM_BUILD_ROOT}/%{_bindir}
mkdir -p ${RPM_BUILD_ROOT}/%{_datadir}/%{origname}/po/ja/LC_MESSAGES/


#
# install el files
# 

cp dcc/{ldcc,ltcp} ${RPM_BUILD_ROOT}/%{_bindir}

cp -r lisp/* ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}

cp  %{SOURCE3}  ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}

mv  -f ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}/ChangeLog \
	 ChangeLog.lisp

(cd etc && make  install prefix=${RPM_BUILD_ROOT}/usr )
(cp etc/po/ja.mo ${RPM_BUILD_ROOT}%{_datadir}/%{origname}/po/ja/LC_MESSAGES/%{origname}.mo )


#
#  build & install info
#

install -m 644 doc/*.info  ${RPM_BUILD_ROOT}%{_infodir}


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

%_installemacsenscript %{origname} %{SOURCE1} 

%_removeemacsenscript  %{origname} %{SOURCE2}


#
# install info file
# 

mkdir -p ${RPM_BUILD_ROOT}%{_infodir}


%post 
#
# bytecompile and install 
#

if [ "$1" = 2 ]; then

%_emacsenPackageRemove %{origname}

fi


%_addemacsenlist %{origname}

%_emacsenPackageInstall %{origname}


/sbin/install-info %{_infodir}/liece.info.gz %{_infodir}/dir \
    --entry="* Liece: (liece).  IRC Client On Emacsen" --section="Emacs"


%preun

if [ "$1" = 0 ]; then

echo "preun$1"

%_emacsenPackageRemove %{origname}

%_removeemacsenlist %{origname}

/sbin/install-info --delete %{_infodir}/liece.info.gz %{_infodir}/dir \
    --entry="* Liece: (liece).  IRC Client On Emacsen" --section="Emacs"

fi


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


%files
%defattr(-,root,root)
%doc AUTHORS COPYING ChangeLog* INSTALL NEWS README doc
#%doc etc/sample.dot.emacs   where is it?

%{_bindir}/*
%{_datadir}/emacs/site-lisp/%{origname}/
%{_libdir}/emacsen-common/packages/install/%{origname}
%{_libdir}/emacsen-common/packages/remove/%{origname}

%{_infodir}/%{origname}.info*
%{_datadir}/%{origname}/po/ja/LC_MESSAGES/%{origname}.mo
%{_datadir}/%{origname}/icons
%{_datadir}/%{origname}/styles


%changelog
* Fri Aug 15 2008 Shu KONNO <owa@bg.wakwak.com> 1.4.10-1vl5
- applied new versioning policy, spec in utf-8

* Thu Aug 30 2007 Shu KONNO <owa@bg.wakwak.com> 1.4.10-0vl6
- added %%define _libdir %%{_prefix}/lib for x86_64

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

* Tue Sep 20 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.4.10-0vl4
- add Patch10 to support emacs22 (use assoc-string instead of assoc-ignore-case)

* Sun Jun 20 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 1.4.10-0vl3
- rebuild for VineSeed

* Wed May 19 2004 IKEDA Katsumi <ikeda@webmasters.gr.jp>
- 1.4.10-0vl2
- Added a patch "liece-dsa341.patch" for fixing security
- DSA-341-1 liece -- insecure temporary file

* Fri Nov  1 2002 Daisuke SUZUKI <daisuke@linux.or.jp> 1.4.10-0vl1
- new upstream version.

* Wed Feb 13 2002 akira yamada <akira@vinelinux.org> 1.4.6-0vl1
- new upstream version.
- added BuildRequires: gettext
- removed patch10.

* Sun Dec 30 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.4.4-0vl4
- liece-el -> liece
- spec file cleaned up too much
- added patch (Patch10) to set default {icon,style} directory for Vine
- patch0 removed

* Thu Nov  8 2001 Kazuhisa TAKEI <takei@vinelinux.org>
- patchZZ

* Wed Jul 18 2001 Kazuhisa TAKEI <takei@vinelinux.org>
- emacsenize 

* Wed Jul 11 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>
- 1.14.3-0vl2
- back to Requires: emacs = 20.7 -> emacs >= 20.7 (for emacs-beta)

* Wed Jul 11 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>
- 1.14.3-0vl1
- updated to apel-10.3, flim-1.14.3, semi-1.14.3, emh-1.14.1

* Fri Aug 25 2000 MATSUBAYASHI 'Shaolin' Kohji
- 1.13.7-8
- added %define _noVersionedDependencies 1

* Fri Aug 25 2000 MATSUBAYASHI 'Shaolin' Kohji
- 1.13.7-7
- modified %files section to handle compressed man page(s)

* Wed May 10 2000 MATSUBAYASHI 'Shaolin' Kohji
- 1.13.7-6
- apel updated to 10.2

* Mon Jan 24 2000 MATSUBAYASHI 'Shaolin' Kohji
- 1.13.7-5
- added patch (see emacs-mime-ja: 00303) to format texinfo correctly

* Thu Dec 24 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.13.7-4
- updated in sync with apel-10.0 / clime-1.13.6 release

* Wed Dec  1 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.13.7-3
- change Group to Applications/Editors/EmacsLisp

* Mon Nov 29 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.13.7-2
- added patches (see emacs-mime-ja:00183, emacs-mime-ja:00184)
- now emh-1.10.1 and rmail-mime-1.13.0 are also included
- documentation files are properly stored under /usr/doc directory

* Wed Nov  3 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.13.7-1
- updated to apel-9.23 / clime-1.13.5 / semi-1.13.7 release
- added Japanese / English info files to be installed
