File postquantumcryptoengine.spec of Package postquantumcryptoengine

%define _name postquantumcryptoengine
%define _cmakename PostQuantumCryptoEngine
%define major 1
%define libname lib%{_name}
%define devname lib%{_name}-devel

%define sobase lib%{_name}
%define sover 1

%bcond_with static
%bcond_without strict
%bcond_without tests
%define enable_tests 0

# NOTE: use commit if the last release is still in beta
%global commit ea086ea0aa9ec3b5cfb5be7d73fd6da579e1dce9

Summary:    Post Quantum algorithm integration to bctoolbox
Name:       postquantumcryptoengine
Version:    5.3.0
# Fedora release look standard from OpenSUSE build service:
# Release:      <CI_CNT>.<B_CNT>
# Release:      %%{?release_prefix}.<CI_CNT>.<B_CNT>
# where rpm macro %%{release_prefix} is defined in spec file
# Normally it looks like:
# Release:      63.fc38 for Fedora packages which is scripted as:
# Release:      0%%{?dist}
# OpenSUSE build service allows for this variant:
# Release:      63.1.fc38
# Release:       <CI_CNT>.<B_CNT>%%{?dist}
#
# Add this to Project Config to tag Fedora packages with fcXX:
# ------------------------------
# # reset release name
# onepercentage%%if 0onepercentage%%{?fedora_version}
# Release: <CI_CNT>.<B_CNT> spec:<CI_CNT>.<B_CNT>twopercentage%%{?dist}
# onepercentage%%endif
# ------------------------------
Release:        0
#License:    GPLv3
License:    GPL-3.0-or-later
Group:      System/Libraries
URL:        https://linphone.org/
#Source0:   https://gitlab.linphone.org/BC/public/Postquantumcryptoengine/-/archive/%%{version}-beta/Postquantumcryptoengine-%%{version}-beta.tar.bz2
#Source0:   https://gitlab.linphone.org/BC/public/%%{name}/-/archive/%%{?commit:%%{commit}}%%{!?commit:%%{version}}/%%{name}-%%{?commit:%%{commit}}%%{!?commit:%%{version}}.tar.bz2
Source0:    %{name}-%{version}.tar.bz2
BuildRequires:  gcc-c++
%if 0%{?suse_version}
BuildRequires:  libopenssl-devel
BuildRequires:  ninja
%endif
%if 0%{?fedora_version} > 1
BuildRequires:  openssl-devel
BuildRequires:  ninja-build
%endif
BuildRequires:  cmake
#BuildRequires: bctoolbox-static-devel
BuildRequires:  bctoolbox-devel => 5.3.5
#BuildRequires: cmake(bctoolbox)
#
# Jun 2023:
# OpenSUSE system liboqs is too new 0.8.0
# Workaround: created new package liboqs-linphone for old v0.7.1
#
#BuildRequires:  liboqs-devel
#BuildRequires:  liboqs-devel = 0.7.1
%if 0%{?fedora_version} > 1
BuildRequires:  liboqs-devel = 0.7.2
%endif
%if 0%{?suse_version}
BuildRequires:  liboqs-devel = 0.7.2
%endif
#BuildRequires:  liboqs-devel => 0.7.1
#BuildRequires:  liboqs-devel =< 0.8.0
#BuildRequires:  liboqs-linphone-devel => 0.7.1
#BuildRequires: cmake(liboqs)

%description
postquantumcryptoengine is an extension to the bctoolbox lib providing Post
Quantum Cryptography.

 *  Kyber 512, 768 and 1024
 *  HQC 128, 192 and 256 (NIST round 3 version)
 *  X25519 and X448 in KEM version and a way to combine two or more of
    theses.

#---------------------------------------------------------------------------

#%%package -n %%{libname}
%package -n %{sobase}%{sover}
Summary:  Post Quantum algorithm integration to bctoolbox
Group:    System/Libraries

#%%description -n %%{libname}
%description -n %{sobase}%{sover}
postquantumcryptoengine is an extension to the bctoolbox lib providing Post
Quantum Cryptography.

 *  Kyber 512, 768 and 1024
 *  HQC 128, 192 and 256 (NIST round 3 version)
 *  X25519 and X448 in KEM version and a way to combine two or more of
    theses.

#%%files -n %%{libname}
%files -n %{sobase}%{sover}
%{_libdir}/lib%{name}.so.%{sover}*

#---------------------------------------------------------------------------

%package -n %{devname}
Summary:  Development files for %{name}
Group:    Development/C
Provides: %{name}-devel = %{version}-%{release}
#Requires: %%{libname} = %%{version}-%%{release}
Requires: %{sobase}%{sover} = %{version}-%{release}

%description -n %{devname}
This package contains development files for %{name}

%files -n %{devname}
%if %{enable_tests}
%{_bindir}/pqcrypto-tester
%endif
%{_includedir}/%{name}/
%{_libdir}/lib%{name}.so
#%%{_libdir}/cmake/%%{name}
%{_libdir}/cmake/%{_cmakename}
#---------------------------------------------------------------------------

%prep
#%%autosetup -p1 -n %%{name}-%%{version}-beta-%%{commit}
#%%autosetup -p1 -n %%{name}-%%{?commit:%%{commit}}%%{!?commit:%%{version}}
%autosetup -p1 -n %{name}-%{version}

%build
%cmake \
  -DENABLE_STATIC:BOOL=%{?with_static:ON}%{?!with_static:OFF} \
  -DENABLE_STRICT:BOOL=%{?with_strict:ON}%{?!with_strict:OFF} \
%if %{enable_tests} == 0
  -DENABLE_TOOLS=OFF \
  -DENABLE_UNIT_TESTS=OFF \
  -DENABLE_TESTS:BOOL=%{?with_tests:ON}%{?!with_tests:OFF} \
%endif
  -DCONFIG_PACKAGE_LOCATION:PATH=%{_libdir}/cmake/%{name} \
  -G Ninja

%if 0%{?suse_version}
%ninja_build
%endif
%if 0%{?fedora} > 1
%ninja_build -C redhat-linux-build
%endif

%install
%if 0%{?suse_version}
%ninja_install -C build
%endif
%if 0%{?fedora} > 1
%ninja_install -C redhat-linux-build
rm -f $HOME/.rpmmacros
export QA_RPATHS=$(( 0x0001|0x0002 ))
%endif

# fix cmake stuff path
install -dm 0755 %{buildroot}%{_libdir}/cmake
#mv %%{buildroot}%%{_datadir}/%%{name}/cmake %%{buildroot}%5{_libdir}/cmake/%%{name}
mv %{buildroot}%{_datadir}/%{_cmakename}/cmake %{buildroot}%{_libdir}/cmake/%{_cmakename}
#rmdir %%{buildroot}%%{_datadir}/%%{name}
rmdir %{buildroot}%{_datadir}/%{_cmakename}
rm -f %{buildroot}/usr/lib/debug/usr/bin/pqcrypto-tester.debug

%post -n %{sobase}%{sover} -p /sbin/ldconfig
%postun -n %{sobase}%{sover} -p /sbin/ldconfig

%changelog
openSUSE Build Service is sponsored by