#
# spec file for package libdeflate
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define major 0
%define libname %{name}%{major}
Name:           libdeflate
Version:        1.21
Release:        1.1
Summary:        Library for DEFLATE/zlib/gzip compression and decompression
License:        BSD-2-Clause
URL:            https://github.com/ebiggers/libdeflate
Source:         https://github.com/ebiggers/libdeflate/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        baselibs.conf
BuildRequires:  cmake
BuildRequires:  zlib-devel

%description
libdeflate is a library for whole-buffer DEFLATE-based compression
and decompression. It supports raw, zlib-wrapped and gzip-wrapped DEFLATE.
It is significantly faster than zlib and gzip (+72-187%%).
In addition, libdeflate provides optional high compression modes
above zlib's "level 9".

%package -n    %{libname}
Summary:        Library for DEFLATE/zlib/gzip compression and decompression

%description -n    %{libname}
libdeflate is a library for whole-buffer DEFLATE-based compression
and decompression. It supports raw, zlib-wrapped and gzip-wrapped DEFLATE.
It is significantly faster than the zlib library:

 - decompression speedup over gzip-1.10 is 2.28x (generic), 2.87x (AVX2)
 - compression speedup over gzip is 1.72x (generic), 2.23x (AVX2)

In addition, libdeflate provides optional high compression modes
above zlib's "level 9".

%package tools
Summary:        File compression utility

%description tools
A gzip implementation that uses libdeflate which is significantly
faster than the GNU gzip implementation (+72-187%%).

%package devel
Summary:        Development files for %{name}
Requires:       %{libname} = %{version}

%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

%prep
%autosetup -p1

%build
%cmake \
  -DLIBDEFLATE_BUILD_STATIC_LIB=OFF \
  -DLIBDEFLATE_BUILD_TESTS=ON
%cmake_build

%install
%cmake_install

# Delete libdeflate-gunzip and replace with symlink libdeflate-gzip to fix dwz break with hardlink.
# boo#1180984
rm %{buildroot}%{_bindir}/libdeflate-gunzip
ln -s ./libdeflate-gzip %{buildroot}%{_bindir}/libdeflate-gunzip

%check
%ctest

%post -n %{libname} -p /sbin/ldconfig
%postun -n %{libname} -p /sbin/ldconfig

%files tools
%{_bindir}/libdeflate-gzip
%{_bindir}/libdeflate-gunzip

%files -n %{libname}
%{_libdir}/libdeflate.so.%{major}

%files devel
%license COPYING
%doc README.md
%{_includedir}/libdeflate.h
%{_libdir}/libdeflate.so
%{_libdir}/cmake/libdeflate
%{_libdir}/pkgconfig/libdeflate.pc

%changelog
* Sun Aug 18 2024 Dirk Müller <dmueller@suse.com>
- update to 1.21:
  * Fixed build error on x86 with gcc 8.1 and gcc 8.2.
  * Fixed build error on x86 when gcc 11 is paired with a
    binutils version that doesn't support AVX-VNNI
    e.g. as it is on RHEL 9.
  * Fixed build error on arm64 with gcc 6.
  * Fixed build error on arm64 with gcc 13.1 and later with some
  - mcpu options.
  * Enabled detection of dotprod support in Windows ARM64 builds.
* Wed Apr  3 2024 Dirk Müller <dmueller@suse.com>
- update to 1.20:
  * Improved CRC-32 performance on recent x86 CPUs by adding
  * VPCLMULQDQ-accelerated implementations using 256-bit and
    512-bit vectors.
  * Improved Adler-32 performance on recent x86 CPUs by adding
  * VNNI-accelerated implementations using 256-bit and 512-bit
    vectors.
  * Improved CRC-32 and Adler-32 performance on short inputs.
  * Optimized the portable implementation of Adler-32.
  * Added some basic optimizations for RISC-V.
  * Dropped support for gcc versions older than v4.9 (released in
    2014) and clang versions older than v3.9 (released in 2016).
  * Dropped support for CRC-32 acceleration on 32-bit ARM using
    the ARMv8 pmull or crc32 instructions.
* Mon Feb 12 2024 pgajdos@suse.com
- baselibs for tools and devel reportedly not needed
- modified sources
  %% baselibs.conf
* Thu Feb  8 2024 pgajdos@suse.com
- introduce baselibs.conf for openexr
  https://build.opensuse.org/request/show/1144873
- added sources
  + baselibs.conf
* Sun Sep 17 2023 Dirk Müller <dmueller@suse.com>
- update to 1.19:
  * Added new functions `libdeflate_alloc_compressor_ex()` and
    `libdeflate_alloc_decompressor_ex()`.  These functions allow
    specifying a custom memory allocator on a per-compressor basis.
  * libdeflate now always generates Huffman codes with at least 2
    codewords. This fixes a compatibility issue where Windows
    Explorer's ZIP unpacker could not decompress DEFLATE streams
    created by libdeflate.  libdeflate's behavior was
  * allowed by the DEFLATE RFC, but not all software was okay
    with it.  In rare cases, compression ratios can be slightly
    reduced by this change.
  * Disabled the use of some compiler intrinsics on MSVC versions
    where they don't work correctly.
  * libdeflate can now compress up to the exact size of the
    output buffer.
  * Slightly improved compression performance at levels 1-9.
  * Improved the compression ratio of very short inputs.
* Thu Apr 27 2023 Dirk Müller <dmueller@suse.com>
- update to 1.18:
  * Fixed a bug where the build type didn't default to "Release"
    when using CMake 3.10 or earlier.
  * Fixed a bug where some optimized code wasn't used when
    building with Clang 15 or later (x86), or with Clang 16
    or later (aarch64).
  * Fixed build errors with some architecture and compiler
    combos:
  * aarch64 with Clang 16
  * armv6kz or armv7e-m with gcc
  * armhf with gcc (on Debian only)
* Tue Jan 24 2023 Paolo Stivanin <info@paolostivanin.com>
- update to 1.17:
  * Improved the compression ratio at levels 10-12 slightly, mainly
    levels 11-12. Some inputs (such as certain PNG files) see much
    improved compression ratios. As a trade-off, compressing at
    levels 11-12 is now about 5-20%% slower.
  * For consistency with zlib, the decompressor now returns an error
    on some invalid inputs that were accepted before.
  * Fixed a build error on arm64 with gcc with certain target CPUs.
  * Fixed a build error in programs/gzip.c with uClibc.
* Thu Dec 29 2022 Dirk Müller <dmueller@suse.com>
- update to 1.15:
  * libdeflate now uses CMake instead of a plain Makefile.
* Mon Oct  3 2022 Dirk Müller <dmueller@suse.com>
- update to 1.14:
  Significantly improved decompression performance on all platforms.  Examples
  include (measuring DEFLATE only):
  | Platform                           | Speedup over v1.13 |
  |------------------------------------|--------------------|
  | x86_64 (Intel Comet Lake), gcc     | 1.287x             |
* Mon Aug  8 2022 Dirk Müller <dmueller@suse.com>
- update to 1.13:
  * Changed the 32-bit Windows build of the library to use the default calling
    convention (cdecl) instead of stdcall, reverting a change from libdeflate 1.4.
  * Fixed a couple macOS compatibility issues with the gzip program.
* Tue Jul 12 2022 Dirk Müller <dmueller@suse.com>
- update to 1.12:
  * Improved CRC-32 performance on short inputs on x86 and ARM.
  * Improved CRC-32 performance on Apple Silicon Macs by using a 12-way pmull
    implementation.   Performance on large inputs on M1 is now about 67 GB/s,
    compared to 8 GB/s before, or 31 GB/s with the Apple-provided zlib.
  * Improved CRC-32 performance on some other ARM CPUs by reworking the code so
    that multiple crc32 instructions can be issued in parallel.
  * Improved CRC-32 performance on some x86 CPUs by increasing the stride length
    of the pclmul implementation.
  * Improved Adler-32 performance on some x86 CPUs by optimizing the AVX-2
    implementation.  E.g., performance on Zen 1 improved from 19 to 30 GB/s, and
    on Ice Lake from 35 to 41 GB/s (if the AVX-512 implementation is excluded).
  * Removed the AVX-512 implementation of Adler-32 to avoid CPU frequency
    downclocking, and because the AVX-2 implementation was made faster.
  * Improved Adler-32 performance on some ARM CPUs by optimizing the NEON
  * Improved compression performance slightly.
  * Detect arm64 CPU features on Apple platforms, which should improve
    performance in some areas such as CRC-32 computation.
  * The included `gzip` and `gunzip` programs now support the `-q` option.
  * The included `gunzip` program now passes through non-gzip data when both
    the `-f` and `-c` options are used.
* Mon Feb 14 2022 Dirk Müller <dmueller@suse.com>
- update to 1.10:
  * Added an additional check to the decompressor to make it quickly detect
    certain bad inputs and not try to generate an unbounded amount of output.
  * Cleaned up a few things in the compression code.
* Mon Jan 24 2022 Dirk Müller <dmueller@suse.com>
- update to 1.9:
  * Heuristics were implemented which significantly improve the compression
    ratio on data where short matches aren't useful, such as DNA sequencing
    data.  This applies to all compression levels, but primarily to levels 1-9.
  * Levels 1 was made much faster, though it often compresses slightly worse
    than before (but still better than zlib).
  * Levels 8-9 were also made faster, though they often compress slightly worse
    than before (but still better than zlib).  On some data, levels 8-9 are much
    faster and compress much better than before; this change addressed an issue
    where levels 8-9 did poorly on certain files.  The algorithm used by levels
    8-9 is now more similar to that of levels 6-7 than to that of levels 10-12.
  * Levels 2-3, 7, and 10-12 were strengthened slightly.
  * Levels 4-6 were also strengthened slightly, but some of this improvement was
    traded off to speed them up slightly as well.
  * Levels 1-9 had their per-compressor memory usage greatly reduced.
  * `make install` will now install a pkg-config file for libdeflate.
  * The Makefile now supports the `DISABLE_SHARED` parameter to disable building
    the shared library.
* Tue Jan  4 2022 Dirk Müller <dmueller@suse.com>
- update to 1.8:
  * Added `-t` (test) option to `libdeflate-gunzip`.
  * Unaligned access optimizations are now enabled on WebAssembly builds.
  * Fixed a build error when building with the Intel C Compiler (ICC).
  * Fixed a build error when building with uClibc.
  * libdeflate's CI system has switched from Travis CI to GitHub Actions.
  * Made some improvements to test scripts.
* Wed Jan 13 2021 andy great <andythe_great@pm.me>
- Add workaround build fail due issue in dwz by deleting
  libdeflate-gunzip and replace with symlink libdeflate-gzip to
  fix dwz break with hardlink.
  boo#1180984
* Wed Jan 13 2021 Jan Engelhardt <jengelh@inai.de>
- Quantify the description's supposed "fast" claims
- Adhere to shared library packaging guide and split tools off
  into subpackage.
* Wed Jan 13 2021 andy great <andythe_great@pm.me>
- Initial package release.