%global build_cflags %{optflags} -fcommon

Name:           spectrum3d
Version:        2.7.2
Release:        0.2%{?dist}
Summary:        3D audio spectrum analyser in real time
Group:          Sound
License:        GPLv3
Url:            http://spectrum3d.sourceforge.net
Source:         %{name}-%{version}.tar.gz
#:! for N in `grep -rl 'g_build_filename.*"icons"' ~/RPM/BUILD/spectrum3d-2*[0-9]`; do sed -Ei 's/(g_build_filename .*, "icons",)/\1 "spectrum3d",/' $N; done
Patch 0:          spectrum3d-2.7.1-iconspath.patch

# Upstream provides none of the following files
Source1:        %{name}.appdata.xml

BuildRequires:  gcc gstreamer1-devel SDL2-devel gtk3-devel
BuildRequires:  jack-audio-connection-kit-devel
BuildRequires:  mesa-libGLU-devel
BuildRequires:  libappstream-glib

%description
Spectrum 3D displays a 3D audio spectrogram in real time; the source can
be either the microphone or an audio file; it is also possible to record
a file and to have it analysed; so analysis can be done done on the fly
(harmonics are displayed while the audio file is being played), or
before the file is being played (in that case, the analysis of the whole
will be performed and displayed, then the file can be played
afterwards).

%prep
%setup -q
%patch 0 -p1

%build
%configure
%make_build icondir=%{_datadir}/icons/%{name} svgicondir=%{_datadir}/icons/%{name}

%install
%make_install icondir=%{_datadir}/icons/%{name} svgicondir=%{_datadir}/icons/%{name}
install -D data/spectrum3d.png %{buildroot}%{_datadir}/icons/hicolor/48x48/apps/spectrum3d.png
install -D data/spectrum3d.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/spectrum3d.png
install -D COPYING %{buildroot}%{_datadir}/licenses/%{name}/COPYING
install -Dpm 0644                                                             \
%{SOURCE1} %{buildroot}%{_datadir}/appdata/%{name}.appdata.xml
appstream-util                                                                \
validate-relax --nonet %{buildroot}%{_datadir}/appdata/%{name}.appdata.xml

%post
if [ $1 -eq 1 ]; then
    touch --no-create %{_datadir}/icons/hicolor >&/dev/null || :
fi

%postun
if [ $1 -eq 0 ]; then
    touch --no-create %{_datadir}/icons/hicolor >&/dev/null || :
    gtk-update-icon-cache %{_datadir}/icons/hicolor >&/dev/null || :
fi

%posttrans
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :

%files
%doc README*
%license COPYING
%_bindir/*
%{_datadir}/appdata/%{name}.appdata.xml
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/%{name}/*
%{_datadir}/icons/hicolor/*/apps/*

%changelog
* Wed Apr 29 2020 Johan Heikkila <johan.heikkila@gmail.com> 2.7.2-0.2
- Explicitely use -fcommon to fix building with gcc 10.

* Sat Jan 27 2018 Johan Heikkila <johan.heikkila@gmail.com> 2.7.2-0.1
- Build for Fedora. Spec adapted from altlinux. Fixed icon installation.

* Wed Sep 20 2017 Fr. Br. George <george@altlinux.ru> 2.7.1-alt1
- Autobuild version bump to 2.7.1

* Tue Feb 03 2015 Fr. Br. George <george@altlinux.ru> 2.5.0-alt1
- Autobuild version bump to 2.5.0
- Fix icon path patch

* Thu Sep 18 2014 Fr. Br. George <george@altlinux.ru> 2.4.0-alt1
- Autobuild version bump to 2.4.0
- Fix icon path

* Thu Sep 18 2014 Fr. Br. George <george@altlinux.ru> 2.3.0-alt1
- Initial build