File nghttp2.spec of Package nghttp2
%define realname nghttp2
%define realver 1.64.0
%define srcext tar.gz
%define lib_so_ver 14
# turn off the generation of debuginfo rpm (RH9) ??
%global debug_package %{nil}
# Common info
Name: lib%{realname}%{?lib_so_ver:-%{lib_so_ver}}
Version: %{realver}
Release: wiz%{?extraver:0.}1%{?dist}
License: MIT
Group: System/Libraries
URL: https://nghttp2.org/
Summary: HTTP/2 C Library
# Install-time parameters
Provides: lib%{realname} = %{version}-%{release}
Provides: %{realname} = %{version}-%{release}
# Build-time parameters
BuildRequires: gcc-c++
BuildRequires: cmake >= 3.14 ninja
BuildRequires: python3%{?suse_version:-base}
BuildRequires: pkg-config
BuildRequires: pkgconfig(libcares) >= 1.7.5
BuildRequires: pkgconfig(zlib) >= 1.2.3
BuildRequires: pkgconfig(libbrotlienc) >= 1.0.9
BuildRequires: pkgconfig(libbrotlidec) >= 1.0.9
BuildRequires: pkgconfig(openssl) >= 1.1.1
BuildRequires: systemd-devel >= 209
BuildRequires: pkgconfig(jansson) >= 2.5
BuildRequires: pkgconfig(libevent) >= 2.0.8
BuildRequires: pkgconfig(libxml-2.0) >= 2.6.26
BuildRequires: pkgconfig(jemalloc)
Source: https://codeload.github.com/nghttp2/nghttp2/%{srcext}/refs/tags/v%{realver}#/%{realname}-%{realver}%{?extraver}.%{srcext}
%description
nghttp2 is an implementation of HTTP/2 and its header compression algorithm
HPACK in C.
The framing layer of HTTP/2 is implemented as a form of reusable C library. On
top of that, we have implemented HTTP/2 client, server and proxy.
%package -n lib%{realname}-devel
Group: Development/Languages/C and C++
Summary: Development files for %{name}
Requires: %{name} = %{version}-%{release}
Provides: %{name}-devel = %{version}-%{release}
Provides: %{realname}-devel = %{version}-%{release}
%description -n lib%{realname}-devel
Development files for %{name}
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}
%build
_CFLAGS='%{optflags} %{?gcc_lto}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
_CMAKE_ARGS=(
-G Ninja \
-Wno-dev
-DCMAKE_INSTALL_PREFIX=%{_prefix}
-DCMAKE_INSTALL_SYSCONFDIR=%{_sysconfdir}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_CXX_FLAGS_RELEASE="$_CFLAGS"
-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 tmp_build \
"${_CMAKE_ARGS[@]}" \
\
-DENABLE_APP=NO \
-DENABLE_HPACK_TOOLS=NO \
-DENABLE_EXAMPLES=NO \
-DWITH_LIBXML2=YES \
-DWITH_JEMALLOC=YES
ninja -v -C tmp_build %{?_smp_mflags}
%install
DESTDIR=%{buildroot} ninja -v -C tmp_build install
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}%{_datadir}/doc
# Fix shebang
%{__sed} -ri '1 s|#!.*python\d?$|#!%{_bindir}/python3|' %{buildroot}%{_datadir}/%{realname}/fetch-ocsp-response
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%files
%defattr(-,root,root)
%license COPYING
%doc AUTHORS README README.rst
%{_libdir}/lib%{realname}.so.%{?lib_so_ver}*
%dir %{_datadir}/%{realname}/
%{_datadir}/%{realname}/fetch-ocsp-response
%exclude %{_mandir}/man1/*
# Development stuff
%files -n lib%{realname}-devel
%defattr(-,root,root)
%{_libdir}/pkgconfig/lib%{realname}.pc
%dir %{_libdir}/cmake/%{realname}
%dir %{_libdir}/cmake
%{_libdir}/cmake/%{realname}/*.cmake
%dir %{_includedir}/%{realname}/
%{_includedir}/%{realname}/*.h
%{_libdir}/lib%{realname}.so
%exclude %{_libdir}/*.la
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%changelog