# Detect the distribution in use
%global __despace head -n 1 | tr -d '[:space:]' | sed -e 's/[(].*[)]//g'
%global __lower4 cut -c 1-4 | tr '[:upper:]' '[:lower:]'
%global __distfile %([ -f /etc/SuSE-release ] && echo /etc/SuSE-release || echo /etc/redhat-release)
%global __distinit %(sed -e 's/ release .*//' -e 's/\\([A-Za-z]\\)[^ ]*/\\1/g' %{__distfile} | %{__despace} | %{__lower4})
%global __distvers %(sed -e 's/.* release \\([^. ]*\\).*/\\1/' %{__distfile} | %{__despace})
# Identify Alma, CentOS, CentOS Stream and Rocky Linux as rhel
%if "%{__distinit}" == "a" || "%{__distinit}" == "c" || "%{__distinit}" == "cl" || "%{__distinit}" == "cs" || "%{__distinit}" == "rl"
%global __distinit rhel
%endif
# Dist tag for Fedora is still "fc"
%if "%{__distinit}" == "f"
%global __distinit fc
%endif

Name:		perl-List-MoreUtils-XS
Version:	0.430
Release:	14.%{__distinit}%{__distvers}
Summary:	Provide compiled List::MoreUtils functions
# Code from List-MoreUtils < 0.417 is GPL-1.0-or-later OR Artistic-1.0-Perl
# Anything after that is Apache-2.0
# "git blame" on the upstream repo will probably be needed to
# determine the license of any particular chunk of code
License:	(GPL-1.0-or-later OR Artistic-1.0-Perl) AND Apache-2.0
URL:		https://metacpan.org/release/List-MoreUtils-XS
Source0:	https://cpan.metacpan.org/modules/by-module/List/List-MoreUtils-XS-%{version}.tar.gz
# Module Build
BuildRequires:	coreutils
BuildRequires:	findutils
BuildRequires:	gcc
BuildRequires:	make
BuildRequires:	perl-devel
BuildRequires:	perl-generators
BuildRequires:	perl-interpreter
BuildRequires:	perl(Carp)
BuildRequires:	perl(Config)
BuildRequires:	perl(constant)
BuildRequires:	perl(ExtUtils::CBuilder)
BuildRequires:	perl(ExtUtils::MakeMaker)
BuildRequires:	perl(File::Basename)
BuildRequires:	perl(File::Spec)
BuildRequires:	perl(File::Temp)
BuildRequires:	perl(IO::File)
BuildRequires:	perl(IO::Handle)
BuildRequires:	perl(lib)
BuildRequires:	perl(PerlIO)
BuildRequires:	perl(Scalar::Util)
BuildRequires:	perl(Text::ParseWords)
# Module Runtime (wants XSLoader 0.22 but seems to work OK with earlier versions)
BuildRequires:	perl(base)
BuildRequires:	perl(Exporter)
BuildRequires:	perl(strict)
BuildRequires:	perl(vars)
BuildRequires:	perl(warnings)
BuildRequires:	perl(XSLoader)
# Test Suite
BuildRequires:	perl(JSON::PP)
BuildRequires:	perl(List::Util)
BuildRequires:	perl(Math::Trig)
BuildRequires:	perl(overload)
BuildRequires:	perl(POSIX)
BuildRequires:	perl(Storable)
BuildRequires:	perl(Test::Builder::Module)
BuildRequires:	perl(Test::LeakTrace)
BuildRequires:	perl(Test::More) >= 0.96
BuildRequires:	perl(Tie::Array)
# Dependencies
%if 0%{?fedora} < 38 && 0%{?rhel} < 10
Requires:	perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
%endif

# Don't "provide" private Perl libs
%{?perl_default_filter}

%description
This module provides accelerated versions of functions in List::MoreUtils.

%prep
%setup -q -n List-MoreUtils-XS-%{version}

%build
perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}"
make %{?_smp_mflags}

%install
make pure_install DESTDIR=%{buildroot}
find %{buildroot} -type f -name .packlist -delete
find %{buildroot} -type f -name '*.bs' -empty -delete
%{_fixperms} -c %{buildroot}

%check
make test

%files
%license ARTISTIC-1.0 GPL-1 LICENSE
%doc Changes MAINTAINER.md README.md
%{perl_vendorarch}/auto/List/
%{perl_vendorarch}/List/
%{_mandir}/man3/List::MoreUtils::XS.3*

%changelog
* Thu Jun 13 2024 Paul Howarth <paul@city-fan.org> - 0.430-14
- Perl 5.40 rebuild

* Tue Jul 11 2023 Paul Howarth <paul@city-fan.org> - 0.430-10
- Perl 5.38 rebuild

* Wed Apr 26 2023 Paul Howarth <paul@city-fan.org> - 0.430-8
- Use SPDX-format license tag

* Wed Jun  1 2022 Paul Howarth <paul@city-fan.org> - 0.430-6
- Perl 5.36 rebuild

* Fri May 21 2021 Paul Howarth <paul@city-fan.org> - 0.430-3
- Perl 5.34 rebuild

* Wed Oct 21 2020 Paul Howarth <paul@city-fan.org> - 0.430-1
- Update to 0.430
  - Fix parts of CPAN RT#123989: more $a/$b/$_ refcounting bugs
    - Since some bugs are simply reported wrong, dealing with them breaks more
      (including running code) than it solves - way too heavy to feel better...
  - Introduce functions slide and slideatatime
  - Toolchain fixes
  - Fix LANG=nb_NO.utf8 related str tests fails (CPAN RT#133128)
  - Fix typo (GH#7)
  - Fix parts of CPAN RT#132043: listcmp misbehave in XS implementation

* Thu Jun 25 2020 Paul Howarth <paul@city-fan.org> - 0.428-9
- Perl 5.32 rebuild

* Fri May 31 2019 Paul Howarth <paul@city-fan.org> - 0.428-6
- Perl 5.30 rebuild

* Wed Jun 27 2018 Paul Howarth <paul@city-fan.org> - 0.428-3
- Perl 5.28 rebuild

* Thu Dec 21 2017 Paul Howarth <paul@city-fan.org> - 0.428-1
- Update to 0.428
  - Fix build fails on perl ≥ 5.27.4 with -DDEBUGGING (CPAN RT#123613)
  - Update ppport.h to 3.37 for improved blead support
  - Fix context arg to croak() (CPAN RT#123869)
  - Fix one() returning true on empty list (CPAN RT#123870)
  - Pamper $a/$b/$_ refcounting bugs (CPAN RT#123868)

* Tue Oct  3 2017 Paul Howarth <paul@city-fan.org> - 0.426-1
- Update to 0.426
  - Fix broken format in part (GH#4)
  - Fix gcc 4.7 sequence point warning (GH#5)
  - Fix incorrect padname resolving for perl > 5.21.6 (CPAN RT#122883)
  - Fix compiling issue on CentOS 4 and CentOS 5

* Sat Aug 19 2017 Paul Howarth <paul@city-fan.org> - 0.423-1
- Update to 0.423
  - Fix dealing with lists with one element on bremove/binsert (GH#2)
  - Add support for compilers before C99
  - Fix some 32-bit compiler warnings
  - Add support for compilers without statement expression feature

* Tue Aug 15 2017 Paul Howarth <paul@city-fan.org> - 0.422-1
- Update to 0.422
  - Rename 'occurances' into 'occurrences' (CPAN RT#91991, CPAN RT#122806)
  - Add DESCRIPTION to Pod clarifying the role of List::MoreUtils::XS
  - Improve Makefile.PL regarding some build artifacts

* Tue Aug 15 2017 Paul Howarth <paul@city-fan.org> - 0.421-1
- Update to 0.421
  - Fix a lot of potential memory leaks when callbacks throw exceptions
  - Add some new functions: qsort, binsert, bremove, listcmp, arrayify
    (CPAN RT#17230), samples (CPAN RT#77562), minmaxstr (CPAN RT#106401),
    lower_bound, upper_bound, equal_range, frequencies, occurances, mode
    (CPAN RT#91991), zip6 (CPAN RT#42921), reduce_0, reduce_1, reduce_u
  - Improve tests
  - Make List::MoreUtils::XS independent from List::MoreUtils
    Note that List::MoreUtils::XS doesn't guarantee API stability: this
    feature is only provided through List::MoreUtils as frontend
  - Improve configure toolchain to use Config::AutoConf 0.315
  - Speed up some inner loops by hinting the expected result
  - Fix mind screwed up issue in upper_bound and reduce elements visited in
    equal_range
  - Correct license in META (CPAN RT#122702)
  - Fix issues with -DPERL_IMPLICIT_SYS on Windows with Strawberry-Perl

* Mon Aug  7 2017 Paul Howarth <paul@city-fan.org> - 0.418-6
- BR: perl-generators unconditionally
- BR: perl-interpreter rather than perl

* Wed Jun 14 2017 Paul Howarth <paul@city-fan.org> - 0.418-4
- Drop support for EOL distributions prior to F-13
  - Drop BuildRoot: and Group: tags
  - Drop explicit buildroot cleaning in %%install section
  - Drop explicit %%clean section

* Thu Mar 30 2017 Paul Howarth <paul@city-fan.org> - 0.418-1
- Initial RPM version