%define oname    racc
%define ruby     /usr/bin/ruby
%define rversion %(%{ruby} 'print VERSION')
%define rbindir  %(%{ruby} -r rbconfig -e 'print Config::CONFIG["bindir"]')
%define rlibdir  %(%{ruby} -r rbconfig -e 'print Config::CONFIG["rubylibdir"]')
%define rarchdir %(%{ruby} -r rbconfig -e 'print Config::CONFIG["archdir"]')

Summary: A generator of LALR parser written by Ruby
Name: %{oname}
Version: 1.4.3
Release: 1%{?_dist_release}
License: LGPL
Group: Development/Tools
Source: http://www.loveruby.net/archive/racc/%{oname}-%{version}-all.tar.gz
Patch1: racc-1.4.3-setup.rb.patch
URL: http://www.loveruby.net/ja/prog/%{oname}.html
Prefix: /usr
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: ruby, ruby-devel >= 1.8.0
Requires: ruby >= 1.8.0
Summary(ja): Rubyで書かれたLALR(1)パーザ生成器

%description
Racc is LALR(1) parser generator coded for Ruby.  Written by Ruby and
output Ruby source.

%description -l ja
raccはRubyで書かれたLALR(1)パーザ生成器で、Rubyのコードを出力します。

%prep

%setup -q -c
cd %{oname}-%{version}-all
%patch1 -p1
cd ..

%build
cd %{oname}-%{version}-all
ruby setup.rb config \
  --with=racc \
  --bin-dir=%{rbindir} \
  --rb-dir=%{rlibdir} \
  --so-dir=%{rarchdir}
ruby setup.rb setup
cd ..

%install
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}%{rbindir}
mkdir -p ${RPM_BUILD_ROOT}%{rlibdir}
mkdir -p ${RPM_BUILD_ROOT}%{rarchdir}

# installing binaries ...
cd %{oname}-%{version}-all
ruby setup.rb config \
  --with=racc \
  --bin-dir=${RPM_BUILD_ROOT}%{rbindir} \
  --rb-dir=${RPM_BUILD_ROOT}%{rlibdir} \
  --so-dir=${RPM_BUILD_ROOT}%{rarchdir}
ruby setup.rb install
cd ..

# listing all files in %{oname}-all.files
(find \
  $RPM_BUILD_ROOT%{rbindir} \
  $RPM_BUILD_ROOT%{rlibdir} \
  $RPM_BUILD_ROOT%{rarchdir} \
      -type f -o -type l) | 
 sort | uniq | \
  sed -e "s,^$RPM_BUILD_ROOT,," \
      -e "s,\(/man/man./.*\)$,\1*," \
 > %{oname}.files

%clean
rm -rf ${RPM_BUILD_ROOT}
rm -f *.files

#%post -p /sbin/ldconfig -n %{oname}

#%postun -p /sbin/ldconfig -n %{oname}

%files -f %{oname}.files
%defattr(-, root, root)
%doc %{oname}-%{version}-all/packages/racc/BUGS.en
%doc %{oname}-%{version}-all/packages/racc/BUGS.ja
%doc %{oname}-%{version}-all/packages/racc/README.en
%doc %{oname}-%{version}-all/packages/racc/README.ja
%doc %{oname}-%{version}-all/packages/racc/doc.en
%doc %{oname}-%{version}-all/packages/racc/doc.ja
%doc %{oname}-%{version}-all/packages/racc/sample

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

* Wed Dec 19 2007 Shu KONNO <owa@bg.wakwak.com> racc-1.4.3-0vl3
- s/Copyright/License/

* Mon Oct 06 2003 akira yamada <akira@vinelinux.org> racc-1.4.3-0vl2
- build with ruby-1.8.0.  it requires libruby >= 1.8.0.
- obsoleted racc-runtime sub-package.  runtime environment of Racc is in
  libruby >= 1.8.0.

* Thu May 22 2003 IWAI Masaharu <iwai@alib.jp> 1.4.3-0vl1
- new upstream version
- update setup.rb.patch (Patch1)

* Fri Mar 08 2002 akira yamada <akira@vinelinux.org> 1.4.2-0vl1
- new upstream version.
- update location of source and homepage.

* Fri Mar 08 2002 akira yamada <akira@vinelinux.org> 1.4.1-0vl1
- new upstream version.
- no longer requires ruby-amstd.

* Sat Oct 28 2001 akira yamada <akira@vinelinux.org> 1.3.11-0vl1
- new upstream version.
- corrected Reqreuis.

* Thu Jul 26 2001 akira yamada <akira@vinelinux.org>
- rebuild with ruby-devel-1.6.4-0vl3.

* Tue Mar 20 2001 akira yamada <akira@vinelinux.org>
- New upstream version 1.3.8.

* Thu Mar 15 2001 akira yamada <akira@vinelinux.org>
- New upstream version.

* Thu Mar 15 2001 akira yamada <akira@vinelinux.org>
- Initial packaging.
