%bcond_without php82
%bcond_without php81
%bcond_with php74

%define extname mailparse

Summary: Email message manipulation for PHP
Summary(ja): PHP用e-mailメッセージ操作拡張
Name: php-ext-%{extname}
Version: 3.1.4
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

%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 php82}
%package -n php82-ext-mailparse
Summary: Email message manipulation for PHP-8.2
Summary(ja): PHP-8.2用e-mailメッセージ操作拡張
Group: programming
BuildRequires: php82-devel
%if "%{?req_php82_api}" != ""
Requires: %{req_php82_api}
%endif

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

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

%description -n php81-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 php81-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 php82}
cp -a %{extname}-%{version} php82
pushd php82
phpize82
popd
%endif

%if %{with php81}
cp -a %{extname}-%{version} php81
pushd php81
phpize81
popd
%endif


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

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

%if %{with php81}
pushd php81
%configure --with-php-config=%{_bindir}/php-config81
%__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 php82}
mkdir -p %{buildroot}%{_libdir}/php82/
mkdir -p %{buildroot}%{_sysconfdir}/php82/php.d
pushd php82
%makeinstall INSTALL_ROOT=%{buildroot}
popd

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

EOF
%endif

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

cat > %{buildroot}%{_sysconfdir}/php81/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 php82}
%files -n php82-ext-mailparse
%defattr(-,root,root)
%license LICENSE
%doc README CREDITS
%{_libdir}/php82/*
%config(noreplace) %{_sysconfdir}/php82/php.d/*
%endif

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


%changelog
* Fri Mar 17 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.1.4-1
- new upstream release.
- added php82 support.
- dropped php80 support.
- disabled php74 support.

* Fri Nov 26 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.1.2-2
- added php81 support.

* Mon Nov 22 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.1.2-1
- new upstream release.

* 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.