%define ruby_archdir %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["archdir"]')

Summary:       An interpreter of embedded Ruby language
Summary(ja):   テキスト埋め込みの Ruby 言語インタプリタ
Name:          eruby
Version:       1.0.5
Release:       5%{?_dist_release}
# eruby is GPLv2+
# liberuby is LGPLv2+
License:       GPLv2+ and LGPLv2+
Group:         Development/Languages
Source0:       http://www.modruby.net/archive/%{name}-%{version}.tar.gz
Patch0:        patch-aa-git
Patch1:        eruby-fix-build.patch
Patch2:	       eruby-1.0.5-ruby19.patch
URL:           http://www.modruby.net/
Prefix:        /usr
BuildRoot:     %{_tmppath}/%{name}-%{version}-root
BuildRequires: ruby, ruby-devel >= 1.9


%description
eRuby interprets a Ruby code embedded text file. For example, eRuby
enables you to embed a Ruby code to a HTML file.

%description -l ja
eRubyはRubyのコードが埋めこまれたテキストファイルを解釈実行します．た
とえば，eRubyを使えば，HTMLにRubyのコードをHTMLファイルに埋めこむこと
ができます．


%package -n liberuby
Summary:     Library for eruby
Summary(ja): eruby 用ライブラリ
Group:       System Environment/Libraries
Requires:    libruby >= 1.8.0

%description -n liberuby
This package includes library for eruby.

%description -n liberuby -l ja
eruby に必要なライブラリです。


%package -n liberuby-devel
Summary:     A eRuby development environment.
Summary(ja): eRuby 開発環境
Group:       Development/Libraries
Requires:    liberuby = %{version}
Obsoletes:   eruby-devel

%description -n liberuby-devel
Header files and libraries for an application embedded ERuby.

%description -n liberuby-devel -l ja
ERubyを組み込んだアプリケーションを作るために必要となるへッダファイルや
ライブラリです．


%prep
%setup -q
%patch0 -p1 -b .git
%patch1 -p1 -b .0-build
%patch2 -p1 -b .ruby19

%build
ruby configure.rb --enable-shared
make

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_libdir}
mkdir -p %{buildroot}%{_datadir}
mkdir -p %{buildroot}%{_mandir}/man1
mkdir -p %{buildroot}%{_includedir}
mkdir -p %{buildroot}%{ruby_vendorarchdir}

# installing binaries ...
make install DESTDIR=$RPM_BUILD_ROOT RUBY=ruby rubyarchdir=$RPM_BUILD_ROOT%{ruby_archdir}

# remove the unnecessary files
rm %{buildroot}%{_libdir}/*.a

# change permissions
find %{buildroot}%{_libdir} -name '*.so*' | xargs chmod 0755

# workaround for not working site-install properly
mv $RPM_BUILD_ROOT%{ruby_archdir}/eruby.so $RPM_BUILD_ROOT%{ruby_vendorarchdir}/

%clean
rm -rf %{buildroot}


%post -p /sbin/ldconfig -n liberuby


%postun -p /sbin/ldconfig -n liberuby


%files -n eruby
%defattr(-, root, root)
%{rbindir}/%{name}
%{_mandir}/man1/%{name}.1*
%doc COPYING GPL LGPL
%doc README* ChangeLog examples


%files -n liberuby
%defattr(-, root, root)
%{_libdir}/lib%{name}.so.*
%{ruby_vendorarchdir}/%{name}*


%files -n liberuby-devel
%defattr(-, root, root)
%{_libdir}/lib%{name}.so
%{_includedir}/%{name}*.h


%changelog
* Fri Sep 11 2015 Daisuke SUZUKI <daisuke@vinelinux.org> 2.0.5-5
- rebuild with ruby-2.2.3

* Sat Jul 12 2014 Daisuke SUZUKI <daisuke@vinelinux.org> 1.0.5-4
- rebuild with ruby-2.1.2

* Fri Oct 26 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 1.0.5-3
- rebuild with ruby-1.9.3
- add patches from FreeBSD/fedora

* Thu Mar 22 2012 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.0.5-2
- rebuild; spec revamp; remove *.a file

* Fri Aug 15 2008 Shu KONNO <owa@bg.wakwak.com> 1.0.5-1vl5
- applied new versioning policy, spec in utf-8

* Mon Sep 18 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.0.5-0vl3
- changed liberuby Group to System Environment/Libraries
- changed liberuby-devel Group to Development/Libraries

* Sat Jul 29 2006 NAKAMURA Kenta <kenta@vinelinux.org> 1.0.5-0vl2
- s/Copyright/License/
- added "libdir=${RPM_BUILD_ROOT}%{_libdir}" to make install option

* Tue Dec 30 2003 akira yamada <akira@vinelinux.org> 1.0.5-0vl1
- new upstream version.

* Mon Oct 06 2003 akira yamada <akira@vinelinux.org> 1.0.4-0vl1
- new upstream version.
- build with ruby-1.8.0.

* Mon Jul 21 2003 IWAI Masaharu <iwai@alib.jp> 1.0.3-0vl1
- new upstream version.

* Thu May 30 2002 akira yamada <akira@vinelinux.org> 0.9.8-0vl2
- updated URL of upstream sources.

* Thu May 30 2002 akira yamada <akira@vinelinux.org> 0.9.8-0vl1
- new upstream version.

* Wed Aug 08 2001 akira yamada <akira@vinelinux.org> 0.9.7-0vl1
- new upstream version.

* Wed Aug 08 2001 akira yamada <akira@vinelinux.org>
- 0.9.6-0vl1
- new upstream version 0.9.6.

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

* Mon Jun 25 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>
- 0.9.5-0vl2
- added "Obsoletes: eruby-devel" for liberuby-devel

* Thu Jun 21 2001 akira yamada <akira@vinelinux.org>
- Updated to upstream version 0.9.5.
- eruby -> eruby + liberuby
- eruby-devel -> liberuby-devel

* Mon Jun 07 2001 akira yamada <akira@vinelinux.org>
- Updated to upstream version 0.9.4.

* Mon Jun 04 2001 akira yamada <akira@vinelinux.org>
- Updated to upstream version 0.9.3.

* Thu Oct 19 2000 akira yamada <akira@vinelinux.org>
- Updated to upstream version 0.1.2.

* Thu Sep 27 2000 akira yamada <akira@vinelinux.org>
- Updated to upstream version 0.1.1
- New binary package: eruby-devel
- Removed eruby.c.O_EXCL.patch (fixed at 0.1.1)

* Tue Aug 29 2000 akira yamada <akira@vinelinux.org>
- Updated to upstream  version 0.0.9
- Added eruby.c.O_EXCL.patch

* Tue Jun 22 2000 akira yamada <akira@redhat.com>
- Initial packaging.
