# TODO: fixes scons to generate debug information
#%%global debug_package %{nil}

%define _xinputconf %{_sysconfdir}/X11/xinit/xinput.d/xsunpinyin.conf
%define gitdate 20190805

Name:		sunpinyin
Version:	3.0.0
Release:	2
Summary:	A statistical language model based Chinese input method engine
License:	LGPL-2.0-only or CDDL-1.0 or CC-BY-SA-3.0
Obsoletes:	%{name}-data-le
Obsoletes:	%{name}-data-be
URL:		http://code.google.com/p/sunpinyin/
Source0:	%{name}-%{gitdate}.tar.xz
Source2:	http://downloads.sourceforge.net/project/open-gram/lm_sc.3gm.arpa-20140820.tar.bz2
Source3:	http://downloads.sourceforge.net/project/open-gram/dict.utf8-20131214.tar.bz2
Patch0: 	sunpinyin-use-python3.patch
Patch1: 	sunpinyin-fixes-scons.patch
BuildRequires:  gcc-c++, sqlite-devel, gettext, python3-scons, perl(Pod::Man), python3-devel

%description
Sunpinyin is an input method engine for Simplified Chinese. It is an SLM based
IM engine, and features full sentence input.

SunPinyin has been ported to various input method platforms and operating 
systems. The 2.0 release currently supports iBus, XIM, and Mac OS X. 

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

%description devel
The %{name}-devel package contains libraries and header files that allows user
to write their own front-end for sunpinyin.

%prep
%setup -q -n %{name}-%{gitdate}
%patch0 -p1 -b .python3
%patch1 -p1 -b .scons

mkdir -p raw
cp %SOURCE2 raw
cp %SOURCE3 raw
pushd raw
tar xvf lm_sc.3gm.arpa-20140820.tar.bz2
tar xvf dict.utf8-20131214.tar.bz2
popd

# fix strip
sed -i 's|-Wall|-Wall -s -g|' SConstruct SConstruct.python3 SConstruct.scons
sed -i 's|-std=c++11|-std=c++11 -s -g|' SConstruct SConstruct.python3 SConstruct.scons

%build
# export CFLAGS, CXXFLAGS, LDFLAGS, ...
%configure || :

scons %{?_smp_mflags} --prefix=%{_prefix} --libdir=%{_libdir} --datadir=%{_datadir}
export PATH=`pwd`/src:$PATH
pushd raw
ln -sf ../doc/SLM-inst.mk Makefile
make %{?_smp_mflags} VERBOSE=1
popd

%install
scons %{?_smp_mflags} --prefix=%{_prefix} --libdir=%{_libdir} --datadir=%{_datadir} install --install-sandbox=%{buildroot}
pushd raw
make install DESTDIR=%{buildroot} INSTALL="install -p"
popd
install -m0644 AUTHORS TODO %{buildroot}%{_docdir}/%{name}


%ldconfig_scriptlets

%files
%license COPYING *.LICENSE
%{_libdir}/libsunpinyin*.so.*
%{_datadir}/%{name}
%{_bindir}/*
%{_mandir}/man1/*.1.gz
%{_docdir}/%{name}/SLM-*.mk
%{_docdir}/%{name}/README
%{_docdir}/%{name}/AUTHORS
%{_docdir}/%{name}/TODO

%files devel
%{_libdir}/libsunpinyin*.so
%{_libdir}/pkgconfig/sunpinyin*.pc
%{_includedir}/sunpinyin*

%changelog
* Mon Mar 20 2023 liweiganga <liweiganga@uniontech.com> - 3.0.0-2
- feat: fix strip and enable debug
- feat: License compliance rectification

* Tue Dec 22 2020 weidong <weidong@uniontech.com> - 3.0.0-1
- Initial Package
