File uim.spec of Package uim

# spec file for package uim
# Copyright (c) 2018 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

%define is_gnome3 (0%{?suse_version} > 1140)
%define build_applet (0%{?suse_version} < 1310)

Name:           uim
Version:        1.8.8
Release:        0
Summary:        A multilingual input method framework
License:        BSD-3-Clause and LGPL-2.1+ and (BSD-3-Clause or LGPL-2.0)
Group:          System/I18n/Japanese
Source1:        suse-start-uim.el
Source2:        xemacs-auto-autoloads.el
Source3:        etc-x11-xim.d-uim
Source4:        baselibs.conf
#Source5:        uim-pixmap.tar.gz
Patch1:         uim-fix-crash-in-firefox.diff
Patch2:         uim-fix-multiple_declaration.diff
#Patch3:         fix-for-sles-qhash-incomplete-type.patch
#Patch4:         libgcroots-aarch64.patch
#Patch5:         90_close_socket_on_exec.patch
#Patch6:         95_sock_cloexec.patch
#Patch7:         workaround_for_gtk3_higher_3.7.8.patch
#Patch8:         qt5-disable-debug-flag.patch
#Patch9:         uim-emacs-utf8.patch
Patch10:        git_772620b.patch
Patch11:        fix-caret-color.patch
Patch12:        fix-qt5_applications_segfault.patch
Patch13:        fix-gtk-suppress.patch
Patch14:        fix-fep-hang_on.patch
#BuildRequires:  xz
BuildRequires:  anthy-devel
BuildRequires:  canna-devel
BuildRequires:  emacs-x11
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  automake
BuildRequires:  cmake
%if %{build_applet}
BuildRequires:  gnome-panel-devel
BuildRequires:  gtk2-devel
BuildRequires:  intltool
BuildRequires:  libedit-devel
BuildRequires:  libexpat-devel
%if 0%{?suse_version} <= 1500
BuildRequires:  libqt4-devel
BuildRequires:  m17n-lib-devel
BuildRequires:  ncurses-devel
BuildRequires:  sqlite3-devel
BuildRequires:  perl-XML-Parser
BuildRequires:  pkg-config
BuildRequires:  update-desktop-files
BuildRequires:  hicolor-icon-theme
#BuildRequires:  rsvg-view
BuildRequires:  xemacs
BuildRequires:  asciidoc
#BuildRequires:  ruby
BuildRequires:  pkgconfig(gdk-x11-2.0)
BuildRequires:  pkgconfig(gtk+-2.0)
BuildRequires:  pkgconfig(gtk+-3.0)
BuildRequires:  pkgconfig(libnotify)
BuildRequires:  pkgconfig(x11)
Recommends:     %{name}-gtk2 = %{version}
Recommends:     %{name}-gtk3 = %{version}
%if 0%{?suse_version} <= 1500
Recommends:     %{name}-qt4 = %{version}
BuildRequires:  libicu-devel
BuildRequires:  libxkbcommon-devel
BuildRequires:  libqt5-qtbase-devel
BuildRequires:  libqt5-qtbase-private-headers-devel
BuildRequires:  libqt5-qtx11extras-devel
BuildRequires:  libQt5Core-devel
BuildRequires:  libQt5Widgets-devel
Recommends:     %{name}-qt5 = %{version}

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires(pre):  %{_bindir}/touch
%if ! (%{build_applet})
# If we can't build the applet, we need to ensure we can cleanly 'upgrade' Obsoleting the applet.
Obsoletes:      %{name}-applet-gnome <= %{version}

Uim is a multilingual input method framework. Uim's goal is to
provide simple, easily extensible and high code-quality input 
method development platform, and useful input method environment 
for users of desktop and embedded platforms.

%package devel
Summary:        Include Files and Libraries mandatory for Development
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description devel
Include Files and Libraries mandatory for Development with uim.

%package gtk2
Summary:        GTK2 IM Module for UIM
Group:          System/I18n/Japanese
Requires:       %{name} = %{version}

%description gtk2
Contains GTK+2.0 IM module for uim

%package gtk3
Summary:        GTK3 IM Module for UIM
Group:          System/I18n/Japanese
Requires:       %{name} = %{version}

%description gtk3
Contains GTK+3.0 IM module for uim

%if %{build_applet}
%package applet-gnome
Summary:        GNOME applet for uim
Group:          System/I18n/Japanese
Requires:       %{name} = %{version}
Obsoletes:      uim-applet < %{version}
Provides:       uim-applet = %{version}

%description applet-gnome
GNOME applet for uim

%if 0%{?suse_version} <= 1500
%package qt4
Summary:        Qt4 input module plugin for uim
Group:          System/I18n/Japanese
Requires:       %{name} = %{version}

%description qt4
Contains Qt4 input module plugin for uim

%package qt5
Summary:        Qt5 input module plugin for uim
Group:          System/I18n/Japanese
Requires:       %{name} = %{version}

%description qt5
Contains Qt5 input module plugin for uim

%setup0 -q
%patch1 -p1
%patch2 -p0
#%patch3 -p1
#%patch4 -p1
#%patch5 -p1
#%patch6 -p1
#%patch7 -p1
#%patch8 -p1
#%patch9 -p1

cp emacs/README README.emacs
iconv -f euc-jp -t utf-8 < emacs/README.ja > README.ja.emacs
# hack to fix incompatibility of gtk-query-immodules-2.0 (bnc#845860)
%if %suse_version < 1310
sed -i \
    -e's@\(gtk-query-immodules-2.0-64\) --update-cache@\1 > <prefix>%{_sysconfdir}/gtk-2.0/gtk64.immodules@g' \
    -e's@\(gtk-query-immodules-2.0\) --update-cache@\1 > <prefix>%{_sysconfdir}/gtk-2.0/gtk.immodules@g' \

#export RUBYOPT=-EUTF-8
export CFLAGS="$CFLAGS -fcommon"
%configure --disable-static --with-pic \
	--libexecdir=%{_prefix}/lib/uim \
	--with-anthy-utf8 \
%if 0%{?suse_version} <= 1500    
	--with-qt4 \
	--with-qt4-immodule \
	--with-qt5 \
	--with-qt5-immodule \
	--enable-kde-applet \
	--enable-openssl \
	--enable-dict \

make %{?_smp_mflags}

rm -f %{buildroot}%{_includedir}/gcroots.h
rm -f %{buildroot}%{_libdir}/pkgconfig/gcroots.pc
# this file is generated by "uim-module-manager".
# touch it here to make sure that it is in the file list of the
# package, then it will be deleted when the package is uninstalled:
touch %{buildroot}%{_datadir}/uim/modules
mkdir -p %{buildroot}%{_sysconfdir}/X11/xim.d/ja
install -m 644 $RPM_SOURCE_DIR/etc-x11-xim.d-uim \
pushd  %{buildroot}%{_sysconfdir}/X11/xim.d/ja
    ln -s ../uim 60-uim
# GNU Emacs:
install -m 644 $RPM_SOURCE_DIR/suse-start-uim.el %{buildroot}%{_datadir}/emacs/site-lisp/
pushd %{buildroot}%{_datadir}/emacs/site-lisp/uim-el
    for i in $(find . -name "*.el")
        emacs -no-site-file -q -batch -eval '(setq load-path (cons "." load-path))' -f batch-byte-compile $i
# XEmacs
mkdir -p %{buildroot}%{_datadir}/xemacs/site-packages/lisp/uim-el
install -m 644 emacs/*.el %{buildroot}%{_datadir}/xemacs/site-packages/lisp/uim-el
pushd %{buildroot}%{_datadir}/xemacs/site-packages/lisp/uim-el
    for i in $(find . -name "*.el")
        xemacs -no-site-file -q -batch -eval '(setq load-path (cons "." load-path))' -f batch-byte-compile $i
install -m 644 $RPM_SOURCE_DIR/xemacs-auto-autoloads.el \
# replace buildroot in comments in .elc files by spaces with the same total length:
BUILD_ROOT_REPLACEMENT=$(echo %{buildroot} | tr [:print:] ' ')
for i in $(find %{buildroot} -name "*.elc")
    perl -pi -e "s|(;;; from file )%{buildroot}(%{_datadir}/xemacs/site-packages/.*)|\1BUILD_ROOT_REPLACEMENT\2|" $i
    perl -pi -e "s|(;;; from file )%{buildroot}(%{_datadir}/emacs/site-lisp/.*)|\1BUILD_ROOT_REPLACEMENT\2|" $i
%find_lang uim
%if 0%{?suse_version} > 1100
touch uim-chardict-qt.lang
%find_lang uim-chardict-qt
%suse_update_desktop_file uim System SystemSetup
find %{buildroot} -name "*.scm" \
    | grep -E -v "installed-modules.scm|loader.scm" \
    | sort | uniq | perl -p -e "s|%{buildroot}||" >> uim.lang
%if 0%{?suse_version} > 1020
%fdupes %{buildroot}%{_prefix}/share
find %{buildroot} -type f -name "*.la" -delete -print
rm -f doc/Makefile*

# uim/pixmaps
#rm -r %{buildroot}%{_datadir}/uim/pixmaps
#cp -a -r ./uim-pixmap/pixmaps %{buildroot}%{_datadir}/uim/

# register uim modules to uim. This will change the files:
#     %{_datadir}/uim/installed-modules.scm
#     %{_datadir}/uim/loader.scm
uim-module-manager --register \
    ajax-ime anthy anthy-utf8 byeoru canna elatin  hangul  ipa-x-sampa \
    latin m17nlib pyload skk tcode trycode tutcode viqr

%postun -p /sbin/ldconfig

%post gtk2

%postun gtk2

%post gtk3

%postun gtk3

%files -f uim.lang
%defattr(-, root, root)
%doc doc
%dir %{_sysconfdir}/X11/xim.d/
# autogenerated by uim-module-manager:
%ghost %{_datadir}/uim/installed-modules.scm
%ghost %{_datadir}/uim/loader.scm
%ghost %{_datadir}/uim/modules
%dir %{_libdir}/uim
%if "%{_libdir}" != "%{_prefix}/lib"
%dir %{_prefix}/lib/uim
%dir %{_libdir}/uim/plugin/
%doc %{_mandir}/man1/*.1.gz

%files devel
%defattr(-, root, root)

%files gtk2
%defattr(-, root, root)

%files gtk3
%defattr(-, root, root)

%if %{build_applet}
%files applet-gnome
%defattr(-, root, root)
%if %{is_gnome3}

%if 0%{?suse_version} <= 1500
%files qt4 -f uim-chardict-qt.lang
%defattr(-, root, root)

%files qt5 -f uim-chardict-qt.lang
%defattr(-, root, root)