File sphinxbase.spec of Package sphinxbase

#
# spec file for package sphinxbase
#
# Copyright (c) 2022 SUSE LLC
#
# 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/
#


Name:           sphinxbase
Version:        0.8
Release:        0
Summary:        Support library required by Pocketsphinx
License:        BSD-2-Clause AND MIT
Group:          Productivity/Office/Other
URL:            http://cmusphinx.sourceforge.net/wiki/download/
Source:         http://downloads.sourceforge.net/project/cmusphinx/%{name}/%{version}/%{name}-%{version}.tar.gz
# PATCH-FIX-UPSTREAM remove __DATE and __TIME
Patch0:         sphinxbase-no-date.patch
# PATCH-FIX-UPSTREAM fix doxygen documentation
Patch1:         sphinxbase-doxygen.patch
# PATCH-FIX-UPSTREAM fix largefile support
Patch2:         sphinxbase-largefile.patch
# PATCH-FIX-UPSTREAM initialize a variable
Patch3:         sphinxbase-uninit.patch
# PATCH-FIX-UPSTREAM boo#1127564
Patch4:         workaround-gcc-issue-on-i586.patch
Patch5:         use-python3.patch
BuildRequires:  alsa-devel
BuildRequires:  bison
BuildRequires:  doxygen
BuildRequires:  fdupes
BuildRequires:  libsndfile-devel
BuildRequires:  pkgconfig
BuildRequires:  python-rpm-macros
BuildRequires:  python3-Cython
BuildRequires:  python3-devel
Requires(post): update-alternatives
Requires(postun):update-alternatives
%if 0%{?suse_version} <= 1210
BuildRequires:  liblapack3
%else
BuildRequires:  lapack-devel
%endif

%description
CMU Sphinx toolkit is a speech recognition tool and has a number of packages for
different tasks and applications.

%package -n libsphinxbase1
Summary:        Sphinxbase speech recognizer library
Group:          System/Libraries

%description -n libsphinxbase1
CMU Sphinx toolkit is a speech recognition tool and has a number of packages for
different tasks and applications.

%package -n libsphinxad0
Summary:        Sphinxbase speech recognizer library
Group:          System/Libraries

%description -n libsphinxad0
CMU Sphinx toolkit is a speech recognition tool and has a number of packages for
different tasks and applications.

%package devel
Summary:        Headers for support library required by Pocketsphinx
Group:          Development/Libraries/C and C++
Requires:       alsa-devel
Requires:       lapack-devel
Requires:       libsndfile-devel
Requires:       libsphinxad0 = %{version}-%{release}
Requires:       libsphinxbase1 = %{version}-%{release}
Conflicts:      sphinxbase5-devel

%description devel
devel files for %{name}-%{version}

CMU Sphinx toolkit is a speech recognition tool and has a number of packages for
different tasks and applications.

%package -n python3-sphinxbase
Summary:        Python3 bindings for sphinxbase
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
Conflicts:      python3-pocketsphinx-python <= 0.1.3
Conflicts:      python3-sphinxbase5

%description -n python3-sphinxbase
Python3 bindings for %{name}-%{version}

CMU Sphinx toolkit is a speech recognition tool and has a number of packages for
different tasks and applications.

%prep
%setup -q
%patch0 -p1
%patch1
%patch2
%patch3
%ifarch i586
%patch4 -p1
%endif
%patch5 -p1
# It has to be regenerated by cython
rm python/sphinxbase.c
sed -ie "s,\#\!%{_bindir}/env perl,#!%{_bindir}/perl," src/sphinx_lmtools/sphinx_lm_sort

%build
%configure --disable-static --with-python=%{_bindir}/python3
%make_build

%install
%make_install
find %{buildroot} -type f -name "*.la" -delete -print
%fdupes %{buildroot}

# Prepare for alternatives
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for binary in sphinx_cepview sphinx_fe sphinx_jsgf2fsg sphinx_lm_convert \
              sphinx_lm_eval sphinx_pitch ; do
    mv %{buildroot}%{_bindir}/$binary %{buildroot}%{_bindir}/$binary-%{version}
    ln -s %{_sysconfdir}/alternatives/$binary %{buildroot}%{_bindir}/$binary
done

%ifarch x86_64 i586
%check
%make_build check
%endif

%post
update-alternatives --install %{_bindir}/sphinx_pitch sphinx_pitch %{_bindir}/sphinx_pitch-%{version} 10 \
  --slave %{_bindir}/sphinx_cepview sphinx_cepview %{_bindir}/sphinx_cepview-%{version} \
  --slave %{_bindir}/sphinx_fe sphinx_fe %{_bindir}/sphinx_fe-%{version} \
  --slave %{_bindir}/sphinx_jsgf2fsg sphinx_jsgf2fsg %{_bindir}/sphinx_jsgf2fsg-%{version} \
  --slave %{_bindir}/sphinx_lm_convert sphinx_lm_convert %{_bindir}/sphinx_lm_convert-%{version} \
  --slave %{_bindir}/sphinx_lm_eval sphinx_lm_eval %{_bindir}/sphinx_lm_eval-%{version}

%postun
if [ ! -f %{_bindir}/sphinx_pitch ]; then
    update-alternatives --remove sphinx_pitch %{_bindir}/sphinx_pitch-%{version}
fi

%post   -n libsphinxad0 -p /sbin/ldconfig
%postun -n libsphinxad0 -p /sbin/ldconfig
%post   -n libsphinxbase1 -p /sbin/ldconfig
%postun -n libsphinxbase1 -p /sbin/ldconfig

%files
%doc AUTHORS ChangeLog README NEWS
%license COPYING
%ghost %{_sysconfdir}/alternatives/sphinx_cepview
%ghost %{_sysconfdir}/alternatives/sphinx_fe
%ghost %{_sysconfdir}/alternatives/sphinx_jsgf2fsg
%ghost %{_sysconfdir}/alternatives/sphinx_lm_convert
%ghost %{_sysconfdir}/alternatives/sphinx_lm_eval
%ghost %{_sysconfdir}/alternatives/sphinx_pitch
%{_bindir}/sphinx_cepview*
%{_bindir}/sphinx_fe*
%{_bindir}/sphinx_jsgf2fsg*
%{_bindir}/sphinx_lm_convert*
%{_bindir}/sphinx_lm_eval*
%{_bindir}/sphinx_pitch*
%{_bindir}/sphinx_cont_adseg
%{_bindir}/sphinx_cont_fileseg
%{_bindir}/sphinx_lm_sort

%files -n libsphinxad0
%{_libdir}/libsphinxad.so.*

%files -n libsphinxbase1
%{_libdir}/libsphinxbase.so.*

%files devel
%{_libdir}/libsphinxbase.so
%{_libdir}/libsphinxad.so
%{_libdir}/pkgconfig/sphinxbase.pc
%{_includedir}/sphinxbase/

%files -n python3-sphinxbase
%{python3_sitearch}/SphinxBase-0.8-py%{python3_version}.egg-info
%{python3_sitearch}/sphinxbase*.so

%changelog
openSUSE Build Service is sponsored by