File jamesdsp.spec of Package jamesdsp

#
# spec file for package jamesdsp
#
# copyright (c) 2024 munix9@googlemail.com
#

%define flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == ""
%define pkg_mode %{nil}
%define pkg_type PipeWire
%define pkg_meta %{nil}
%global pkg_conf %{nil}
%else
%define pkg_mode -%{flavor}
%define pkg_type PulseAudio
%define pkg_meta .pulse
%global pkg_conf USE_PULSEAUDIO
%endif
%ifarch %{arm} %{arm64}
%global pkg_conf %{pkg_conf} NO_CRASH_HANDLER
%endif

Name:           jamesdsp%{pkg_mode}
Version:        2.7.0
Release:        0
Summary:        An audio effect processor for %{pkg_type} clients
License:        GPL-3.0-or-later
URL:            https://github.com/Audio4Linux/JDSP4Linux
Source0:        jamesdsp-%{version}.tar.gz
# https://github.com/Audio4Linux/JDSP4Linux/pull/191
Patch0:         fix-gcc14.patch
BuildRequires:  AppStream
BuildRequires:  cmake
BuildRequires:  hicolor-icon-theme
BuildRequires:  pkgconfig
BuildRequires:  qt6-gui-private-devel
BuildRequires:  update-desktop-files
BuildRequires:  cmake(Qt6Core)
BuildRequires:  cmake(Qt6Network)
BuildRequires:  cmake(Qt6Svg)
BuildRequires:  cmake(Qt6Xml)
BuildRequires:  pkgconfig(glibmm-2.4)
BuildRequires:  pkgconfig(libarchive)
Provides:       JDSP4Linux = %{version}
Obsoletes:      JDSP4Linux < %{version}
Provides:       JDSP4Linux-common = %{version}
Obsoletes:      JDSP4Linux-common < %{version}
%if "%{flavor}" == ""
BuildRequires:  pkgconfig(libpipewire-0.3)
Conflicts:      jamesdsp-pulse
Conflicts:      JDSP4Linux-pulseaudio
Provides:       jamesdsp-pipewire = %{version}
Obsoletes:      jamesdsp-pipewire < %{version}
Provides:       JDSP4Linux-pipewire = %{version}
Obsoletes:      JDSP4Linux-pipewire < %{version}
%else
BuildRequires:  pkgconfig(gstreamer-1.0)
BuildRequires:  pkgconfig(gstreamer-audio-1.0)
BuildRequires:  pkgconfig(libpulse)
Conflicts:      jamesdsp-pipewire
Conflicts:      JDSP4Linux-pipewire
Provides:       jamesdsp = %{version}
Obsoletes:      jamesdsp < %{version}
Provides:       jamesdsp-pulseaudio = %{version}
Provides:       JDSP4Linux-pulseaudio = %{version}
Obsoletes:      JDSP4Linux-pulseaudio < %{version}
%endif
%if 0%{?suse_version} <= 1500
BuildRequires:  gcc11-PIE
BuildRequires:  gcc11-c++
%else
BuildRequires:  gcc-c++
%endif

%description
JamesDSP provides open-source sound effects for %{pkg_type} clients.

%prep
%autosetup -n jamesdsp-%{version} -p1

# get APP_VERSION eg. with "git describe --tags --long --always"
APP_VERSION="2.7.0-0-g30a30aa"
#APP_VERSION="$(echo "%%{version}" | sed -r 's/(.*)\+git(.*)\.(.*)/\1-\2-g\3/')"
sed -e "s|^\(DEFINES += APP_VERSION\)=.*|\1=$APP_VERSION|" -i src/src.pro

%check

%build
%if 0%{?suse_version} <= 1500
export CC=gcc-11
export CXX=g++-11
%endif

mkdir build
cd build
%qmake6 .. \
%if 0%{?suse_version} <= 1500
	QMAKE_CC=gcc-11 QMAKE_CXX=g++-11 \
%endif
%if "%{pkg_conf}" != ""
	"CONFIG += %{pkg_conf}" \
%endif
	%{nil}

%qmake6_build

%install
install -D -m 0755 -t %{buildroot}%{_bindir} build/src/jamesdsp
mkdir -p %{buildroot}%{_datadir}/applications/
install -D -m 0644 -t %{buildroot}%{_datadir}/metainfo/jamesdsp.metainfo.xml \
	meta/flatpak/me.timschneeberger.jdsp4linux%{pkg_meta}.metainfo.xml
appstreamcli validate --no-net \
	%{buildroot}%{_datadir}/metainfo/jamesdsp.metainfo.xml || :
install -D -m 0644 resources/icons/icon.png \
	%{buildroot}%{_datadir}/pixmaps/jamesdsp.png
install -D -m 0644 resources/icons/icon.png \
	%{buildroot}%{_datadir}/icons/hicolor/512x512/apps/jamesdsp.png
install -D -m 0644 resources/icons/icon.svg \
	%{buildroot}%{_datadir}/icons/hicolor/scalable/apps/jamesdsp.svg
chmod +x "%{buildroot}/usr/bin/jamesdsp"

cat <<EOT >> "%{buildroot}/usr/share/applications/jamesdsp.desktop"
[Desktop Entry]
Name=JamesDSP
GenericName=Audio effect processor
Comment=JamesDSP for Linux
Keywords=equalizer;audio;effect
Categories=AudioVideo;Audio
Exec=/usr/bin/jamesdsp
Icon=/usr/share/pixmaps/jamesdsp.png
StartupNotify=false
Terminal=false
Type=Application
EOT

%files
%license LICENSE
%doc README.md
%attr(0755, root, root) "%{_bindir}/jamesdsp"
%{_datadir}/applications/jamesdsp.desktop
%{_datadir}/icons/hicolor/*/apps/jamesdsp.*
%{_datadir}/metainfo/jamesdsp.metainfo.xml
%{_datadir}/pixmaps/jamesdsp.png

%changelog
openSUSE Build Service is sponsored by