%define rlibdir %(ruby -r rbconfig -e 'print Config::CONFIG["rubylibdir"]')
%define rarchdir %(ruby -r rbconfig -e 'print Config::CONFIG["archdir"]')

Summary: Simple Kana to Kanji conversion server on ruby
Name: rskkserv
Version: 2.94.13
Release: 0vl2
License: GPL
Group: Applications/System
Source0: http://www.unixuser.org/~ysjj/rskkserv/%{name}-%{version}.tar.gz
Source1: rskkserv.init
Patch0: rskkserv.conf.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-root
#PreReq: chkconfig
BuildPreReq: autoconf ruby ruby-devel >= 1.8
Requires: ruby >= 1.8
Requires: gdbm skkdic
Conflicts: dbskkd-cdb
Provides: skkserv

%description
rskkserv is an alternate version of skkserv implemented by Ruby. 
Please use ruby-tcpwrap library for security. 

Now, supports multi skkdic and epwing dictionaries(*1). 

*1: Needs ruby-eb library for epwing dictionary.


%prep
rm -rf $RPM_BUILD_ROOT

%setup -n rskkserv-cvs -q
%patch0

%build
autoconf
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
	--with-rubylibdir=%{rlibdir} --with-rubyarchdir=%{rarchdir}
make

%install
#make install DESTDIR=${RPM_BUILD_ROOT} libdir=${RPM_BUILD_ROOT}/usr/lib
make install DESTDIR=${RPM_BUILD_ROOT} \
	rsslibdir=${RPM_BUILD_ROOT}%{rlibdir} \
	rssarchdir=${RPM_BUILD_ROOT}%{rarchdir}
cd ext
make install DESTDIR=${RPM_BUILD_ROOT} RUBYLIBDIR=${RPM_BUILD_ROOT}%{rlibdir}/skkserv
cd ..
mkdir -p ${RPM_BUILD_ROOT}/etc/rc.d/init.d
install -m 755 ${RPM_SOURCE_DIR}/rskkserv.init ${RPM_BUILD_ROOT}/etc/rc.d/init.d/rskkserv

%clean
rm -fr ${RPM_BUILD_ROOT}

%post
/sbin/chkconfig --add rskkserv
if test -r /var/run/rskkserv.pid; then
    /etc/rc.d/init.d/rskkserv stop
    /etc/rc.d/init.d/rskkserv start
fi

%preun
if [ "$1" = 0 ]; then
    if test -r /var/run/rskkserv.pid; then
        /etc/rc.d/init.d/rskkserv stop
    fi
    /sbin/chkconfig --del rskkserv
fi


%files
%defattr(-,root,root)
%doc COPYING ChangeLog README TODO 
%config /etc/rskkserv.conf
%config /etc/rc.d/init.d/rskkserv
/usr/sbin/skkserv.rb
%{rlibdir}/skkserv
%{rarchdir}/skkserv
%dir /var/cache/rskkserv

%ChangeLog
* Fri Jul 28 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.94.13-0vl2
- rebuilt with ruby 1.8
- changed Group to Applications/System

* Wed Oct 08 2003 UECHI Yasumasa <uh@u.dhis.portside.net> 2.94.13-0vl1
- new upstream version
- add rsslibdir/rssarchdir to 'make install'
- add 'make install' in ext directory
- add patch0 (rskkserv.conf.patch)
- build with ruby-1.8.0

* Tue May 27 2003 UECHI Yasumasa <uh@u.dhis.portside.net>
- 2.94.12a-0vl2
- add Provides: skkserv

* Sun May 25 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org>
- 2.94.12a-0vl1
- update to 2.94.12a

* Fri Jul 27 2001 UECHI Yasumasa <uh@u.dhis.portside.net>
- 2.94.11-0vl2
- add ruby and ruby-devl>=1.6.4-0vl3 to BuildPreReq
- use Config::CONFIG for library path in files section

* Thu Jul 19 2001 UECHI Yasumasa <uh@u.dhis.portside.net>
- 2.94.11-0vl1
- version up to 2.94.11

* Mon Jul  9 2001 UECHI Yasumasa <uh@u.dhis.portside.net>
- 2.94.9-0vl2
- patch for HENKAN failure when using EBDic module

* Wed Mar 7 2001 Uechi Yasumasa <uh@u.dhis.portside.net>
- 2.94.9-0vl1
- update to 2.94.9
- rewrite spec file for vine
- remove skk dictionaries and tools from this pkg

* Sat Feb  3 2001 Daiki Matsuda <dyky@df-usa.com>
- (2.3.2-5k)
- rebuild againt rpm-3.0.5-39k

* Tue Nov 28 2000 Toru Hoshina <toru@df-usa.com>
- use _initscriptdir macro to keep backword compatibility.

* Tue Oct 16 2000 Toru Hoshina <toru@df-usa.com>
- rebuild against ruby 1.6.1

* Fri Sep 9 2000 Toru Hoshina <t@kondara.org>
- rebuild against glibc 2.1.93.

* Fri Sep 9 2000 Toru Hoshina <t@kondara.org>
- (2.3-0k)
- update to 2.3

* Thu Aug 10 2000 AYUHANA Tomonori <l@kondara.org>
- (2.2-1k)
- update to 2.2
- comment outed %patch0 (needless?)

* Wed Jul 05 2000 Toru Hoshina <t@kondara.org>
- rebuild against glibc-2.1.90, X-4.0, rpm-3.0.5.

* Fri Apr 28 2000 Yasumasa Uechi <uh@kondara.org>
- update to 2.1

* Tue Apr 11 2000 Toru Hoshina <t@kondara.org>
- rskkserv work only with localhost:127.0.0.1.

* Sat Mar 11 2000 Tenkou N. Hattori <tnh@kondara.org>
- add rskkserv-local.rb

* Wed Feb 23 2000 Hidetomo Machi <mcHT@kondara.org>
- add PreReq: /sbin/chkconfig
- include /usr/share/skk directory

* Sat Nov 27 1999 Toru Hoshina <t@kondara.org>
- remove tutrials to avoid conflicts.

* Sun Nov 7 1999 Toru Hoshina <t@kondara.org>
- be a NoSrc :-P

* Sun Sep  5 1999 Toru Hoshina<hoshina@best.com>
- add norika patch.

* Sun Jun 27 1999 Toru Hoshina<hoshina@best.com>
- rebuild against rpm-3.0.2-0.4.

* Tue Mar 16 1999 Toru Hoshina<hoshina@best.com>
- rebuild against rawhide 1.2.9

* Fri Feb 19 1999 Toru Hoshina <hoshina@best.com>
- 1st release

