File libzhuyin.spec of Package libzhuyin

#
# spec file for package libzhuyin
#
# Copyright (c) 2014 SUSE LINUX Products 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/
#

Name:           libzhuyin
Version:	0.9.99.20140619
Release:	0
License:	GPL-2.0
Summary:	Library to deal with zhuyin
Url:	https://github.com/libzhuyin/libzhuyin
Group:	System/I18n/Chinese
Source:	%{name}-%{version}.tar.gz
Source1:	http://downloads.sourceforge.net/libzhuyin/models/model8.text.tar.gz
# PATCH-FIX-UPSTREAM marguerite@opensuse.org - no download when build
Patch:		libzhuyin-no-download.patch
# PATCH-FIX-UPSTREAM marguerite@opensuse.org 
# it will use current date eg. /usr/include/libzhuyin-0.9.99.20140716
# Don't do this
Patch1:		libzhuyin-no-random-version-number-includedir.patch
BuildRequires:	fdupes
BuildRequires:	gcc-c++
BuildRequires:	glib2-devel
BuildRequires:	gnome-common
BuildRequires:	libtool
BuildRequires:	db-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
The libzhuyin project aims to provide the algorithms core 
for intelligent sentence-based Chinese zhuyin input methods.

%package tools
Summary:	Tools for libzhuyin
Group:		System/I18n/Chinese
Requires(post):	update-alternatives
Requires(postun):	update-alternatives

%description tools
The libzhuyin project aims to provide the algorithms core
for intelligent sentence-based Chinese zhuyin input methods.

This package provides the tools used to make data files.

%package -n libzhuyin5
Summary:	Runtime libraries for libzhuyin
Group:		System/Libraries
Requires:	libzhuyin-data

%description -n libzhuyin5
The libzhuyin project aims to provide the algorithms core
for intelligent sentence-based Chinese zhuyin input methods.

This package provides the runtime libraries for libzhuyin.

%package data
Summary:	Data files for libzhuyin
Group:		System/I18n/Chinese

%description data
The libzhuyin project aims to provide the algorithms core
for intelligent sentence-based Chinese zhuyin input methods.

This package provides the data files used by libzhuyin to be functional.

%package devel
Summary:	Development headers for libzhuyin
Group:		Development/Libraries/C and C++
Requires:	libzhuyin5 = %{version}
Requires:	libzhuyin-tools = %{version}

%description devel
The libzhuyin project aims to provide the algorithms core
for intelligent sentence-based Chinese zhuyin input methods.

This package provides the development headers for libzhuyin project.

%prep
%setup -q
%patch -p1
%patch1 -p1
cp -r %{SOURCE1} data
pushd data &> /dev/null
tar -xf model8.text.tar.gz
popd &> /dev/null
./autogen.sh

%build
%configure --prefix=%{_prefix} --libdir=%{_libdir}
make %{?_smp_mflags}

%install
%make_install

# update-alternatives
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for alt in gen_binary_files gen_unigram import_interpolation ; do
	mv %{buildroot}%{_bindir}/${alt} %{buildroot}%{_bindir}/${alt}-zhuyin
	mv %{buildroot}%{_mandir}/man1/${alt}.1 %{buildroot}%{_mandir}/man1/${alt}-zhuyin.1
	touch %{buildroot}%{_sysconfdir}/alternatives/${alt}
	touch %{buildroot}%{_sysconfdir}/alternatives/${alt}.1.gz
	ln -sf %{_sysconfdir}/alternatives/${alt} %{buildroot}%{_bindir}/${alt}
	ln -sf %{_sysconfdir}/alternatives/${alt}.1.gz %{buildroot}%{_mandir}/man1/
done

rm -rf %{buildroot}%{_libdir}/%{name}.{a,la}

%fdupes %{buildroot}

%post -n libzhuyin5 -p /sbin/ldconfig

%postun -n libzhuyin5 -p /sbin/ldconfig

%post tools
update-alternatives \
	--install %{_bindir}/gen_binary_files gen_binary_files %{_bindir}/gen_binary_files-zhuyin 30 \
	--slave %{_bindir}/gen_unigram gen_unigram %{_bindir}/gen_unigram-zhuyin \
	--slave %{_bindir}/import_interpolation import_interpolation %{_bindir}/import_interpolation-zhuyin \
	--slave %{_mandir}/man1/gen_binary_files.1.gz gen_binary_files.1.gz %{_mandir}/man1/gen_binary_files-zhuyin.1.gz \
	--slave %{_mandir}/man1/gen_unigram.1.gz gen_unigram.1.gz %{_mandir}/man1/gen_unigram-zhuyin.1.gz \
	--slave %{_mandir}/man1/import_interpolation.1.gz import_interpolation.1.gz %{_mandir}/man1/import_interpolation-zhuyin.1.gz

%postun tools
if [ $1 -eq 0 ] ; then
	update-alternatives --remove gen_binary_files %{_bindir}/gen_binary_files-zhuyin
fi

%files -n libzhuyin5
%defattr(-,root,root)
%doc AUTHORS ChangeLog README COPYING
%dir %{_libdir}/%{name}
%{_libdir}/libzhuyin.so.5
%{_libdir}/libzhuyin.so.5.0.0
%{_mandir}/man1/%{name}.1.gz

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

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

%files tools
%defattr(-,root,root)
%{_bindir}/gen_binary_files
%{_bindir}/gen_unigram
%{_bindir}/import_interpolation
%{_bindir}/gen_binary_files-zhuyin
%{_bindir}/gen_unigram-zhuyin
%{_bindir}/import_interpolation-zhuyin
%{_mandir}/man1/gen_binary_files.1.gz
%{_mandir}/man1/gen_unigram.1.gz
%{_mandir}/man1/import_interpolation.1.gz
%{_mandir}/man1/gen_binary_files-zhuyin.1.gz
%{_mandir}/man1/gen_unigram-zhuyin.1.gz
%{_mandir}/man1/import_interpolation-zhuyin.1.gz
%ghost %{_sysconfdir}/alternatives/gen_binary_files
%ghost %{_sysconfdir}/alternatives/gen_unigram
%ghost %{_sysconfdir}/alternatives/import_interpolation
%ghost %{_sysconfdir}/alternatives/gen_binary_files.1.gz
%ghost %{_sysconfdir}/alternatives/gen_unigram.1.gz
%ghost %{_sysconfdir}/alternatives/import_interpolation.1.gz

%changelog

openSUSE Build Service is sponsored by