File openfst.spec of Package openfst
# spec file for package openfst
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#
%define soname 0
Name: openfst
Version: 1.5.0
Release: 0
Summary: Weighted finite-state transducer library
License: Apache-2.0
Group: Development/Tools/Other
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
BuildRequires: gcc-c++
BuildRequires: pkgconfig(zlib)
BuildRequires: python-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
OpenFst is a library for constructing, combining, optimizing and
searching weighted finite-state transducers (FSTs).
%package -n python-%{name}
Summary: Python interface to %{name}
Group: Development/Languages/Python
Requires: %{name} = %{version}-%{release}
%description -n python-%{name}
This package contains a python interface to OpenFst.
%package devel
Summary: Development files for OpenFst
License: Apache-2.0
Group: Development/Libraries/C and C++
Requires: %{name} = %{version}-%{release}
%description devel
OpenFst is a library for constructing, combining, optimizing and
searching weighted finite-state transducers (FSTs).
%package tools
Summary: Command-line tools for working with FSTs
Group: Development/Tools/Other
Requires: %{name} = %{version}-%{release}
%description tools
OpenFst is a library for constructing, combining, optimizing and
searching weighted finite-state transducers (FSTs).
This package contains command-line tools that give access to OpenFst
functionality.
%prep
%setup -q
# 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 \
src/extensions/const/Makefile.in \
src/extensions/linear/Makefile.in \
src/extensions/lookahead/Makefile.in \
src/extensions/ngram/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++11/-std=gnu++11/' configure
%build
export LDFLAGS="$RPM_LD_FLAGS -Wl,-rpath=%{_libdir}/fst -ldl"
%configure --enable-bin --enable-compact-fsts --enable-compress \
--enable-const-fsts --enable-far --enable-linear-fsts \
--enable-lookahead-fsts --enable-mpdt --enable-ngram-fsts --enable-pdt \
--enable-python
# 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
# Fix python install directory
sed -i 's|^\(pythondir = \).*|\1%{python_sitearch}|' \
src/extensions/python/Makefile
# FIXME: The 1.4.1 release broke parallel building # %%{?_smp_mflags}
make
%install
make install DESTDIR=%{buildroot}
# Get rid of libtool files
find %{buildroot}/%{_libdir} -name '*.la' -delete
find %{buildroot}/%{python_sitearch} -name '*.la' -delete
# 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 compress concat connect convert \
determinize difference disambiguate draw encode epsnormalize equal \
equivalent info intersect invert isomorphic linear loglinearapply \
minimize print project prune push randgen randmod relabel replace reverse \
reweight rmepsilon shortestdistance shortestpath symbols synchronize \
topsort union; do
ln -s fstmap %{buildroot}%{_datadir}/bash-completion/completions/fst$fil
done
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root)
%doc AUTHORS COPYING NEWS README
%dir %{_libdir}/fst
%{_libdir}/fst/*.so.*
%{_libdir}/*.so.*
%files devel
%defattr(-,root,root)
%{_includedir}/fst
%{_libdir}/fst/*.so
%{_libdir}/*.so
%files tools
%defattr(-,root,root)
%{_bindir}/*
#%{_mandir}/man1/*
%dir %{_datadir}/bash-completion/completions/
%{_datadir}/bash-completion/completions/*
%files -n python-%{name}
%defattr(-,root,root)
%{python_sitearch}/fst.so
%changelog