%define fname         webrtc-audio-processing

# Majors
%define super         2
%define major         1

# Library names
# The naming scheme in non-Mandriva-based distros
%if 0%{!?mklibname:1}
%define mklibname(ds)  lib%{1}%{?2:%{2}}%{-s:-static}%{-d:-devel}
%endif
%if 0%{!?mkrel:1}
%define mkrel(c) %{1}%{?dist}
%endif

%define libname       %mklibname %{name}_ %{major}
%define libname_devel %mklibname %{name} -d

Summary:        WebRTC Audio Processing Library
Name:           %{fname}%{super}
Version:        %{super}.%{major}
%if %{super} == 1
Release:        %mkrel 4
%elif %{super} == 2
Release:        %mkrel 1.4
%endif
License:        Distributable
Group:          System/Libraries
Url:            https://freedesktop.org/software/pulseaudio/webrtc-audio-processing/
%if %{super} >= 2
Source0:        http://freedesktop.org/software/pulseaudio/%{fname}/%{fname}-%{version}.tar.xz
%else
Source0:        https://freedesktop.org/software/pulseaudio/%{fname}/%{fname}-%{version}.tar.gz
%endif

%if %{super} >= 2
%global absl_min_version 20240722
%else
%global absl_min_version 20220623
%endif

# Upstream patches merged from https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing
#

# other patches
%if %{super} < 2
Patch101:       big-endian-support.patch
%endif
Patch102:       Add-generic-byte-order-and-pointer-size-detection.patch
# actually doesn't build on i586 with these two patchset, temporarily disabling
Source103:      Avoid-SSE2-on-i386.patch
Source104:      Avoid-SSE2-on-i386-meson.patch
#
%if %{super} < 2
Patch105:       webrtc-audio-processing-noavx2-nosse2-i586.patch
%endif
# from PLD
%if %{super} < 2
Patch106:       webrtc-audio-processing1-nosimd.patch
%endif
#
BuildRequires:  meson >= 0.63
BuildRequires:  gcc-c++ >= 9.1
BuildRequires:  cmake(absl) >= %{absl_min_version}
BuildRequires:  cmake

%description
Packaging friendly copy of the AudioProcessing module from the WebRTC project.
See http://webrtc.org for more details

%package -n     %{libname}
Summary:        WebRTC Audio Processing Library
Group:          System/Libraries
%if %{super} < 2
# fix libpkg name
Obsoletes:      %{_lib}webrtc-audio-processing11 < 1.0-6
%endif

%description -n %{libname}
WebRTC Audio Processing Library.

%package -n     %{libname_devel}
Summary:        Development files for WebRTC Audio Processing Library
Group:          Development/C
Requires:       %{libname} = %{version}-%{release}
Provides:       %{name}-devel = %{version}-%{release}
%if %{super} < 2
# (daviddavid) my bad with a typo
Obsoletes:      %{_lib}webrtc-audio-processing1webrtc-audio-processing1-devel < 1.0-7
%endif

%description -n %{libname_devel}
Development files for WebRTC Audio Processing Library.

%prep
%setup -q -n %{fname}-%{version}
%autopatch -p1

%build
%meson \
%if %{super} >= 2
	-Dinline-sse=false \
	-Dneon=disabled \
%endif
	-Dcpp_std=gnu++17
%meson_build

%install
%meson_install

%files -n %{libname}
%if %{super} < 2
%{_libdir}/libwebrtc-audio-coding-%{super}.so.%{major}
%endif
%{_libdir}/libwebrtc-audio-processing-%{super}.so.%{major}

%files -n %{libname_devel}
%doc README* COPYING
%{_includedir}/webrtc-audio-processing-%{super}/
%if %{super} < 2
%{_libdir}/libwebrtc-audio-coding-%{super}.so
%endif
%{_libdir}/libwebrtc-audio-processing-%{super}.so
%{_libdir}/pkgconfig/webrtc-*.pc


%changelog
* Mon Dec 11 2023 ghibo <ghibo> 1.3-1.mga9
+ Revision: 2017211
- Update to release 1.3.
- Drop patches merged upstream.

* Fri Jan 27 2023 daviddavid <daviddavid> 1.0-7.mga9
+ Revision: 1936449
- fix devel pkg name, typo in previous commit r1936413

* Fri Jan 27 2023 daviddavid <daviddavid> 1.0-6.mga9
+ Revision: 1936413
- fix library pkg name

* Thu Oct 27 2022 ghibo <ghibo> 1.0-5.mga9
+ Revision: 1899614
- Remove old webrtc-audio-processing spec file
- Use webrtc-audio-processing1 as package name
- Disable _disable_ld_no_undefined as no longer needed.
- Sync patchset from current git upstream.
- Disable older 32bit Patches (Avoid-SSE2-on-i386, Avoid-SSE2-on-i386-meson) as doesn't compile con i586.
- Reorder deb patches (101, 102).
- Merge nosimd's webrtc-audio-processing1-nosimd patch from pld.
- Write patch for disabling sse2 and avx2 on i586 (webrtc-audio-processing-noavx2-nosse2-i586.patch).
- Force c++17.
- Prepare for switching to webrtc-audio-processing1 package name.
- Copy webrtc-audio-processing to webrtc-audio-processing1.
+ neoclust <neoclust>
- Rebuild with arm build fix patches
+ umeabot <umeabot>
- Mageia 9 Mass Rebuild
+ luigiwalser <luigiwalser>
- 1.0
- library major is now 0
- remove upstream patch
- adding audio-coding library

* Mon May 04 2020 danf <danf> 0.3.1-2.mga9
+ Revision: 1580012
- Switch URLs from http: to https:

* Fri Feb 14 2020 umeabot <umeabot> 0.3.1-2.mga8
+ Revision: 1521690
- Mageia 8 Mass Rebuild
+ wally <wally>
- replace deprecated %%configure2_5x
- replace deprecated %%apply_patches

* Sat Dec 29 2018 luigiwalser <luigiwalser> 0.3.1-1.mga7
+ Revision: 1346458
- 0.3.1

* Tue Dec 11 2018 pterjan <pterjan> 0.3-3.mga7
+ Revision: 1340324
- Disable neon on armv7hl
- Replace patch with a better one from Fedora

* Sun Sep 23 2018 umeabot <umeabot> 0.3-2.mga7
+ Revision: 1301660
- Mageia 7 Mass Rebuild

* Mon Jun 27 2016 pterjan <pterjan> 0.3-1.mga6
+ Revision: 1037768
- 0.3 (build fixes)

* Wed May 11 2016 luigiwalser <luigiwalser> 0.2-2.mga6
+ Revision: 1013677
- add -msse2 to compiler flags to fix build on i586
- add patch from debian to fix build on newer gcc
- 0.2
- library major is now 1

* Tue Feb 02 2016 umeabot <umeabot> 0.1-5.mga6
+ Revision: 932578
- Mageia 6 Mass Rebuild

* Wed Oct 15 2014 umeabot <umeabot> 0.1-4.mga5
+ Revision: 748492
- Second Mageia 5 Mass Rebuild

* Tue Sep 16 2014 umeabot <umeabot> 0.1-3.mga5
+ Revision: 690289
- Mageia 5 Mass Rebuild

* Sun Jun 22 2014 wally <wally> 0.1-2.mga5
+ Revision: 638706
- rebuild for mga5

* Wed Jul 25 2012 colin <colin> 0.1-1.mga3
+ Revision: 274202
- imported package webrtc-audio-processing