## START: Set by rpmautospec
## (rpmautospec version 0.7.2)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

Name:           ngtcp2
Version:        1.8.1
Release:        %autorelease
Summary:        ngtcp2 project is an effort to implement RFC9000 QUIC protocol

License:        MIT
URL:            https://github.com/ngtcp2/ngtcp2
Source0:        %{url}/archive/v%{version}/%{name}-%{version}.tar.gz

BuildRequires:  autoconf
BuildRequires:  gcc
BuildRequires:  make
BuildRequires:  libtool
BuildRequires:  gnutls-devel
%if 0%{?rhel} == 8
BuildRequires: cmake cmake3 git
BuildRequires: gcc-toolset-13
%endif
%if 0%{?rhel} == 7
BuildRequires: cmake cmake3 git
BuildRequires: devtoolset-12-gcc-c++ devtoolset-12-make
%endif

%description
"Call it TCP/2. One More Time."

ngtcp2 project is an effort to implement RFC9000 QUIC protocol.

%package devel
Summary:        ngtcp2 development files
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description devel
"Call it TCP/2. One More Time."

ngtcp2 project is an effort to implement RFC9000 QUIC protocol.

Development headers and libraries.

%prep
%if 0%{?rhel} == 8
scl enable gcc-toolset-13 -- bash
source /opt/rh/gcc-toolset-13/enable
%endif
%if 0%{?rhel} == 7
#cd /opt/rh/gcc-toolset-13/root/usr/lib/gcc/%{_arch}-redhat-linux/12/plugin
#ln -s annobin.so gcc-annobin.so
scl enable devtoolset-12 -- bash
source /opt/rh/devtoolset-12/enable
%endif
%if 0%{?rhel} == 8 || 0%{?rhel} == 7
cd /tmp
git clone --depth 1 -b v4.0.0 https://github.com/libressl/portable.git libressl
cd libressl
./autogen.sh
./configure --prefix=$PWD/build
make -j$(nproc) install
%endif
%autosetup


%build
%if 0%{?rhel} == 8
scl enable gcc-toolset-13 -- bash
source /opt/rh/gcc-toolset-13/enable
%endif
%if 0%{?rhel} == 7
scl enable devtoolset-12 -- bash
source /opt/rh/devtoolset-12/enable
%endif
autoreconf -fsi
%if 0%{?rhel} == 8 || 0%{?rhel} == 7
%configure --disable-static --enable-werror  PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/tmp/libressl/build/lib/pkgconfig
%else
%configure --with-gnutls --disable-static --enable-werror
%endif
%make_build


%install
%make_install

# Blow away libtool archives
find %{buildroot}%{_libdir}/ -name '*.la' -delete


%files
%license COPYING
%doc README.rst
%doc SECURITY.md
%doc AUTHORS
%{_libdir}/libngtcp2.so.16*
%if 0%{?rhel} == 8 || 0%{?rhel} == 7
%{_libdir}/libngtcp2_crypto_quictls.so.2*
%else
%{_libdir}/libngtcp2_crypto_gnutls.so.8*
%endif

%files devel
%{_libdir}/libngtcp2.so
%{_libdir}/pkgconfig/libngtcp2.pc
%if 0%{?rhel} == 8 || 0%{?rhel} == 7
%{_libdir}/libngtcp2_crypto_quictls.so
%{_libdir}/pkgconfig/libngtcp2_crypto_quictls.pc
%else
%{_libdir}/libngtcp2_crypto_gnutls.so
%{_libdir}/pkgconfig/libngtcp2_crypto_gnutls.pc
%endif
%{_includedir}/%{name}/



%changelog
## START: Generated by rpmautospec
* Thu Oct 17 2024 Alex <redhat@att.org.ru> - 1.8.1-1
- 1.8.1

* Thu Oct 10 2024 Petr Menšík <pemensik@redhat.com> - 1.8.0-1
- Initial build using autoconf

* Thu Oct 03 2024 Tatsuhiro Tsujikawa <404610+tatsuhiro-t@users.noreply.github.com>
- RPMAUTOSPEC: unresolvable merge
## END: Generated by rpmautospec