Blob Blame History Raw
Name:           openfst
Version:        1.4.1
Release:        3%{?dist}
Summary:        Weighted finite-state transducer library

Group:          Development/Libraries
License:        ASL 2.0
URL:            http://www.openfst.org/
Source0:        http://www.openfst.org/twiki/pub/FST/FstDownload/%{name}-%{version}.tar.gz
Source1:        http://openfst.cs.nyu.edu/twiki/pub/Contrib/OpenFstBashComp/openfstbc
# Man pages written by Jerry James.  The text of the man pages is lifted from
# the sources, so it is under the same copyright and license.  In short, I
# contributed the formatting, but none of the text (with a few very small
# exceptions).
Source2:        openfst-man.tar.xz

%description
OpenFst is a library for constructing, combining, optimizing, and
searching weighted finite-state transducers (FSTs).  Weighted
finite-state transducers are automata where each transition has an input
label, an output label, and a weight.  The more familiar finite-state
acceptor is represented as a transducer with each transition's input and
output label equal.  Finite-state acceptors are used to represent sets
of strings (specifically, regular or rational sets); finite-state
transducers are used to represent binary relations between pairs of
strings (specifically, rational transductions).  The weights can be used
to represent the cost of taking a particular transition.

FSTs have key applications in speech recognition and synthesis, machine
translation, optical character recognition, pattern matching, string
processing, machine learning, information extraction and retrieval among
others.  Often a weighted transducer is used to represent a
probabilistic model (e.g., an n-gram model, pronunciation model).  FSTs
can be optimized by determinization and minimization, models can be
applied to hypothesis sets (also represented as automata) or cascaded by
finite-state composition, and the best results can be selected by
shortest-path algorithms.

%package devel
Summary:        Development files for OpenFst
Group:          Development/Libraries
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description devel
This package includes the necessary files to develop systems with
OpenFst.

%package tools
Summary:        Command-line tools for working with FSTs
Group:          Applications/Multimedia
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description tools
This package contains command-line tools that give access to OpenFst
functionality.

%prep
%setup -q
%setup -q -T -D -a 2

# Add missing linkage, remove unnecessary linkage, and make sure libraries
# are built in the correct order so linkage is possible.
sed -e 's|^LIBS =|LIBS = ../lib/libfst.la|' -i src/script/Makefile.in
sed -e 's|^LIBS =|LIBS = ../../lib/libfst.la|' \
    -i src/extensions/compact/Makefile.in
sed -e 's|^LIBS =|LIBS = ../../lib/libfst.la|' \
    -i src/extensions/const/Makefile.in
sed -e 's|^LIBS =|LIBS = ../../lib/libfst.la|' \
    -i src/extensions/linear/Makefile.in
sed -e 's|^LIBS =|LIBS = ../../lib/libfst.la|' \
    -i src/extensions/lookahead/Makefile.in
sed -e 's|^LIBS =|LIBS = ../../lib/libfst.la|' \
    -e 's|^\(libfstpdtscript_la_LIBADD =\).*|\1 ../../script/libfstscript.la|' \
    -i src/extensions/pdt/Makefile.in
sed -e 's|^\(libfstfarscript_la_LIBADD =\).*|\1 ../../lib/libfst.la libfstfar.la|' \
    -e 's|^\(@HAVE_SCRIPT_TRUE@libfst_LTLIBRARIES =\).*|\1 libfstfar.la libfstfarscript.la|' \
    -i src/extensions/far/Makefile.in

# Allow use of GNU extensions
sed -i 's/-std=c++0x/-std=gnu++11/' configure

%build
%configure --enable-bin --enable-compact-fsts --enable-const-fsts \
  --enable-far --enable-linear-fsts --enable-lookahead-fsts \
  --enable-ngram-fsts --enable-pdt LIBS="-ldl"

# 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

# FIXME: The 1.4.1 release broke %%{?_smp_mflags}
make

%install
make install DESTDIR=%{buildroot}

# Get rid of libtool files
find %{buildroot}%{_libdir} -name '*.la' | xargs rm -f

# Install the bash completion file
mkdir -p %{buildroot}%{_datadir}/bash-completion/completions
cp -p %{SOURCE1} %{buildroot}%{_datadir}/bash-completion/completions/fstmap
for fil in arcsort closure compile compose concat connect convert determinize \
    difference disambiguate draw encode epsnormalize equal equivalent info \
    intersect invert linear loglinearapply minimize print project prune push \
    randgen relabel replace reverse reweight rmepsilon shortestdistance \
    shortestpath symbols synchronize topsort union; do
  ln -s fstmap %{buildroot}%{_datadir}/bash-completion/completions/fst$fil
done

# Install the man pages
mkdir -p %{buildroot}%{_mandir}/man1
cd man
for f in *.1; do
  sed -e "s/@VERSION@/%{version}/" -e "s/@DATE@/June 2012/" $f > \
    %{buildroot}%{_mandir}/man1/$f
  touch -r $f %{buildroot}%{_mandir}/man1/$f
done
cd ..

# Move libraries that are actually used by binaries out of the private dir.
# Leave symbolic links behind, since they are dlopen()ed.

# libfstfar and libfstfarscript
mv %{buildroot}%{_libdir}/fst/libfstfar* %{buildroot}%{_libdir}
ln -s ../libfstfar.so %{buildroot}%{_libdir}/fst/libfstfar.so
ln -s ../libfstfar.so.1 %{buildroot}%{_libdir}/fst/libfstfar.so.1
ln -s ../libfstfarscript.so %{buildroot}%{_libdir}/fst/libfstfarscript.so
ln -s ../libfstfarscript.so.1 %{buildroot}%{_libdir}/fst/libfstfarscript.so.1

# libfstlinearscript
mv %{buildroot}%{_libdir}/fst/libfstlinearscript* %{buildroot}%{_libdir}
ln -s ../libfstlinearscript.so %{buildroot}%{_libdir}/fst/libfstlinearscript.so
ln -s ../libfstlinearscript.so.1 \
      %{buildroot}%{_libdir}/fst/libfstlinearscript.so.1

# libfstpdtscript
mv %{buildroot}%{_libdir}/fst/libfstpdtscript* %{buildroot}%{_libdir}
ln -s ../libfstpdtscript.so %{buildroot}%{_libdir}/fst/libfstpdtscript.so
ln -s ../libfstpdtscript.so.1 %{buildroot}%{_libdir}/fst/libfstpdtscript.so.1

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%doc AUTHORS COPYING NEWS README
%dir %{_libdir}/fst
%{_libdir}/fst/*.so.*
%{_libdir}/*.so.*

%files devel
%{_includedir}/fst
%{_libdir}/fst/*.so
%{_libdir}/*.so

%files tools
%{_bindir}/*
%{_mandir}/man1/*
%{_datadir}/bash-completion/completions/*

%changelog
* Tue Jul 22 2014 Jerry James <loganjerry@gmail.com> - 1.4.1-3
- Fix libfstlinearscript linking
- Update bash completion file list

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Thu May  1 2014 Jerry James <loganjerry@gmail.com> - 1.4.1-1
- New upstream version

* Mon Nov  4 2013 Jerry James <loganjerry@gmail.com> - 1.3.4-1
- New upstream version

* Mon Jul 29 2013 Jerry James <loganjerry@gmail.com> - 1.3.3-3
- Fix broken symlinks (bz 989685)

* Fri Mar 29 2013 Jerry James <loganjerry@gmail.com> - 1.3.3-2
- Move bash completion script to _datadir and link once per supported binary

* Wed Feb  6 2013 Jerry James <loganjerry@gmail.com> - 1.3.3-1
- New upstream version

* Mon Aug  6 2012 Jerry James <loganjerry@gmail.com> - 1.3.2-1
- New upstream version

* Fri Jul 20 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Mon Apr 23 2012 Jerry James <loganjerry@gmail.com> - 1.3.1-2
- Rebuild for new icu

* Mon Mar  5 2012 Jerry James <loganjerry@gmail.com> - 1.3.1-1
- New upstream version

* Tue Feb 28 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.10-3
- Rebuilt for c++ ABI breakage

* Fri Jan  6 2012 Jerry James <loganjerry@gmail.com> - 1.2.10-2
- Rebuild for GCC 4.7

* Mon Jan  2 2012 Jerry James <loganjerry@gmail.com> - 1.2.10-1
- New upstream version

* Tue Dec  6 2011 Jerry James <loganjerry@gmail.com> - 1.2.9-1
- New upstream version
- Drop upstreamed format patch

* Wed Nov  9 2011 Jerry James <loganjerry@gmail.com> - 1.2.8-1
- New upstream version
- Drop unnecessary spec file elements (%%clean, etc.)

* Thu Sep  8 2011 Jerry James <loganjerry@gmail.com> - 1.2.7-3
- Rebuild for new icu.

* Wed May 18 2011 Jerry James <loganjerry@gmail.com> - 1.2.7-2
- Fix incorrect target order in far extension Makefile.  Thanks to Dan HorĂ¡k
  for the analysis.

* Wed Mar  2 2011 Jerry James <loganjerry@gmail.com> - 1.2.7-1
- Initial RPM