## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

Name:           blosc2
Version:        2.15.1
Release:        %autorelease
Summary:        High performance compressor optimized for binary data

License:        BSD-3-Clause
URL:            https://www.blosc.org/
Source:         https://github.com/Blosc/c-blosc2/archive/v%{version}/c-blosc2-%{version}.tar.gz

BuildRequires:  cmake
BuildRequires:  gcc
BuildRequires:  ninja-build
BuildRequires:  lz4-devel
BuildRequires:  zlib-devel
BuildRequires:  zlib-ng-devel
BuildRequires:  libzstd-devel
BuildRequires:  xxhash-devel

%description
Blosc is a high performance compressor optimized for binary data
(i.e. floating-point numbers, integers, and booleans, although it can handle
string data too). It has been designed to transmit data to the processor cache
faster than the traditional, non-compressed, direct memory fetch approach via a
memcpy() OS call. Blosc main goal is not just to reduce the size of large
datasets on-disk or in-memory, but also to accelerate memory-bound computations.

C-Blosc2 is the new major version of C-Blosc, and is backward compatible with
both the C-Blosc1 API and its in-memory format. However, the reverse thing is
generally not true for the format; buffers generated with C-Blosc2 are not
format-compatible with C-Blosc1.

%package devel
Summary:        Development headers for %{name}
Requires:       %{name}%{_isa} = %{version}-%{release}

%description devel
%{summary}.

%prep
%autosetup -n c-blosc2-%{version} -p1

# https://github.com/Blosc/c-blosc2/issues/489
rm plugins/codecs/ndlz/xxhash.?
sed -r -i '/xxhash.c/d' plugins/codecs/ndlz/CMakeLists.txt

# let's do this to make it clear that we're not using those
rm -r internal-complibs/* internal-complibs

%build
OPTIONS=(
        -GNinja
        -DBUILD_STATIC:BOOL=OFF
        -DBUILD_FUZZERS:BOOL=OFF
        -DPREFER_EXTERNAL_LZ4:BOOL=ON
        -DPREFER_EXTERNAL_ZLIB:BOOL=ON
        -DPREFER_EXTERNAL_ZSTD:BOOL=ON
        -DDEACTIVATE_AVX2:BOOL=ON

        # We need to pass the distro build flags here, otherwise they are ignored.
        # Silence warnings about stupid programming errors.
        -DCMAKE_C_FLAGS:STRING="$CFLAGS -Wno-unused-variable"
        )

%cmake "${OPTIONS[@]}"
%cmake_build

%install
%cmake_install

%check
# Tests fail on s390x: https://github.com/Blosc/c-blosc2/issues/467
%ifarch s390x
%global ignore_result || :
%endif

# Tests fail with -j12: https://github.com/Blosc/c-blosc2/issues/432
%ctest -j1 %{?ignore_result}

%files
# API versioning hard. With CMake even harder.
# SONAME is "libblosc2.so.3". Let's use a literal pattern
# here to see what upstream does in the next version.
%{_libdir}/libblosc2.so.4
%{_libdir}/libblosc2.so.2.15.1
%license LICENSE.txt
%doc ROADMAP.rst
%doc ANNOUNCE.*
%doc THANKS.*
%doc RELEASE_NOTES.*
%doc README*
%doc FAQ.*

%files devel
%dir %{_includedir}/%{name}
%{_includedir}/b2nd.h
%{_includedir}/blosc2.h
%{_includedir}/blosc2/*.h
%{_libdir}/libblosc2.so
%{_libdir}/pkgconfig/blosc2.pc
%{_libdir}/cmake/Blosc2

%changelog
## START: Generated by rpmautospec
* Wed Aug 21 2024 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.15.1-1
- Version 2.15.1 (rhbz#2293517)

* Wed Jul 17 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2.14.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Sun Apr 21 2024 Packit <hello@packit.dev> - 2.14.4-1
- Update to 2.14.4 upstream release
- Resolves: rhbz#2273551
- SO version is changed to '3'

* Mon Apr 01 2024 Packit <hello@packit.dev> - 2.14.0-1
- [packit] 2.14.0 upstream release
- Resolves: rhbz#2272484

* Thu Feb 08 2024 Packit <hello@packit.dev> - 2.13.2-1
- [packit] 2.13.2 upstream release
- Resolves rhbz#2263279

* Fri Jan 26 2024 Packit <hello@packit.dev> - 2.13.1-1
- [packit] 2.13.1 upstream release
- Resolves rhbz#2256143

* Tue Jan 23 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2.11.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jan 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2.11.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Sun Dec 17 2023 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.11.3-1
- Version 2.11.3 (rhbz#2252346)

* Wed Nov 29 2023 Laura Barcziova <lbarczio@redhat.com> - 2.11.2-3
- [Packit config] move upstream_tag_template definition globally

* Tue Nov 21 2023 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.11.2-2
- Hopefully fix compilation on ppc64el

* Tue Nov 21 2023 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.11.2-1
- Version 2.11.2 (rhbz#2239080)

* Mon Nov 20 2023 topazus <topazus@outlook.com> - 2.10.5-3
- disable the building of static library

* Wed Oct 25 2023 Packit <hello@packit.dev> - 2.10.5-1
- [packit] 2.10.5 upstream release

* Wed Oct 25 2023 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.10.1-3
- Add packit config

* Sun Aug 06 2023 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.10.1-1
- Version 2.10.1 (rhbz#2228597)

* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.10.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Sun Jul 16 2023 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.10.0-1
- Version 2.10.0

* Mon May 15 2023 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.9.1-5
- Ignore test results on s390x

* Mon May 15 2023 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.9.1-3
- Add patch to fix build of pytables

* Mon May 15 2023 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.9.1-2
- Fixes after review

* Sat May 13 2023 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.9.1-1
- First version
## END: Generated by rpmautospec