File webrtc-audio-processing.spec of Package webrtc-audio-processing

# vim: set sw=4 ts=4 et nu:
#
# spec file for package webrtc-audio-processing
#
# Copyright (c) 2025 SUSE LLC
# Copyright (c) 2012 Pascal Bleser <pascal.bleser@opensuse.org>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%global use_clang 1
%global use_lld 1
%ifarch %ix86 %arm
%global use_lto 0
%else
%global use_lto 1
%endif

%define major_version 2
%define soname      1
%define pkg_soname  %{major_version}-%{soname}
# Please submit bugfixes or comments via http://bugs.opensuse.org/
Name:           webrtc-audio-processing
Version:        2.1
Release:        0
Summary:        Real-Time Communication Library for Web Browsers
License:        BSD-3-Clause
Group:          System/Libraries
URL:            https://www.freedesktop.org/software/pulseaudio/webrtc-audio-processing/
#Source:         http://freedesktop.org/software/pulseaudio/webrtc-audio-processing/webrtc-audio-processing-%{version}.tar.xz
Source:         webrtc-audio-processing-%{version}.tar.xz
Source1:        baselibs.conf
# PATCH-FIX-UPSTREAM fix-build.patch alarrosa@suse.com -- Fix a number of "control reaches end of non-void function" errors
Patch0:         fix-build.patch
%if 0%{?use_clang}
BuildRequires:  clang-devel
#BuildRequires:     npth-devel
%if 0%{?use_lld}
BuildRequires:  lld
%else
BuildRequires:  binutils-gold
BuildRequires:  llvm-gold
%endif
%else
BuildRequires:  binutils-gold
BuildRequires:  gcc-c++
%endif
BuildRequires:  cmake
BuildRequires:  glibc-devel
BuildRequires:  make
BuildRequires:  meson >= 0.59.4
BuildRequires:  pkgconfig
BuildRequires:  xz
BuildRequires:  cmake(absl) >= 20240722
ExcludeArch:    s390 s390x ppc64

%description
WebRTC is an open source project that enables web browsers with Real-Time
Communications (RTC) capabilities via simple Javascript APIs. The WebRTC
components have been optimized to best serve this purpose.

WebRTC implements the W3C's proposal for video conferencing on the web.

%package -n libwebrtc-audio-processing-%{pkg_soname}
Summary:        Real-Time Communication Library for Web Browsers
Group:          System/Libraries

%description -n libwebrtc-audio-processing-%{pkg_soname}
WebRTC is an open source project that enables web browsers with Real-Time
Communications (RTC) capabilities via simple Javascript APIs. The WebRTC
components have been optimized to best serve this purpose.

WebRTC implements the W3C's proposal for video conferencing on the web.

%package -n libwebrtc-audio-processing-devel
Summary:        Real-Time Communication Library for Web Browsers
Group:          Development/Libraries/C and C++
Requires:       libwebrtc-audio-processing-%{pkg_soname} = %{version}

%description -n libwebrtc-audio-processing-devel
WebRTC is an open source project that enables web browsers with Real-Time
Communications (RTC) capabilities via simple Javascript APIs. The WebRTC
components have been optimized to best serve this purpose.

WebRTC implements the W3C's proposal for video conferencing on the web.

%package -n libwebrtc-audio-processing-devel-static
Summary:        Real-Time Communication Library for Web Browsers
Group:          Development/Libraries/C and C++
Requires:       libwebrtc-audio-processing-devel = %{version}

%description -n libwebrtc-audio-processing-devel-static
WebRTC is an open source project that enables web browsers with Real-Time
Communications (RTC) capabilities via simple Javascript APIs. The WebRTC
components have been optimized to best serve this purpose.

WebRTC implements the W3C's proposal for video conferencing on the web.

%prep
%autosetup -p1
sed -i 's/\r$//' AUTHORS

%build
# this macro needs 'BuildRequires: memory-constraints'
#limit_build -m 3072
ulimit -Sn 4000
UCFLAGS="-fPIC -O3"
%ifarch x86_64
	export UCFLAGS="${UCFLAGS} -march=x86-64 -mtune=generic -mssse3 -msse4 -msse4.1 -msse4.2 -mavx -maes -mpclmul"
%endif
export ULDFLAGS="-fPIC -Wl,--icf=safe -Wl,--gc-sections -Wl,-O1"
%ifarch %ix86 %arm
# quell some random x32-specific errors
export UCFLAGS="${UCFLAGS} -fopenmp"
export ULDFLAGS="${ULDFLAGS} -fopenmp -Wl,-z,notext"
%endif
%if 0%{?use_lld}
export ULDFLAGS="${ULDFLAGS} -fuse-ld=lld"
export LD="lld"
alias ld=ld.lld
%else
export ULDFLAGS="${ULDFLAGS} -fuse-ld=gold -Wl,--sort-common -Wl,-O1"
export LD=ld.gold
alias ld=gold
%endif
%if 0%{?use_clang}
export CC=clang
export CXX=clang++
#export UCFLAGS="${UCFLAGS} -v "
#export UCFLAGS="${UCFLAGS} -D_GNU_SOURCE -fexceptions -relocatable-pch -faligned-allocation"
export UCXXFLAGS="${UCFLAGS}"
#export UCXXFLAGS="${UCXXFLAGS} -fpermissive -fcxx-exceptions"
#export ULDFLAGS="${ULDFLAGS} -latomic"
export HOST="$(${CC} -print-target-triple)"
%if 0%{?use_lto}
%if 0%{?use_lld}
%global _lto_cflags -flto=thin
%global _lto_ldlags -flto=thin
%else
%global _lto_cflags -flto=thin
%global _lto_ldlags -flto=thin
%endif
%else
%global _lto_cflags %nil
%global _lto_ldlags %nil
%endif
%else
export CC=gcc
export CXX=g++
export UCFLAGS="${UCFLAGS} -ftree-parallelize-loops=4 -ftree-vectorize -fpredictive-commoning"
export UCXXFLAGS="${UCFLAGS} -fpermissive"
export HOST="%{_target_platform}"
%if 0%{?use_lto}
%global _lto_cflags -fuse-linker-plugin %_lto_cflags -ffat-lto-objects -flto-odr-type-merging
%global _lto_ldlags -fuse-linker-plugin -flto=2
%else
%global _lto_cflags %nil
%global _lto_ldlags %nil
%endif
%endif
export TARGET="${HOST}"
export UCFLAGS="${UCFLAGS} %_lto_cflags"
export UCXXFLAGS="${UCXXFLAGS} %_lto_cflags"
export ULDFLAGS="${ULDFLAGS} %_lto_cflags %_lto_ldlags"
# override OBS defaults ?
export CFLAGS="${UCFLAGS}"
export CXXFLAGS="${UCXXFLAGS}"
export LDFLAGS="${ULDFLAGS}"

# wouldn't be Google's code without being amateurishly broken to all hell
%meson \
	-Dc_std=gnu11 \
	-Dcpp_std=gnu++17 \
	-Dstrip=false \
	-Ddefault_library=both \
	-Db_ndebug=true \
	-Dc_args="${CFLAGS} ${LDFLAGS}" \
	-Dcpp_args="${CXXFLAGS} ${LDFLAGS}" \
	-Dgnustl=disabled \
%ifarch aarch64
	-Dneon=enabled \
%else
	-Dneon=disabled \
%endif
%ifarch i586
	-Dinline-sse=false \
%endif
	%{nil} || cat */meson-logs/meson-log.txt
%meson_build

%install
%meson_install
# why the actual fuck this piece of garbage does not install headers on which headers, that it installs, depend upon?!
find webrtc/{api,common_audio,modules,rtc_base} -iname "*.cc" -delete -print
find webrtc/{api,common_audio,modules,rtc_base} -iname "meson*" -delete -print
find webrtc/{api,common_audio,modules,rtc_base} -iname "BUILD.gn" -delete -print
cp -Rfv webrtc/{api,common_audio,modules,rtc_base} %{buildroot}%{_includedir}/webrtc-audio-processing-*/
find %{buildroot} -type f -name "*.la" -delete -print

%post   -n libwebrtc-audio-processing-%{pkg_soname} -p /sbin/ldconfig
%postun -n libwebrtc-audio-processing-%{pkg_soname} -p /sbin/ldconfig

%files -n libwebrtc-audio-processing-%{pkg_soname}
%license COPYING
%doc AUTHORS NEWS README.md UPDATING.md
%{_libdir}/libwebrtc-audio-processing-%{major_version}.so.%{soname}*

%files -n libwebrtc-audio-processing-devel
%{_includedir}/webrtc-audio-processing-%{major_version}
%{_libdir}/libwebrtc-audio-processing-%{major_version}.so
%{_libdir}/pkgconfig/webrtc-audio-processing-%{major_version}.pc

%files -n libwebrtc-audio-processing-devel-static
%{_libdir}/libwebrtc-audio-processing-%{major_version}.a

%changelog
openSUSE Build Service is sponsored by