%define name clearsilver
%define version 0.10.5
%define release 10%{_dist_release}

Summary: A fast, powerful, and language-neutral HTML template system.
Summary(ja): 高速、パワフルで言語中立なHTMLテンプレートシステム
Name: %{name}
Version: %{version}
Release: %{release}

License: Neotonic ClearSilver Software License
Group: Applications/Text
URL: http://clearsilver.net/

Source0: http://clearsilver.net/downloads/%{name}-%{version}.tar.gz
Patch0: clearsilver-0.10.5-conf.patch
Patch1: clearsilver-0.10.5-regression.patch
Patch2: clearsilver-0.10.5-CVE-2011-4357.patch
Patch3: clearsilver-ruby-1.9.patch
Patch4: clearsilver-ruby-2.2.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: perl
BuildRequires: python-devel
BuildRequires: ruby
BuildRequires: ruby-devel >= 1.9.3
BuildRequires: zlib-devel
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
Provides: ruby(clearsilver)

Vendor: Project Vine
Distribution: Vine Linux

%description
ClearSilver is a fast, powerful, and language-neutral template system.
It is designed to make it easy to create template driven static or
dynamic websites.

%description -l ja
Clearsilver は高速、強力で言語中立なテンプレートシステムです。
テンプレート駆動の静的あるいは動的な Web サイトの構築を
容易にすることを目指して設計されています。

%prep
%setup -q
%patch0 -p1 -b .conf
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
touch configure
perl -pi -e 's/python_versions="2\.5/python_versions="2.7 2.6 2.5/' configure
sed -i 's|/neo/opt/bin/python|%{__python}|' python/examples/*/*.py
sed -i 's|PYTHON_SITE = @PYTHON_SITE@|PYTHON_SITE = %{python_sitearch}|' rules.mk.in
find python/examples -type f | xargs chmod -x


%build
%configure --disable-csharp

%ifarch x86_64
perl -pi -e 's/^(TARGETS =.+) test/$1/' cs/Makefile
%endif

%__make %{_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT
cd ruby
%ruby install.rb config --rb-dir=${RPM_BUILD_ROOT}%{ruby_vendorlibdir} --so-dir=${RPM_BUILD_ROOT}%{ruby_vendorarchdir}
cd ..
make DESTDIR=${RPM_BUILD_ROOT} install

find $RPM_BUILD_ROOT -type f -name '*.bs' -size 0 -exec rm -f {} \;
find $RPM_BUILD_ROOT \( -name perllocal.pod -o -name .packlist \) -exec rm -v {} \;
find $RPM_BUILD_ROOT -depth -type d -exec rmdir {} 2>/dev/null \;

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc CS_LICENSE INSTALL LICENSE README README.python
%{_bindir}/*
%{_includedir}/ClearSilver/
%{perl_sitearch}/*.pm
%{perl_sitearch}/auto/ClearSilver/
%{ruby_vendorarchdir}/*.so
%{ruby_vendorlibdir}/*.rb
%{python_sitearch}/*.so
%{_libdir}/*.a
%{_mandir}/man*/*.gz

%changelog
* Sat Sep 12 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.10.5-10
- rebuild with ruby-2.2.3
- add Patch4 (clearsilver-ruby-2.2.patch) from fedora

* Wed Dec 17 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 0.10.5-9
- rebuilt with perl 5.16.3 and ruby 2.1.5

* Sun Dec 08 2013 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.10.5-8
- rebuilt with ruby-2.0.0.353.

* Thu Oct 25 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 0.10.5-7
- rebuild with ruby-1.9.3
- add patch3 to build with ruby-1.9
- add patch2 for CVE-2011-4357

* Sat Feb 25 2012 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.10.5-6
- rebuilt with python-2.7.

* Sun May 15 2011 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.10.5-5
- rebuilt with perl-5.12.3 and python-2.6.

* Mon Jun 22 2009 Shu KONNO <owa@bg.wakwak.com> 0.10.5-4
- applied new versioning policy, spec in utf-8

* Mon Jul 21 2008 Shu KONNO <owa@bg.wakwak.com> 0.10.5-3
- rebuilt with python-2.5.2
- added clearsilver-0.10.5-conf.patch

* Tue Apr 29 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.10.5-2
- rebuilt with perl-5.10.0.

* Mon Apr 28 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.10.5-1
- x86_64: make to skip testing.

* Fri Nov 09 2007 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.10.5-0vl4
- add --disable-csharp for configure script

* Tue Aug 28 2007 KANEKO Seiji <giraffe@m2.pbc.ne.jp> 0.10.5-0vl2
- initial build for Vine Linux
