## -*- coding: utf-8-unix -*-
%define   _noVersionedDependencies        1
%define   prereq_ge()   %(LC_ALL="C" rpm -q --queryformat 'PreReq:%%{NAME} >= %%{VERSION}' %1| grep -v "is not")
%define   origname      migemo
%define   origver       0.40
%define   release       3%{?_dist_release}
#%%define rlibdir ruby -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'
%define   rubyver	%(%{ruby} -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'|%{__sed} -e 's/^.*\\/\\([0-9.]*\\)$/\\1/')

Name:     %{origname}
Version:  %{origver}
Release:  %{release}

Summary: Japanese incremental search with Romaji on Emacsen
Summary(ja): Emacsen 上でローマ字を使って日本語インクリメントサーチを行うツール
License: GPL2
Group: Applications/Editors/Emacs
Source0: http://0xcc.net/migemo/migemo-%{origver}.tar.gz
Source1: migemo-install.sh
Source2: migemo-remove.sh
Source3: vine-default-migemo.el
Source4: migemo-init.el
URL: http://0xcc.net/migemo/
BuildArch: noarch
Buildroot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: ruby
BuildRequires: ruby-bsearch
BuildRequires: ruby-romkan
BuildRequires: emacsen
Requires: emacsen
Requires: apel
Requires: ruby >= %{rubyver}
Requires: ruby-bsearch >= 1.5-0vl4
Requires: ruby-romkan >= 0.4-0vl3
Requires(post): emacsen
Requires(preun): emacsen
%prereq_ge emacsen-common

%description
Japanese incremental search with Romaji on Emacsen

%description -l ja
Emacsen 上でローマ字を使って日本語インクリメントサーチを行うツール

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

%build
%configure
make emacsdir=${RPM_BUILD_ROOT}-%{emacsdir} \
     lispdir=%{_datadir}/emacs/site-lisp/%{origname} \
     rubydir=%{rlibdir}

%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}%{emacsen_pkgdir}/install
mkdir -p ${RPM_BUILD_ROOT}%{emacsen_pkgdir}/remove

%makeinstall emacsdir=${RPM_BUILD_ROOT}-%{emacsdir} \
             lispdir=${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname} \
             rubydir=${RPM_BUILD_ROOT}%{rlibdir}
rm -f ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}/*.elc
make clean
cp -ar Makefile* configure* *.el *.el.in elisp-comp acinclude.m4 \
      install-sh  mkinstalldirs missing INSTALL NEWS migemo.rb.in \
      README COPYING AUTHORS ChangeLog tests config.status migemo \
      %{SOURCE3} %{SOURCE4} \
      ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}

#
# install  script( bytecompile el and install elc , remove )   
#
%_installemacsenscript %{origname} %{SOURCE1}

%_removeemacsenscript  %{origname} %{SOURCE2}

%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}

rm -rf ${RPM_BUILD_DIR}/%{origname}-%{origver}

%files
%defattr(-,root,root)
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README tests
%{_bindir}/migemo*
%{rlibdir}/migemo*
%{_datadir}/migemo
%{_datadir}/emacs/site-lisp/%{origname}
%{emacsen_pkgdir}/install/%{origname}
%{emacsen_pkgdir}/remove/%{origname}

%changelog
* Wed Jan 06 2010 Munehiro Yamamoto <munepi@vinelinux.org> 0.40-3
- use %%{emacsen_pkgdir}

* Tue May  5 2009 IWAI, Masaharu <iwai@alib.jp> 0.40-2
- spec in UTF-8
- drop Prefix tag
- fix BuildRequires: emacs to emacsen
- apply vine-default
  - update migemo-install.sh (Source1)
  - update migemo-remove.sh (Source2)
  - add vine-default-migemo.el (Source3)
  - add migemo-init.el (Source4)
- update %%flies section
  - add %%{_datadir}/emacs/site-lisp/%%{origname} directory

* Tue Sep 16 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.40-1
- applied new versioning policy
- updated Source0 URL, URL:
- updated BuildRequires:

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

* Fri Oct 22 2004 IWAI, Masaharu <iwai@alib.jp> 0.40-0vl7
- add Japanese summary and description

* Tue Jun 15 2004 IWAI, Masaharu <iwai@alib.jp> 0.40-0vl6
- update migemo-install.sh (Source1):
    touch a few files: aclocal.m4 Makefile.in configure

* Sun Dec 28 2003 IWAI, Masaharu <iwai@alib.jp> 0.40-0vl5
- fix Requires

* Fri Oct 10 2003 IWAI, Masaharu <iwai@alib.jp> 0.40-0vl4
- update {Build,}Requires: more exact

* Tue Oct  7 2003 IWAI, Masaharu <iwai@alib.jp> 0.40-0vl3
- build with ruby-1.8.0

* Sun Jun  1 2003 IWAI Masaharu <iwai@alib.jp> 0.40-0vl2
- fix byte compile routine ([VineSeed-Plus:01695])
   - cp -ar migemo.rb.in migemo %%{_datadir}/emacs/site-lisp/%%{origname}
   - update migemo-install.sh (Source1)

* Fri May 30 2003 IWAI Masaharu <iwai@alib.jp> 0.40-0vl1
- upstream release

* Fri Mar 21 2003 IWAI Masaharu <iwai@alib.jp> 0.32-0vl4
- rebuild

* Sat Feb 16 2002 IWAI Masaharu <iwaim@cc.mbn.or.jp> 0.32-0vl3
- rebuild with ruby-romkan-0.4-0vl1

* Wed Feb  6 2002 IWAI Masaharu <iwaim@cc.mbn.or.jp> 0.32-0vl2
- moved the directory installed the ruby library
    - sitelibdir -> rubylibdir
- added BuildRequires: ruby, rpm >= 3.0.6-0vl16

* Wed Jan  2 2002 IWAI Masaharu <iwaim@cc.mbn.or.jp> 0.32-0vl1
- first release for VIne Linux

* Fri Sep  7 2001 IWAI Masaharu <iwaim@cc.mbn.or.jp>
- 0.32-1
- first release.
