File libpinyin.spec of Package libpinyin

#
# spec file for package libpinyin
#
# Copyright (c) 2017 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 sover 10
Name:           libpinyin
Version:        1.7.0
Release:        0
Summary:        Intelligent Pinyin IME
License:        GPL-3.0+
Group:          System/I18n/Chinese
Url:            https://github.com/libpinyin/libpinyin
Source:         %{name}-%{version}.tar.gz
Source1:        http://jaist.dl.sourceforge.net/project/libpinyin/models/model14.text.tar.gz
Source99:       baselibs.conf
# PATCH-FIX-OPENSUSE marguerite@opensuse.org - avoid download at buildtime
Patch0:         libpinyin-avoid_download_at_buildtime.patch
# PATCH-FIX-UPSTRAEM hillwood@opensuse.org - fix mapper for double pinyin
Patch1:         libpinyin-fix_double_pinyin.patch
# PATCH-FIX-UPSTREAM marguerite@opensuse.org - AX_CXX_COMPILE_CXX([11])
# breaks Leap 42.1 builds while of no actual use
Patch2:         libpinyin-1.7.0-no-AX_CXX_COMPILE_STDCXX_11.patch
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  glib2-devel
BuildRequires:  gnome-common
BuildRequires:  intltool
BuildRequires:  libtool
BuildRequires:  xz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} >= 1140
BuildRequires:  libdb-4_8-devel
%else
BuildRequires:  libdb-4_5-devel
%endif

%description
libpinyin is an intelligent (and universal) sentence-based Pinyin IME
backend supporting many language models and frontends.

%package -n %{name}%{sover}
Summary:        Intelligent Pinyin IME
Group:          System/Libraries
Requires:       %{name}-data

%description -n %{name}%{sover}
libpinyin is a staging joint effort of many Chinese Pinyin IME development
teams. It is an intelligent (and universal) sentence-based Pinyin IME backend
supporting many language models and frontends.

This package provides runtime library for libpinyin.

%package data
Summary:        Data files for the libpinyin IME
Group:          System/I18n/Chinese

%description data
libpinyin is an intelligent (and universal) sentence-based Pinyin IME
backend supporting many language models and frontends.

This package provides language model table data for libpinyin.

%package devel
Summary:        Development files for the libpinyin IME
Group:          Development/Libraries/C and C++
Requires:       %{name}%{sover} = %{version}
Requires:       %{name}-tools = %{version}

%description devel
libpinyin is an intelligent (and universal) sentence-based Pinyin IME
backend supporting many language models and frontends.

This subpackage contains the development files.

%package tools
Summary:        Tools for libpinyin
Group:          System/I18n/Chinese

%description tools
libpinyin is an intelligent (and universal) sentence-based Pinyin IME
backend supporting many language models and frontends.

This package provides the tools used to make data files.

%prep
%setup -q
cp -r %{SOURCE1} data/
%patch0 -p1
%patch1 -p1
%patch2 -p1
NOCONFIGURE=1 ./autogen.sh

%build
%configure --disable-static
make %{?_smp_mflags}

%install
make DESTDIR=%{buildroot} install %{?_smp_mflags}
find %{buildroot} -type f -name "*.la" -delete -print
%fdupes %{buildroot}/%{_prefix}

%post -n %{name}%{sover} -p /sbin/ldconfig

%postun -n %{name}%{sover} -p /sbin/ldconfig

%files -n %{name}%{sover}
%defattr(-,root,root)
%doc ChangeLog AUTHORS COPYING README
%{_libdir}/%{name}.so.*
%{_mandir}/man1/libpinyin.1.gz

%files data
%defattr(-,root,root)
%{_libdir}/%{name}

%files tools
%defattr(-,root,root)
%{_bindir}/gen_binary_files
%{_bindir}/gen_unigram
%{_bindir}/import_interpolation

%files devel
%defattr(-,root,root)
%{_includedir}/%{name}-*/
%{_libdir}/%{name}.so
%{_libdir}/pkgconfig/%{name}.pc

%changelog