File uim.spec of Package uim

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


%define build_gtk3 (%{suse_version} >= 1140)
%define is_gnome3 (%{suse_version} > 1140)

Name:           uim
BuildRequires:  anthy-devel
BuildRequires:  canna-devel
BuildRequires:  emacs-x11
BuildRequires:  emacs-x11
BuildRequires:  gcc-c++
BuildRequires:  intltool
BuildRequires:  libedit-devel
BuildRequires:  libexpat-devel
BuildRequires:  libqt4-devel
BuildRequires:  libtool
BuildRequires:  m17n-lib-devel
BuildRequires:  ncurses-devel
BuildRequires:  perl-XML-Parser
BuildRequires:  pkg-config
%if %suse_version > 1130
BuildRequires:  pkgconfig(gtk+-2.0)
%else
BuildRequires:  gtk2-devel
%endif
%if %build_gtk3
BuildRequires:  pkgconfig(gtk+-3.0)
%endif
BuildRequires:  fdupes
BuildRequires:  gnome-panel-devel
BuildRequires:  kdebase3-devel
BuildRequires:  qt3-devel
BuildRequires:  update-desktop-files
BuildRequires:  xemacs
Version:        1.7.3
Release:        0
# xorg-x11-libXdmcp-devel libgnomeprintui-devel
Summary:        A multilingual input method library
License:        GPL-2.0+
Group:          System/I18n/Japanese
Url:            http://uim.freedesktop.org/wiki/
Source0:        http://uim.googlecode.com/files/uim-%{version}.tar.bz2
Source1:        suse-start-uim.el
Source2:        xemacs-auto-autoloads.el
Source3:        etc-x11-xim.d-uim
Source4:        baselibs.conf
Patch10:        uim-sigscheme-build-fixes.diff
Patch12:        uim-fix-crash-in-firefox.diff
PreReq:         %{_bindir}/touch
Provides:       locale(xorg-x11:ja)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Uim is a multilingual input method library. Uim's project goal is to
provide secure and useful input method for all languages. Currently, it
can input to applications which support gtk+'s immodule or XIM.

%package devel
Summary:        Include Files and Libraries mandatory for Development
Group:          System/I18n/Japanese
Requires:       %{name} = %{version}
Requires:       glibc-devel

%description devel
Include Files and Libraries mandatory for Development.

%package gtk2
Summary:        GTK+2.0 IM module for uim
Group:          System/I18n/Japanese
Requires:       %{name} = %{version}
Provides:       locale(gtk2:ja)
%gtk2_immodule_requires

%description gtk2
GTK+2.0 IM module for uim

%if %{build_gtk3}

%package gtk3
Summary:        GTK+3.0 IM module for uim
Group:          System/I18n/Japanese
Requires:       %{name} = %{version}
Provides:       locale(gtk3:ja)
%gtk3_immodule_requires

%description gtk3
GTK+3.0 IM module for uim
%endif

%package applet-gnome
Summary:        GNOME applet for uim
Group:          System/I18n/Japanese
Requires:       %{name} = %{version}
Obsoletes:      uim-applet
Provides:       uim-applet
Provides:       locale(gnome-libs:ja)

%description applet-gnome
GNOME applet for uim

%package qt3
Summary:        Qt3 input module plugin for uim
Group:          System/I18n/Japanese
Requires:       %{name} = %{version}
Provides:       uim-qt = %{version}
Provides:       locale(qt3:ja)
Obsoletes:      uim-qt

%description qt3
Qt3 input module plugin for uim

%package qt4
Summary:        Qt4 input module plugin for uim
Group:          System/I18n/Japanese
Requires:       %{name} = %{version}
Requires:       uim-qt = %{version}
Provides:       locale(libqt4:ja)

%description qt4
Qt4 input module plugin for uim

%package	kde3
Summary:        KDE3 Applet for Uim
Group:          User Interface/Desktops
Requires:       uim = %{version}-%{release}
Requires:       uim-qt3

%description	kde3
Uim is a multilingual input method library. Uim aims to
provide secure and useful input methods for all
languages.

%prep
%setup0 -q
%patch10 -p1
%patch12 -p1
cp emacs/README README.emacs
iconv -f euc-jp -t utf-8 < emacs/README.ja > README.ja.emacs

%build
autoreconf -f -i
intltoolize --force
cp po/Makefile.in.in qt/chardict/po
cp po/Makefile.in.in qt4/chardict/po
%configure --disable-static --with-pic \
	--libexecdir=%{_prefix}/lib/uim \
	--with-canna\
	--with-anthy-utf8 \
	--with-qt\
	--with-qt-immodule \
        --with-qt4 \
	--with-qt4-immodule \
        --enable-kde-applet

make %{?_smp_mflags}

%install
%make_install
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 \
               %{buildroot}%{_sysconfdir}/X11/xim.d/uim
pushd  %{buildroot}%{_sysconfdir}/X11/xim.d/ja
    ln -s ../uim 60-uim
popd
# 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")
    do
        emacs -no-site-file -q -batch -eval '(setq load-path (cons "." load-path))' -f batch-byte-compile $i
    done
popd
# 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")
    do
        xemacs -no-site-file -q -batch -eval '(setq load-path (cons "." load-path))' -f batch-byte-compile $i
    done
popd
install -m 644 $RPM_SOURCE_DIR/xemacs-auto-autoloads.el \
    %{buildroot}%{_datadir}/xemacs/site-packages/lisp/uim-el/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")
do
    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
done
%find_lang uim
%if 0%{?suse_version} > 1100
touch uim-chardict-qt.lang
%else
%find_lang uim-chardict-qt
%endif
%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
%endif
find %{buildroot} -type f -name "*.la" -delete -print
rm -f doc/Makefile*

%clean
rm -rf %{buildroot}

%post
/sbin/ldconfig
# 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
%gtk2_immodule_post

%postun gtk2
%gtk2_immodule_postun

%if %{build_gtk3}

%post gtk3
%gtk3_immodule_post

%postun gtk3
%gtk3_immodule_postun
%endif

%files -f uim.lang
%defattr(-, root, root)
%doc AUTHORS COPYING ChangeLog INSTALL* NEWS* README*
%doc doc
%dir %{_sysconfdir}/X11/xim.d/
%{_sysconfdir}/X11/xim.d/*
%{_datadir}/uim
# autogenerated by uim-module-manager:
%ghost %{_datadir}/uim/installed-modules.scm
%ghost %{_datadir}/uim/loader.scm
%ghost %{_datadir}/uim/modules
%{_bindir}/uim-sh
%{_bindir}/uim-module-manager
%{_bindir}/uim-xim
%{_bindir}/uim-fep
%{_bindir}/uim-fep-tick
%{_bindir}/uim-el-agent
%{_bindir}/uim-el-helper-agent
%{_bindir}/uim-help
%{_bindir}/uim-m17nlib-relink-icons
%{_libdir}/*.so.*
%dir %{_libdir}/uim
%if "%{_libdir}" != "%{_prefix}/lib"
%dir %{_prefix}/lib/uim
%endif
%{_prefix}/lib/uim/uim-helper-server
%dir %{_libdir}/uim/plugin/
%{_libdir}/uim/plugin/*.so
%doc %{_mandir}/man1/*.1.gz
%{_datadir}/applications/%{name}.desktop
%{_datadir}/emacs/site-lisp/*
%{_datadir}/xemacs/site-packages

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

%files gtk2
%defattr(-, root, root)
%{_bindir}/uim-*-gtk
%{_bindir}/uim-*-gtk-*
%{_bindir}/uim-input-pad-ja
%{_prefix}/lib/uim/uim-*-gtk
%{_libdir}/gtk-2*/*/immodules/*.so

%if %{build_gtk3}

%files gtk3
%defattr(-, root, root)
%{_bindir}/uim-*-gtk3
%{_bindir}/uim-*-gtk3-*
%{_prefix}/lib/uim/uim-*-gtk3
%{_libdir}/gtk-3*/*/immodules/*.so
%endif

%files applet-gnome
%defattr(-, root, root)
%if %{is_gnome3}
%{_prefix}/lib/uim/uim-toolbar-applet-gnome3
%{_datadir}/gnome-panel/*/applets
%{_datadir}/dbus-1/services/*
%else
%{_prefix}/lib/uim/uim-toolbar-applet
%{_libdir}/bonobo/servers/*
%endif

%files qt3 -f uim-chardict-qt.lang
%defattr(-, root, root)
%{_bindir}/uim-*-qt
%{_prefix}/lib/uim/uim-*-qt
%{_prefix}/lib/qt3/plugins/inputmethods/*.so

%files qt4 -f uim-chardict-qt.lang
%defattr(-, root, root)
%{_bindir}/uim-*-qt4
%{_prefix}/lib/uim/uim-*-qt4
%{_libdir}/qt4/plugins/inputmethods/*.so

%files	kde3
%defattr (-, root, root, -)
%doc AUTHORS COPYING ChangeLog* NEWS README
/opt/kde3/%_lib/kde3/uim_panelapplet.so
/opt/kde3/share/apps/kicker/applets/uimapplet.desktop

%changelog