57e36b2
%global miniz_revision r4
57e36b2
57e36b2
Name:       miniz
57e36b2
Version:    1.15
944b2a3
Release:    2.%{miniz_revision}%{?dist}
57e36b2
Summary:    Compression library implementing the zlib and Deflate
57e36b2
Group:      System Environment/Libraries
57e36b2
License:    Unlicense
57e36b2
URL:        https://code.google.com/p/%{name}/
57e36b2
Source0:    https://%{name}.googlecode.com/files/%{name}_v%(echo '%{version}' | tr -d .)_%{miniz_revision}.7z
944b2a3
BuildRequires:  coreutils
944b2a3
BuildRequires:  findutils
944b2a3
BuildRequires:  gcc
944b2a3
BuildRequires:  gcc-c++
57e36b2
BuildRequires:  p7zip
944b2a3
BuildRequires:  sed
57e36b2
57e36b2
%description
57e36b2
Miniz is a lossless, high performance data compression library in a single
57e36b2
source file that implements the zlib (RFC 1950) and Deflate (RFC 1951)
57e36b2
compressed data format specification standards. It supports the most commonly
57e36b2
used functions exported by the zlib library, but is a completely independent
57e36b2
implementation so zlib's licensing requirements do not apply. It also
57e36b2
contains simple to use functions for writing PNG format image files and
57e36b2
reading/writing/appending ZIP format archives. Miniz's compression speed has
57e36b2
been tuned to be comparable to zlib's, and it also has a specialized real-time
57e36b2
compressor function designed to compare well against fastlz/minilzo.
57e36b2
57e36b2
%package devel
57e36b2
Group:      Development/Libraries
57e36b2
Summary:    Development files for the %{name} library
57e36b2
Requires:   %{name}%{?_isa} = %{version}-%{release}
944b2a3
Requires:   gcc%{?_isa}
57e36b2
57e36b2
%description devel
57e36b2
Header files for developing applications that use the %{name} library.
57e36b2
57e36b2
57e36b2
%prep
57e36b2
%setup -c -T -n %{name}-%{version}_%{miniz_revision}
57e36b2
7za e '%{SOURCE0}'
57e36b2
# Remove prebuilt executables
57e36b2
find -name '*.exe' -exec rm -- {} +
57e36b2
# Extract a header file
57e36b2
sed -e '/End of Header/q' < %{name}.c > %{name}.h
57e36b2
# Prepare test for linking against the library
57e36b2
sed -i -e 's/#include "miniz.c"/#include <miniz.h>/' miniz_tester.cpp
57e36b2
57e36b2
%global soname lib%{name}.so.0.1
57e36b2
57e36b2
%build
57e36b2
# Upstream CMakeLists.txt does not produce a library, build it.
57e36b2
# Inject downstream SONAME, bug #1152653
57e36b2
gcc %{optflags} -fPIC -DPIC -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 \
57e36b2
    -fno-strict-aliasing %{name}.c -c -o %{name}.o
57e36b2
gcc %{?__global_ldflags} -fPIC -shared -Wl,-soname,%{soname} \
02c2e02
    %{name}.o -o %{soname}
57e36b2
ln -s %{soname} lib%{name}.so
57e36b2
# Build test against the library
57e36b2
g++ %{optflags} -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 \
57e36b2
    -I. miniz_tester.cpp -c -o miniz_tester.o
57e36b2
g++ %{optflags} -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 \
57e36b2
    -I. timer.cpp -c -o timer.o
57e36b2
g++ %{?__global_ldflags} -L. -l%{name} miniz_tester.o timer.o -o miniz_tester
57e36b2
57e36b2
%check
57e36b2
LD_LIBRARY_PATH=$PWD ./miniz_tester
57e36b2
57e36b2
%install
57e36b2
install -d '%{buildroot}/%{_libdir}'
57e36b2
install %{soname} '%{buildroot}/%{_libdir}'
57e36b2
ln -s %{soname} '%{buildroot}/%{_libdir}/lib%{name}.so'
57e36b2
install -d '%{buildroot}/%{_includedir}'
57e36b2
install -m 0644 %{name}.h '%{buildroot}/%{_includedir}'
57e36b2
57e36b2
%post -p /sbin/ldconfig
57e36b2
57e36b2
%postun -p /sbin/ldconfig
57e36b2
57e36b2
%files
57e36b2
%{_libdir}/%{soname}
57e36b2
57e36b2
%files devel
57e36b2
%{_includedir}/%{name}.h
57e36b2
%{_libdir}/lib%{name}.so
57e36b2
57e36b2
57e36b2
%changelog
944b2a3
* Tue Mar 08 2016 Petr Pisar <ppisar@redhat.com> - 1.15-2.r4
944b2a3
- Correct dependency on libc headers
944b2a3
57e36b2
* Tue Oct 14 2014 Petr Pisar <ppisar@redhat.com> - 1.15-1.r4
57e36b2
- 1.15r4 version packaged
57e36b2
57e36b2