File hiredis.spec of Package hiredis
%define realname hiredis
%define realver 1.2.0
%define srcext tar.gz
%bcond_without ninja
%define so_ver 1
%undefine so_subver
# turn off the generation of debuginfo rpm (RH9) ??
%global debug_package %{nil}
# Common info
Name: libhiredis%{?so_ver}%{?so_subver:_%{so_subver}}
Version: %{realver}
Release: wiz%{?extraver:0.}1%{?dist}
License: BSD-3-Clause
Group: Productivity/Databases/Clients
URL: https://github.com/redis/hiredis
Summary: Minimalistic C client for Redis >= 1.2
# Install-time parameters
Provides: hiredis = %{version}-%{release}
Provides: libhiredis_ssl%{?so_ver} = %{version}-%{release}
# Build-time parameters
BuildRequires: cmake >= 3.0.0
%if %{with ninja}
BuildRequires: ninja
%endif
BuildRequires: openssl-devel
Source: https://codeload.github.com/redis/hiredis/%{srcext}/refs/tags/v%{realver}#/%{realname}-%{version}%{?extraver}.%{srcext}
%description
Hiredis is a minimalistic C client library for the [Redis](http://redis.io/) database.
It is minimalistic because it just adds minimal support for the protocol, but
at the same time it uses an high level printf-alike API in order to make it
much higher level than otherwise suggested by its minimal code base and the
lack of explicit bindings for every Redis command.
%package -n %{realname}-devel
Group: Development/Languages/C and C++
Summary: Development files for %{name}
Requires: %{name} = %{version}-%{release}
Provides: libhiredis-devel = %{version}-%{release}
Provides: libhiredis%{?so_ver}%{?so_subver:_%{so_subver}}-devel = %{version}-%{release}
Provides: libhiredis_ssl%{?so_ver}%{?so_subver:_%{so_subver}}-devel = %{version}-%{release}
%description -n %{realname}-devel
Development files for %{name}
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver}
%build
TOP_DIR=$(pwd -P)
_CFLAGS="%{optflags} %{?gcc_lto}"
_LDFLAGS="-Wl,--as-needed -Wl,--strip-all -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}"
_CMAKE_ARGS=(
%if %{with ninja}
-G Ninja \
%endif
-DCMAKE_INSTALL_PREFIX=%{_prefix}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_C_FLAGS_RELEASE="$_CFLAGS"
-DCMAKE_EXE_LINKER_FLAGS_RELEASE="$_LDFLAGS"
-DCMAKE_MODULE_LINKER_FLAGS_RELEASE="$_LDFLAGS"
-DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$_LDFLAGS"
-DCMAKE_VERBOSE_MAKEFILE=YES
)
cmake -S . -B build \
"${_CMAKE_ARGS[@]}" \
-DENABLE_SSL=YES \
-DDISABLE_TESTS=YES
%if %{with ninja}
ninja -v -C build %{?_smp_mflags}
%else
%{__make} -C build %{?_smp_mflags}
%endif
%install
%if %{with ninja}
DESTDIR=%{buildroot} ninja -v -C build install
%else
%{__make} -C build install DESTDIR=%{buildroot}
%endif
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%files
%defattr(-,root,root)
%license COPYING
%doc CHANGELOG.md README.md
%{_libdir}/*.so.%{?so_ver}*
# Development stuff
%files -n %{realname}-devel
%defattr(-,root,root)
%dir %{_includedir}/hiredis/adapters
%dir %{_includedir}/hiredis
%{_includedir}/hiredis/adapters/*.h
%{_includedir}/hiredis/*.h
%{_libdir}/*.so
%{_libdir}/pkgconfig/hiredis.pc
%{_libdir}/pkgconfig/hiredis_ssl.pc
%dir %{_libdir}/cmake
%{_libdir}/cmake/hiredis/
%{_libdir}/cmake/hiredis_ssl/
%exclude %{_prefix}/build/native/hiredis.targets
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%changelog