%define _noVersionedDependencies        1
%define prereq_ge()  %(LC_ALL="C" rpm -q --queryformat 'PreReq:%%{NAME} >= %%{VERSION}' %1| grep -v "is not")

%define name suikyo
%define version 2.1.0
%define release	1%{?_dist_release}

Summary:       A Romaji-Kana conversion Library
Summary(ja):   ローマ字・かな変換ライブラリ
Name:          %{name}
Version:       %{version}
Release:       %{release}
Group:         Development/Libraries
License:       GPL
URL:           http://taiyaki.org/suikyo/
Source0:       %{name}-%{version}.tar.bz2
BuildRoot:     %{_tmppath}/%{name}-%{version}-root
Requires:      ruby
BuildRequires: ruby-devel

### for GNU Emacs on Vine Linux
Source100:       %{name}-install.sh
Source101:       %{name}-remove.sh
##Source102:       %{name}-init.el

%description
Suikyo is Romaji-Kana conversion Library.

%description -l ja
水鏡はローマ字・かな変換ライブラリです．

%package el
Summary:       elisp binding of Suikyo
Summary(ja):   水鏡の elisp バイディング
Group:         Applications/Editors/Emacs
PreReq:        emacsen
Requires:      %{name} = %{version}-%{release}
%prereq_ge     emacsen-common
BuildRequires: emacsen-common
BuildArch:     noarch

%description el
Suikyo is Romaji-Kana conversion Library.

This package contains elisp binding of Suikyo.

%description -l ja el
水鏡はローマ字・かな変換ライブラリです．

このパッケージは水鏡の elisp バイディングを含んでいます．

%prep
%setup -q

%build
[[ ! -x configure ]] && ./autogen.sh

%configure --with-rubydir=%{rlibdir}
%{__make}


%check
%{__make} check


%install
rm -rf $RPM_BUILD_ROOT
%{__make} install DESTDIR=${RPM_BUILD_ROOT} sitelibdir=%{rlibdir}
rm -rf $RPM_BUILD_ROOT%{_datadir}/doc

### for GNU Emacs
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{name}
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}


#
# install el files
#

##%{__install} -m 644 %{SOURCE102} \
##    ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{name}/
%{__cat} > \
    ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{name}/%{name}-init.el <<EOF
;;
;; suikyo-init.el
;;
;; 	for Vine Linux with emacsen-common
;; 	Munehiro Yamamoto <munepi@cg8.so-net.ne.jp>

(defconst suikyo-version '("2.1.0" "2005-03-29"))

(provide 'init-suikyo)

;; end of file
EOF
##%{__cat} ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/init-suikyo.el >> \
##    ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{name}/%{name}-init.el
%{__rm} -f ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/init-suikyo.el
##%{__cat} >> \
##    ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{name}/%{name}-init.el <<EOF
##
##;; end of file
##EOF

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

%_installemacsenscript %{name} %{SOURCE100}

%_removeemacsenscript  %{name} %{SOURCE101}


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


%post -n %{name}-el
#
# bytecompile and install
#

if [ "$1" = 2 ] ; then

%_emacsenPackageRemove %{name}

fi

%_addemacsenlist %{name}

%_emacsenPackageInstall %{name}

%preun -n %{name}-el

if [ "$1" = 0 ]; then

%_emacsenPackageRemove %{name}

%_removeemacsenlist %{name}

fi


%files
%defattr(-,root,root)
%doc AUTHORS COPYING ChangeLog README
%{rlibdir}/*
%{_libdir}/pkgconfig/*
%{_datadir}/%{name}

%files -n %{name}-el
%defattr(-,root,root)
%doc AUTHORS COPYING ChangeLog README
%{_datadir}/emacs/site-lisp/%{name}/
%{_libdir}/emacsen-common/packages/install/%{name}
%{_libdir}/emacsen-common/packages/remove/%{name}


%changelog
* Sat Nov 01 2008 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 2.1.0-1
- initial build for VineSeed

* Mon Mar 24 2008 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 2.1.0-1vl5
- initial build for VineSeed

### end of file
