Name:           blosc
Version:        1.21.5
Release:        1
Summary:        Binary compressor
License:        MIT
URL:            https://github.com/Blosc/c-blosc
Source:         https://github.com/Blosc/c-blosc/archive/v%{version}/blosc-%{version}.tar.gz

BuildRequires:  cmake lz4-devel snappy-devel zlib-devel libzstd-devel gcc-g++

%description
Blosc is a compression library that is faster than traditional compression.

%package        devel
Summary:        Header files and libraries for Blosc development
Requires:       %{name} = %{version}-%{release}

%description    devel
The blosc-devel package contains the header files and libraries needed
to develop programs that use the blosc meta-compressor.

%package        bench
Summary:        Benchmark for the Blosc compressor
Requires:       %{name} = %{version}-%{release}
Requires:       python3-matplotlib

%description    bench
The blosc-bench package contains a benchmark suite which evaluates
the performance of Blosc, and compares it with memcpy.

%prep
%autosetup -n c-%{name}-%{version} -p1
rm -r internal-complibs/lz4* internal-complibs/zstd*

#rm -r internal-complibs/snappy* internal-complibs/zlib*
sed -i '1i  set\(CMAKE_SKIP_RPATH true\)' bench/CMakeLists.txt
sed -i '1i  set\(CMAKE_POSITION_INDEPENDENT_CODE TRUE\)' CMakeLists.txt
sed -i 's|lib/pkgconfig|%{_lib}/pkgconfig|' CMakeLists.txt
sed -i '1i  #!/usr/bin/python3' bench/plot-speeds.py

%build
%cmake \
%ifarch x86_64
    %{?_cmake_lib_suffix64} \
%endif
    -DCMAKE_BUILD_TYPE:STRING="Debug" \
    -DCMAKE_C_FLAGS:STRING="%{optflags}" \
    -DCMAKE_INSTALL_PREFIX=%{_prefix} \
    -DBUILD_STATIC:BOOL=OFF \
    -DPREFER_EXTERNAL_LZ4:BOOL=ON \
    -DTEST_INCLUDE_BENCH_SUITE:BOOL=OFF \
    -DPREFER_EXTERNAL_SNAPPY:BOOL=ON \
    -DPREFER_EXTERNAL_ZLIB:BOOL=ON \
    -DPREFER_EXTERNAL_ZSTD:BOOL=ON \
    .
%make_build

%check
LD_LIBRARY_PATH=%{buildroot}%{_libdir} make test VERBOSE=1

%install
%make_install

install -p bench/plot-speeds.py* -Dt %{buildroot}/%{_pkgdocdir}/bench/
install -pm 0644 bench/*.c %{buildroot}/%{_pkgdocdir}/bench

install -p bench/bench -D %{buildroot}/%{_bindir}/%{name}-bench
install -p bench/plot-speeds.py %{buildroot}/%{_bindir}/%{name}-plot-times

%files
%exclude %{_pkgdocdir}/bench/
%license LICENSES/*
%{_libdir}/libblosc.so.1*
%doc README.md ANNOUNCE.rst RELEASE_NOTES.rst README_CHUNK_FORMAT.rst 
%doc README_THREADED.rst COMPILING_WITH_WHEELS.rst CONTRIBUTING.md code_of_conduct.md

%files devel
%{_libdir}/libblosc.so
%{_libdir}/pkgconfig/blosc.pc
%{_includedir}/blosc.h
%{_includedir}/blosc-export.h

%files bench
%{_pkgdocdir}/bench/*.c
%{_bindir}/%{name}-bench
%{_bindir}/%{name}-plot-times

%changelog
* Wed Sep 27 2023 yaoxin <yao_xin001@hoperun.com> - 1.21.5-1
- Upgrade to 1.21.5

* Fri Jul 09 2021 xuguangmin <xuguangmin@kylinos.cn> - 1.21.0-1
- Update version to 1.21.0

* Mon May 31 2021 baizhonggui <baizhonggui@huawei.com> - 1.14.4-4
- Fix building error: No CMAKE_CXX_COMPULER could be found
- Add gcc-g++ in BuildRequires

* Thu Nov 14 2019 wangye<wangye54@huawei.com> - 1.14.4-3
- Update
* Thu Nov 14 2019 wangye<wangye54@huawei.com> - 1.14.4-2
- Package init
