%define _noVersionedDependencies	1
%define prereq_ge()  %(LC_ALL="C" rpm -q --queryformat 'PreReq:%%{NAME} >= %%{VERSION}' %1| grep -v "is not")
%define emacsen_pkgdir /usr/lib/emacsen-common/packages
%define	origname lookup
%define origver  1.4.1

Summary:      a Search Interface for Emacsen
Summary(ja):  Emacs 系のエディタで利用できる辞書検索インターフェース
Name:         %{origname}
Version:      %{origver}
Release:      1%{?_dist_release}

Source0:      http://openlab.jp/edict/lookup/dist/lookup-%{version}.tar.gz
Source1:      %{origname}-install.sh
Source2:      %{origname}-remove.sh
Source10:     lookup-sample.dotemacs
Source11:     lookup-init.el
Source12:     vine-default-lookup.el

License:      GPL
Group:        Applications/Editors/Emacs
URL:          http://openlab.jp/edict/lookup/
BuildRoot:    %{_tmppath}/%{name}-%{version}
BuildArch:    noarch

Requires:     emacsen
PreReq:       emacsen flim apel
BuildRequires: flim apel
%prereq_ge    emacsen-common
PreReq:       /sbin/install-info
Obsoletes:    lookup-emacs, lookup-xemacs
Conflicts:    %{origname}-el

Distribution: Vine Linux
Vendor:       Project Vine
Packager:     Tomoya TAKA <taka@vinelinux.org>


%description
Lookup is interface on Emacs to use some dictionaries.
Lookup is developed by OpenLab, Ring Server Project.

%description -l ja
Lookup は Emacs 系のエディタで利用できる辞書検索インターフェースです。
市販のCD-ROM 辞書やネットワークの辞書サーバを始め、様々な情報源から簡単な操作
と設定で辞書検索が行なえます。


%prep

%setup -q -n %{origname}-%{origver}


%build

%configure --prefix=%{_prefix} --infodir=%{_infodir}


%install
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
[ "%{buildroot}" != "/" ] && mkdir -p %{buildroot}

mkdir -p %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}/packages
mkdir -p %{buildroot}%{emacsen_pkgdir}/install
mkdir -p %{buildroot}%{emacsen_pkgdir}/remove

#
# install el files
#

cp -p lisp/*.el %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}
cp -p lisp/*.el.in %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}
cp -p lisp/lookup-logo.* %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}
cp -p packages/*.el %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}/packages
cp -p packages/dict-misc/*.el %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}/packages
cp -p packages/jitenban97/*.el %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}/packages
cp %{SOURCE11} %{SOURCE12} %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}/

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

%_installemacsenscript %{origname} %{SOURCE1}

%_removeemacsenscript  %{origname} %{SOURCE2}

#
# install info file
#

mkdir -p %{buildroot}%{_infodir}
cp -p texi/lookup-guide.info %{buildroot}%{_infodir}
cp -p texi/lookup.info* %{buildroot}%{_infodir}

#
# copy sample of ~/{.emacs.el,.xemacs.el}
#

cp %{SOURCE10} ./sample.dotemacs

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

%post
#
# bytecompile and install
#

if [ "$1" = 2 ]; then

%_emacsenPackageRemove %{origname}

fi

%_addemacsenlist %{origname}

%_emacsenPackageInstall %{origname}

/sbin/install-info --info-dir=%{_infodir} %{_infodir}/lookup-guide.info.gz
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/lookup.info.gz

%preun
if [ "$1" = 0 ]; then

%_emacsenPackageRemove %{origname}

%_removeemacsenlist %{origname}

/sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/lookup-guide.info.gz
/sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/lookup.info.gz

fi


%files
%defattr(-,root,root)
%doc AUTHORS COPYING ChangeLog NEWS README VERSION
%doc sample.dotemacs texi/*.texi
%{_datadir}/emacs/site-lisp/%{origname}
%{emacsen_pkgdir}/install/%{origname}
%{emacsen_pkgdir}/remove/%{origname}
%{_infodir}/*


%changelog
* Tue Mar 30 2010 IWAI, Masaharu <iwai@alib.jp> 1.4.1-1
- update to 1.4.1
- add PreReq: apel
- add BuildRequires: flim apel

* Mon Dec 14 2009 IWAI, Masaharu <iwai@alib.jp> 1.4-2
- apply vine-default
  - add lookup-init.el (Source11)
  - add vine-default-lookup.el (Source12)
  - update lookup-{install,remove}.sh
- update sammary and description in English
- rename Source10: sample.dotemacs to lookup-sample.dotemacs
- add PreReq: flim :fixed <BTS:VineLinux:857>

* Fri Oct 03 2008 Shu KONNO <owa@bg.wakwak.com> 1.4-1vl5
- applied new versioning policy, spec in utf-8
- added %%emacsen_pkgdir macro

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

* Fri Jul  2 2004 NISHIMURA Daisuke <nishi@graco.c.u-tokyo.ac.jp> 1.4-0vl2
- add missing SOURCES (ndeb-binary.el, ndnmz.el) in lookup-install.sh

* Tue May  4 2004 IWAI, Masaharu <iwai@alib.jp> 1.4-0vl1
- version up to 1.4 ( edict openlab version )
- update URL and Source0 tags
- update lookup-install.sh script: value of VERSION

* Mon Mar 17 2003 IWAI Masaharu <iwai@alib.jp> 1.3-0vl4
- rebuild

* Sun Dec 30 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.3-0vl3
- lookup-el -> lookup again

* Sat Dec  9 2001 Tomoya TAKA <taka@vinelinux.org> 1.3-0vl1
- emacsenize

* Sun Jun 24 2001 Tomoya TAKA <tomoya@olive.plala.or.jp>
- 1.3-0vl1
- add Prereq: /sbin/install-info, handle info pages in %%post and %%preun
- some fix on spec file, use rpm macros

* Mon Jun 26 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.2-0vl3
- BuildArch: noarch

* Wed Apr 26 2000 Masaki Kawamura <kawamura@ic.sci.yamaguchi-u.ac.jp>
- release for the Vine Linux 2.0
