# qlo10k1 need old qt version(2 or 3), it can't compile successfully now, so
# we don't include it now.
%global toolsdir {as10k1 envy24control hdspconf hdspmixer rmedigicontrol sb16_csp \
                  seq sscape_ctl us428control echomixer ld10k1 hwmixvolume hdajackretask \
                  hda-verb hdajacksensetest}

%global firmwaredir {hdsploader mixartloader pcxhrloader usx2yloader vxloader}

%global _helpUrl https://alsa.opensrc.org/Alsa-tools

Name:	 alsa-tools
Version: 1.2.5
Release: 3
Summary: Advanced tools for ALSA

License: GPLv2+
URL:	 https://www.alsa-project.org/
Source0: https://www.alsa-project.org/files/pub/tools/%{name}-%{version}.tar.bz2
Source1: 90-alsa-tools-firmware.rules

Patch1:  0001-echomixer-fix-clang-16-incompatible-function-pointer.patch

BuildRequires: alsa-lib-devel gcc gcc-c++ libtool findutils
BuildRequires: fltk-devel gtk2-devel gtk3-devel desktop-file-utils
Requires: xorg-x11-fonts-misc python3-alsa

Provides: alsa-tools-libs = %{version}-%{release}
Obsoletes: alsa-tools-libs

%description
This package contains advanced tools and libraries for certain sound cards.

  *as10k1 - AS10k1 Assembler version A0.99
  *envy24control - Control tool for Envy24 (ice1712) based soundcards
  *hdspconf - GUI to control the Hammerfall HDSP Alsa Settings
  *hdspmixer - Mixer for the RME Hammerfall DSP cards
  *rmedigicontrol - Control panel for RME Hammerfall cards
  *cspctl - Sound Blaster 16 ASP/CSP control program
  *sbiload - An OPL2/3 FM instrument loader for ALSA sequencer
  *sscape_ctl - ALSA SoundScape control utility
  *us428control - Control tool for Tascam 428
  *echomixer - Mixer for the Echo Audio soundcards
  *ld10k1 - Attempt to make EMU10K1 (EMU10K2) patch loader for ALSA
  *hwmixvolume - GUI tool to set individual hardware stream volumes
  *hdajackretask - HD-audio jack retasking tool
  *hda-verb - HD-audio jack retasking tool
  *hdajacksensetest - Tool to check HD-audio jack/pin status

More detail: %{_helpUrl}

%package firmware
Summary: firmware loader for ALSA
Requires: udev alsa-firmware fxload

%description firmware
This package contains firmware loader for certain sound cards.

  *hdsploader - Firmware loader for RME Hammerfall cards
  *mixartloader - Firmware loader for Digigram's miXart
  *pcxhrloader - Firmware loader for Digigram pcxhr compatible soundcards
  *usx2yloader - Firmware loader for Tascam USX2Y USB soundcards
  *vxloader - Firmware loader for Digigram's VX-board

More detail: %{_helpUrl}

%package devel
Summary: Development header files for certain sound cards
Requires: %{name}-libs

%description devel
This package contains header files for certain sound cards.

  *ld10k1 - Attempt to make EMU10K1 (EMU10K2) patch loader for ALSA

More detail: %{_helpUrl}

%package help
Summary:   Documents for %{name}
Buildarch: noarch
Requires:  man info

%description help
Man pages and other related documents for %{name}.

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

%build
for tool in  %{toolsdir} %{firmwaredir}
do
  case $tool in
    seq )
      tool_dir=seq/sbiload
    ;;
    * )
      tool_dir=$tool
    ;;
  esac

  pushd $tool_dir
    autoconf
    %configure
    %make_build
  popd
done
unset tool tool_dir

%install
for tool in %{toolsdir} %{firmwaredir}
do
  case $tool in
    seq )
      tool_dir=seq/sbiload
    ;;
    * )
      tool_dir=$tool
    ;;
  esac

  pushd $tool_dir
  case $tool in
    usx2yloader )
      %make_install hotplugdir=/lib/udev
      ;;
    * )
      %make_install
      ;;
  esac
  mkdir -p -m 755 %{buildroot}%{_docdir}/%{name}/${tool_dir##*/}
  for f in README COPYING AUTHORS NEWS ChangeLog TODO;
  do
    test -f $f || continue
    install -c -m 0644 $f %{buildroot}%{_docdir}/%{name}/${tool_dir##*/}
  done
  popd
done
unset tool tool_dir

rm -f %{buildroot}/lib/udev/tascam_fw.usermap
mkdir -p %{buildroot}/lib/udev/rules.d
install -m 0644 %{SOURCE1} %{buildroot}/lib/udev/rules.d

pushd %{buildroot}
for desktopfile in `find -type f -name *.desktop`;do
    desktop-file-validate $desktopfile
    desktop-file-install --dir %{buildroot}%{_datadir}/applications $desktopfile
done
popd

%post
touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :

%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 || :

%ldconfig_scriptlets libs

%files
%{_bindir}/*
%exclude %{_bindir}/hdsploader
%exclude %{_bindir}/mixartloader
%exclude %{_bindir}/pcxhrloader
%exclude %{_bindir}/usx2yloader
%exclude %{_bindir}/vxloader

%{_sbindir}/*
%{_datadir}/applications/*.desktop

%{_docdir}/alsa-tools/*
%exclude %{_docdir}/alsa-tools/hdsploader/
%exclude %{_docdir}/alsa-tools/mixartloader/
%exclude %{_docdir}/alsa-tools/pcxhrloader/
%exclude %{_docdir}/alsa-tools/usx2yloader/
%exclude %{_docdir}/alsa-tools/vxloader/

%{_datadir}/icons/hicolor/*/apps/*.png
%{_datadir}/ld10k1/effects/*.emu10k1
%{_datadir}/sounds/opl3/*

%{_libdir}/liblo10k1.so.*

%files firmware
/lib/udev/tascam*
/lib/udev/rules.d/*.rules
%{_bindir}/hdsploader
%{_bindir}/mixartloader
%{_bindir}/pcxhrloader
%{_bindir}/usx2yloader
%{_bindir}/vxloader
%{_docdir}/alsa-tools/hdsploader/*
%{_docdir}/alsa-tools/mixartloader/*
%{_docdir}/alsa-tools/pcxhrloader/*
%{_docdir}/alsa-tools/usx2yloader/*
%{_docdir}/alsa-tools/vxloader/*

%files devel
%{_includedir}/lo10k1/*.h

%{_libdir}/liblo10k1.so
%exclude %{_libdir}/*.la

%{_datadir}/aclocal/*.m4

%files help
%{_mandir}/man1/*

%changelog
* Wed Apr 16 2025 Funda Wang <fundawang@yeah.net> - 1.2.5-3
- drop gtk 1.x support

* Wed Aug 28 2024 yanying <201250106@smail.nju.edu.cn> - 1.2.5-2
- backport fix for clang build 

* Mon Nov 29 2021 zhouwenpei <zhouwenpei1@huawei.com> - 1.2.5-1
- update to version 1.2.5

* Tue Feb 2 2021 xinghe <xinghe@huawei.com> - 1.2.2-3
- fix bad requires

* Fri Sep 25 2020 xinghe <xinghe@huawei.com> - 1.2.2-2
- remove old tar packages

* Mon Jun 24 2020 xinghe <xinghe@huawei.com> - 1.2.2-1
- update to version 1.2.2

* Thu Aug 29 2019 luchunsheng <luochunsheng@huawei.com> - 1.1.6-4
- Fix bad requires

* Mon Aug 19 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.1.6-3
- Package init
