File sphinxtrain.spec of Package sphinxtrain

# spec file for package sphinxtrain
# Copyright (c) 2014 Malcolm J Lewis <>
# 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

# NOTE: rpmlint complains about "only non-binary in /usr/lib", but some of the
# files there, even though they are not ELF files, are in fact arch-specific.

Name:           sphinxtrain
Version:        1.0.8
Release:        0
Summary:        Acoustic model trainer for CMU's Sphinx tools
License:        GPL-2.0+
Group:          Applications/Multimedia
# This file was accidentally omitted from the upstream source tarball.
Source1:        g2p_train.hpp
#PATCH-FIX-OPENSUSE sphinxtrain-g2p_train-fixes.patch -- Fix new ngram include names and openfst 1.3.3 changes.
Patch0:         sphinxtrain-g2p_train-fixes.patch
BuildRequires:  alsa-devel
BuildRequires:  gcc-c++
BuildRequires:  lapack-devel
BuildRequires:  libngram0-devel
BuildRequires:  libsamplerate-devel
BuildRequires:  libsndfile-devel
BuildRequires:  libtool
BuildRequires:  openfst-devel
#BuildRequires:  perl
BuildRequires:  pkg-config
#BuildRequires:  python-Cython
#BuildRequires:  python-devel
BuildRequires:  python-numpy-devel
#BuildRequires:  python-setuptools
BuildRequires:  python-scipy
BuildRequires:  sphinxbase-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

SphinxTrain is Carnegie Mellon University's open source acoustic model
trainer.  It contains the scripts and instructions necessary for building
models for the CMU Sphinx Recognizer.

%setup -q
%patch0 -p1
# Add an accidentally omitted header file
cp -p %{S:1} src/programs/g2p_train
# Remove spurious-executable-perm  
find python/ -type f -exec chmod a-x {} \;
# Fix "Your file uses  __DATE and __TIME__ this causes the package to rebuild when not needed warning"
# We use the date from the changes file
set_date_time=`date --date "@\`stat --format %Y %{_sourcedir}/%{name}.changes\`" +"%B %Y %H:%M"`
sed -i -e "s/\_\_DATE\_\_,\_\_TIME\_\_/\"$set_date_time\"/g" src/programs/mllr_transform/main.c
sed -i -e "s/\_\_DATE\_\_, \_\_TIME\_\_/\"$set_date_time\"/g" src/programs/bw/main.c
%ifarch x86_64
   sed -i -e "s/lib\//lib64\//g" scripts/sphinxtrain
   sed -i -e "s/lib\//lib64\//g" scripts/000.comp_feat/
   sed -i -e "s/lib\//lib64\//g" scripts/000.comp_feat/
   sed -i -e "s/lib\//lib64\//g" scripts/decode/
   sed -i -e "s/lib\//lib64\//g" scripts/decode/
   sed -i -e "s/lib\//lib64\//g" scripts/decode/

%configure  --enable-static=no \
	    --with-openfst-includes=%{_includedir}/ \
# Get rid of undesirable hardcoded rpaths; also workaround libtool reordering
# -Wl,--as-needed after all the libraries.
sed -e 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' \
    -e 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' \
    -e 's|CC="g..|& -Wl,--as-needed|' \
    -i libtool

make %{?_smp_mflags}

#FIXME Remove for the moment?
rm -rf %{buildroot}%{_libdir}/%{name}/python \
# Remove executable bits set.
find %{buildroot}%{_libdir}/%{name}/scripts/lib -name \*.pm -exec chmod a-x {} \;
find %{buildroot}%{_libdir}/%{name}/scripts/lib -name \*.txt -exec chmod a-x {} \;