# needs launching memcached
%bcond_with test

%define build_targets 81
%define extname memcached

%define srcdir php-memcached-%{version}

Summary: memcached extension for PHP
Summary(ja): PHP用memcached拡張
Name: php-ext-memcached
Version: 3.2.0
Release: 3%{_dist_release}
Group: programming
Vendor: Project Vine
Distribution: Vine Linux
Packager: tomop

License: The PHP License
#Source: https://pecl.php.net/get/memcached-3.2.0RC2.tgz
Source: https://github.com/php-memcached-dev/php-memcached/archive/v%{version}.tar.gz#/php-%{extname}-%{version}.tar.gz
BuildRequires: libmemcached-awesome-devel
BuildRequires: zlib-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-root

%description
This module enable to access memcached in PHP scripts.

%description -l ja
このモジュールは、PHPスクリプト中でmemcachedにアクセスできるようにします。


%package -n php81-ext-%{extname}
Summary: memcached extension for PHP-8.1
Summary(ja): PHP-8.1用memcached拡張
Group: programming
BuildRequires: php81-devel
%if "%{?req_php81_api}" != ""
Requires: %{req_php81_api}
%endif

%description -n php81-ext-%{extname}
This module enable to access memcached in PHP scripts.

%description -n php81-ext-%{extname} -l ja
このモジュールは、PHPスクリプト中でmemcachedにアクセスできるようにします。


%debug_package


%prep
%setup -T -c -a 0 -n %{srcdir}
pushd %{srcdir}

mkdir -p ../docs
cp -f CREDITS LICENSE README* ChangeLog ../docs/
popd

for v in %{build_targets}; do
cp -a %{srcdir} php${v}
done


%build
for v in %{build_targets}; do
pushd php${v}
phpize${v}
%configure --with-php-config=php-config${v}
%__make %{?_smp_mflags}
popd
done


%install
cat > memcached.ini <<EOF
; Enable memcached extension module
extension=memcached.so

EOF

cat %{srcdir}/memcached.ini >> memcached.ini

for v in %{build_targets}; do
pushd php${v}

mkdir -p %{buildroot}%{_libdir}/php${v}/
mkdir -p %{buildroot}%{_sysconfdir}/php${v}/php.d
%makeinstall INSTALL_ROOT=%{buildroot}

install -m644 ../memcached.ini %{buildroot}%{_sysconfdir}/php${v}/php.d/memcached.ini

cat > ../files.php${v} <<EOF
%%defattr(-,root,root)
%%doc docs/*
%{_libdir}/php${v}/*
%%config(noreplace) %{_sysconfdir}/php${v}/php.d/*
EOF

popd
done


%check
%if %{with test}
for v in %{build_targets}; do
pushd php${v}
NO_INTERACTION=yes TEST_PHPDBG_EXECUTABLE=/usr/bin/phpdbg${v} make test
popd
done
%endif


#%files -n php74-ext-%{extname} -f files.php74
%files -n php81-ext-%{extname} -f files.php81


%changelog
* Fri Mar 25 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.2.0-3
- updated to 3.2.0.

* Thu Mar 10 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.2.0-2.rc2
- updated to 3.2.0RC2.

* Tue Mar 08 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.2.0-1.rc1
- updated to 3.2.0RC1.

* Fri Nov 26 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.1.5.git20211126-1
- sync to git HEAD.
- added php81 support.

* Sat Mar 20 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.1.5.git20210320-1
- sync to git HEAD.
- dropped Patch0: fixed in upstream.

* Sat Dec 19 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.1.5.git20201219-1
- moved to git HEAD.
- added php80 support.
- dropped php73 support.

* Thu Dec 19 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.1.5-1
- new upstream release.
- added php74 support.

* Fri Dec 21 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.1.1-1
- new upstream release.
- dropped Patch1: fixed in upstream.
- drooped php72 support.

* Sat Dec 08 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.0.5-1
- added php73 support.

* Wed Dec 20 2017 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.0.4-1
- new upstream release.

* Thu Mar 16 2017 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.0.3-1
- initial build for Vine Linux.
