%bcond_without php80
%bcond_without php74

%define extname mailparse

Summary: Email message manipulation for PHP
Summary(ja): PHP用e-mailメッセージ操作拡張
Name: php-ext-%{extname}
Version: 3.1.1
Release: 1%{_dist_release}
Group: programming
Vendor: Project Vine
Distribution: Vine Linux
Packager: tomop

License: The PHP License
URL: https://pecl.php.net/package/mailparse
Source: https://pecl.php.net/get/%{extname}-%{version}.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-root

%description
 Mailparse is an extension for parsing and working with email messages.
It can deal with rfc822 and rfc2045 (MIME) compliant messages.

%description -l ja
 Mailparseモジュールは、e-mailメッセージの解析・操作を行うPHP拡張です。
rfc822やrfc2045 (MIME)に準拠したメッセージを取り扱うことが可能です。


%if %{with php74}
%package -n php74-ext-mailparse
Summary: Email message manipulation for PHP-7.4
Summary(ja): PHP-7.4用e-mailメッセージ操作拡張
Group: programming
BuildRequires: php74-devel
%if "%{?req_php74_api}" != ""
Requires: %{req_php74_api}
%endif

%description -n php74-ext-mailparse
 Mailparse is an extension for parsing and working with email messages.
It can deal with rfc822 and rfc2045 (MIME) compliant messages.

%description -n php74-ext-mailparse -l ja
 Mailparseモジュールは、e-mailメッセージの解析・操作を行うPHP拡張です。
rfc822やrfc2045 (MIME)に準拠したメッセージを取り扱うことが可能です。
%endif

%if %{with php80}
%package -n php80-ext-mailparse
Summary: Email message manipulation for PHP-8.0
Summary(ja): PHP-8.0用e-mailメッセージ操作拡張
Group: programming
BuildRequires: php80-devel
%if "%{?req_php80_api}" != ""
Requires: %{req_php80_api}
%endif

%description -n php80-ext-mailparse
 Mailparse is an extension for parsing and working with email messages.
It can deal with rfc822 and rfc2045 (MIME) compliant messages.

%description -n php80-ext-mailparse -l ja
 Mailparseモジュールは、e-mailメッセージの解析・操作を行うPHP拡張です。
rfc822やrfc2045 (MIME)に準拠したメッセージを取り扱うことが可能です。
%endif


%debug_package


%prep
%setup -q -c -n %{extname}-%{version}
cp %{extname}-%{version}/{LICENSE,README.md,CREDITS} ./

%if %{with php74}
cp -a %{extname}-%{version} php74
pushd php74
phpize74
popd
%endif

%if %{with php80}
cp -a %{extname}-%{version} php80
pushd php80
phpize80
popd
%endif


%build
%if %{with php74}
pushd php74
%configure --with-php-config=%{_bindir}/php-config74
%__make %{?_smp_mflags}
popd
%endif

%if %{with php80}
pushd php80
%configure --with-php-config=%{_bindir}/php-config80
%__make %{?_smp_mflags}
popd
%endif


%install
rm -rf %{buildroot}
%if %{with php74}
mkdir -p %{buildroot}%{_libdir}/php74/
mkdir -p %{buildroot}%{_sysconfdir}/php74/php.d
pushd php74
%makeinstall INSTALL_ROOT=%{buildroot}
popd

cat > %{buildroot}%{_sysconfdir}/php74/php.d/%{extname}.ini <<EOF
; Enable %{extname} extension module
extension=%{extname}.so

EOF
%endif

%if %{with php80}
mkdir -p %{buildroot}%{_libdir}/php80/
mkdir -p %{buildroot}%{_sysconfdir}/php80/php.d
pushd php80
%makeinstall INSTALL_ROOT=%{buildroot}
popd

cat > %{buildroot}%{_sysconfdir}/php80/php.d/%{extname}.ini <<EOF
; Enable %{extname} extension module
extension=%{extname}.so

EOF
%endif


%clean
rm -rf %{buildroot}

%if %{with php74}
%files -n php74-ext-mailparse
%defattr(-,root,root)
%license LICENSE
%doc README CREDITS
%{_libdir}/php74/*
%config(noreplace) %{_sysconfdir}/php74/php.d/*
%endif

%if %{with php80}
%files -n php80-ext-mailparse
%defattr(-,root,root)
%license LICENSE
%doc README CREDITS
%{_libdir}/php80/*
%config(noreplace) %{_sysconfdir}/php80/php.d/*
%endif


%changelog
* Sat Dec 19 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.1.1-1
- new upstream release.
- added php80 support.
- dropped php73 support.

* Thu Dec 19 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.0.3-1
- dropped Patch0: fixed in upstream.
- added php74 support.
- dropped php72 support.

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

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

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

* Fri Dec 13 2013 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.1.6-1
- initial build.