File bctoolbox.spec of Package bctoolbox

%define sover   1
%define enable_tests 0
Name:           bctoolbox
Version:        5.4.42
# 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
Summary:        Utility library for software from Belledonne Communications
License:        GPL-3.0-only
Group:          Development/Libraries/C and C++
URL:            https://linphone.org/
Source:         https://gitlab.linphone.org/BC/public/bctoolbox/-/archive/%{version}/%{name}-%{version}.tar.bz2
Source1:        baselibs.conf
# PATCH-FIX-OPENSUSE bctoolbox-fix-pkgconfig.patch
# Patch0:         bctoolbox-fix-pkgconfig.patch
# Patch1:         gcc9-stringop-bogus-warning.patch
# Patch1:         bctoolbox-0001-set-current-version.patch
BuildRequires:  bcunit-devel >= 5.4.42
BuildRequires:  chrpath
BuildRequires:  cmake
BuildRequires:  gcc-c++
#BuildRequires:  mbedtls-devel < 3
#BuildRequires:  mbedtls3.6-devel
BuildRequires:  openssl-devel
BuildRequires:  libdecaf-devel
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(bcunit)
BuildRequires:  pkgconfig(zlib)

%description
Utilities library used by Belledonne Communications softwares like
belle-sip, mediastreamer2 and linphone.

%package devel
Summary:        Development files for %{name}, a utility library for linphone/belle-sip/etc
Group:          Development/Libraries/C and C++
Requires:       cmake
Requires:       lib%{name}%{sover} = %{version}
%if %{enable_tests}
Requires:       lib%{name}-tester%{sover} = %{version}
%endif
#Requires:       mbedtls-devel < 3
#Requires:       mbedtls3.6-devel

%description devel
Utilities library used by Belledonne Communications softwares like
belle-sip, mediastreamer2 and linphone.

This package contains development files.

%package -n lib%{name}%{sover}
Summary:        Utility library for software from Belledonne Communications
Group:          Development/Libraries/C and C++

%description -n lib%{name}%{sover}
Utilities library used by Belledonne Communications softwares like
belle-sip, mediastreamer2 and linphone.

This package the contains shared library.

%if %{enable_tests}
%package -n lib%{name}-tester%{sover}
Summary:        Utility library for software from Belledonne Communications
Group:          Development/Libraries/C and C++

%description -n lib%{name}-tester%{sover}
Utilities library used by Belledonne Communications softwares like
belle-sip, mediastreamer2 and linphone.

This package the contains shared library for testing component.
%endif

%prep
%autosetup -p1

%build
#%%if 0%%{?fedora} == 36
export CFLAGS=$(echo "$CFLAGS -Wno-error=maybe-uninitialized -Wno-error=unused-parameter")
export CXXFLAGS=$(echo "$CXXFLAGS -Wno-error=maybe-uninitialized -Wno-error=unused-parameter")
#%%endif
# -DENABLE_TESTS=OFF
# 2024-01-27
# other libraries require crypto.h , which is only created by ENABLE_OPENSSL
# compilation of test code breaks compilation and is therefore disabled
%cmake \
%if %{enable_tests} == 0
  -DENABLE_TESTS_COMPONENT=OFF \
  -DENABLE_UNIT_TESTS=OFF \
%endif
  -DENABLE_STATIC=OFF \
  -DENABLE_STRICT=OFF \
  -DENABLE_MBEDTLS=OFF \
  -DENABLE_OPENSSL=YES \
  -DDecaf_DIR=/usr/share/decaf/cmake/
%cmake_build

%install
#%%if 0%%{?fedora}
#QA_RPATHS=$(( 0x0001|0x0002|0x0010 ))
#%%endif
%cmake_install
chrpath -d %{buildroot}%{_libdir}/lib%{name}.so.%{sover}*
%if %{enable_tests}
chrpath -d %{buildroot}%{_libdir}/lib%{name}-tester.so.%{sover}*
chrpath -d %{buildroot}%{_bindir}/bctoolbox-tester
%endif

%post -n lib%{name}%{sover} -p /sbin/ldconfig
%postun -n lib%{name}%{sover} -p /sbin/ldconfig
%if %{enable_tests}
%post -n lib%{name}-tester%{sover} -p /sbin/ldconfig
%postun -n lib%{name}-tester%{sover} -p /sbin/ldconfig
%endif

%files -n lib%{name}%{sover}
%license LICENSE.txt
%{_libdir}/lib%{name}.so.%{sover}*

%if %{enable_tests}
%files -n lib%{name}-tester%{sover}
%license LICENSE.txt
%{_libdir}/lib%{name}-tester.so.%{sover}*
%endif

%files devel
%license LICENSE.txt
%doc README.md
%{_libdir}/pkgconfig/%{name}.pc
%{_libdir}/lib%{name}.so
#%%{_datadir}/%%{name}/
%{_datadir}/BCToolbox/
%{_includedir}/%{name}/
%if %{enable_tests}
%{_bindir}/bctoolbox-tester
%{_libdir}/pkgconfig/bctoolbox-tester.pc
%{_libdir}/lib%{name}-tester.so
%endif
%changelog
openSUSE Build Service is sponsored by