%bcond_without php5
%bcond_with php70

%define modname clearsilver

Summary: ClearSilver extension for PHP
Summary(ja): PHP用ClearSilverモジュール
Name: php-ext-%{modname}
Version: 0.4
Release: 8%{_dist_release}
URL: http://www.geodata.soton.ac.uk/software/php_clearsilver/
Source: php-%{modname}-%{version}.tar.gz
Patch0: php-clearsilver-0.4-php5.5.0.patch
Patch1: php-clearsilver-0.4-cgifunctions.patch
Patch2: php-clearsilver-0.4-php7.0.0.patch
License: The PHP License
Group: Development/Languages
BuildRequires: clearsilver, zlib-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-root

%if %{with php5}
BuildRequires: php5-devel
%endif

%if %{with php70}
BuildRequires: php70-devel
%endif

Vendor: Project Vine
Distribution: Vine Linux
Packager: tomop

%description
This module adds ClearSilver functions to PHP.

%description -l ja
このモジュールはPHPにClearSilverテンプレート機能を追加します。

%if %{with php5}
%package -n php5-ext-%{modname}
Summary: ClearSilver extension for PHP-5.6.x
Summary(ja): PHP-5.6.x用ClearSilverモジュール
Group: Development/Languages
%if "%{?req_php5_api}" != ""
Requires: %{req_php5_api}
%endif
Obsoletes: php-ext-clearsilver < 0.4-7

%description -n php5-ext-%{modname}
This module adds ClearSilver functions to PHP.

%description -n php5-ext-%{modname} -l ja
このモジュールはPHPにClearSilverテンプレート機能を追加します。

%endif

%if %{with php70}
%package -n php70-ext-%{modname}
Summary: ClearSilver extension for PHP-7.0.x
Summary(ja): PHP-7.0.x用ClearSilverモジュール
Group: Development/Languages
%if "%{?req_php70_api}" != ""
Requires: %{req_php70_api}
%endif

%description -n php70-ext-%{modname}
This module adds ClearSilver functions to PHP.

%description -n php70-ext-%{modname} -l ja
このモジュールはPHPにClearSilverテンプレート機能を追加します。

%endif

%prep
%setup -q -c -n php-%{modname}-%{version}

cp -a php-%{modname}-%{version}/{CREDITS,INSTALL,LICENSE,README,doc} ./

%if %{with php5}
cp -a php-clearsilver-%{version} php-clearsilver-%{version}-php5
pushd php-clearsilver-%{version}-php5
%patch0 -p1 -b .php55
%patch1 -p1 -b .cgifunctions
popd
%endif

%if %{with php70}
cp -a php-clearsilver-%{version} php-clearsilver-%{version}-php70
pushd php-clearsilver-%{version}-php70
%patch0 -p1 -b .php55
%patch1 -p1 -b .cgifunctions
%patch2 -p1 -b .php70
popd
%endif

%build
%if %{with php5}
pushd php-clearsilver-%{version}-php5
aclocal
autoconf
phpize5
libtoolize --copy --force
%configure --with-php-config=/usr/bin/php-config5
%__make %{_smp_mflags}
popd
%endif

%if %{with php70}
pushd php-clearsilver-%{version}-php70
aclocal
autoconf
phpize70
libtoolize --copy --force
%configure --with-php-config=/usr/bin/php-config70
%__make %{_smp_mflags}
popd
%endif

%install
rm -rf %{buildroot}
%if %{with php5}
pushd php-clearsilver-%{version}-php5
mkdir -p %{buildroot}%{_libdir}/php5/
mkdir -p %{buildroot}%{_sysconfdir}/php5/php.d

install -m644 modules/%{modname}.so %{buildroot}%{_libdir}/php5/

cat > %{buildroot}%{_sysconfdir}/php5/php.d/%{modname}.ini <<EOF
; Enable %{modname} extension module
extension=%{modname}.so
EOF
popd
%endif

%if %{with php70}
pushd php-clearsilver-%{version}-php70
mkdir -p %{buildroot}%{_libdir}/php70/
mkdir -p %{buildroot}%{_sysconfdir}/php70/php.d

install -m644 modules/%{modname}.so %{buildroot}%{_libdir}/php70/

cat > %{buildroot}%{_sysconfdir}/php70/php.d/%{modname}.ini <<EOF
; Enable %{modname} extension module
extension=%{modname}.so
EOF
popd
%endif

%clean
rm -rf %{buildroot}

%if %{with php5}
%files -n php5-ext-%{modname}
%defattr(-,root,root)
%doc CREDITS INSTALL LICENSE README doc
%{_libdir}/php5/*
%{_sysconfdir}/php5/php.d/*
%endif

%if %{with php70}
%files -n php70-ext-%{modname}
%defattr(-,root,root)
%doc CREDITS INSTALL LICENSE README doc
%{_libdir}/php70/*
%{_sysconfdir}/php70/php.d/*
%endif

%changelog
* Thu Nov  5 2015 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4-8
- fixed summary.
- fixed php70 stuff.

* Thu Nov  5 2015 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4-7
- added CGI functions.
- added support for php70.

* Fri Apr 10 2015 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4-6
- rebuilt with php5-5.6.7.

* Thu Jan 09 2014 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4-5
- rebuilt with current environment.

* Tue Jun 25 2013 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4-4
- added a patch for PHP 5.5.0.

* Sun Apr 29 2012 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4-3
- converted encoding to UTF-8.

* Sat Apr 28 2012 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4-2
- added an API version macro to "Requires:".

* Sat Dec 12 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4-1
- new upstream release.
 
* Fri Jul 10 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.1-2
- fixed for php-5.3.0.

* Mon Apr 28 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.1-1
- initial build.

