File uim.spec of Package uim_backports

#
# spec file for package uim
#
# Copyright (c) 2024 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%if ! %{defined _distconfdir}
%define _distconfdir %{_sysconfdir}
%endif
%define is_gnome3 (0%{?suse_version} > 1140)
%define build_applet (0%{?suse_version} < 1310)
%define build_qt4 0%{?suse_version} <= 1500 && 0%{?sle_version} < 150700
%define build_ssl 0%{?suse_version} <= 1500 && 0%{?sle_version} < 150700

Name:           uim
Version:        1.8.8
Release:        0
Summary:        A multilingual input method framework
License:        BSD-3-Clause AND LGPL-2.1-or-later AND (BSD-3-Clause OR LGPL-2.0-only)
Group:          System/I18n/Japanese
URL:            https://github.com/uim/uim
Source0:        https://github.com/uim/uim/releases/download/%{version}/%{name}-%{version}.tar.gz
Source1:        suse-start-uim.el
Source2:        xemacs-auto-autoloads.el
Source3:        etc-x11-xim.d-uim
Source4:        baselibs.conf
Patch1:         uim-fix-crash-in-firefox.diff
Patch2:         emacs-27.1.patch
Patch3:         uim-fix-multiple_declaration.diff
Patch4:         riscv.patch
Patch5:         fix-build_various.patch
Patch6:         fix-caret-color.patch
Patch7:         fix-fep-hang_on.patch
Patch8:         fix-hardcode_fontsets.patch
Patch9:         fix-gtk-suppress.patch
Patch10:        fix-gtk3_various.patch
Patch11:        fix-chardict-qt4.patch
Patch12:        fix-qt5_applications_segfault.patch
Patch13:        fix-qt5_apps_in_wayland.patch
Patch14:        fix-skk_various.patch
Patch15:        fix-wrong-character-comparison.patch
Patch16:        fix-openssl-checks.patch
BuildRequires:  emacs-x11
BuildRequires:  fdupes
BuildRequires:  gcc-c++
%if 0%{?suse_version} > 1600
BuildRequires:  gcc13-c++
%endif
BuildRequires:  automake
BuildRequires:  cmake
BuildRequires:  intltool
BuildRequires:  libtool
BuildRequires:  libqt5-qtbase-devel
BuildRequires:  libqt5-qtbase-private-headers-devel
BuildRequires:  libQt5Core-devel
BuildRequires:  libQt5Widgets-devel
BuildRequires:  libicu-devel
BuildRequires:  libxkbcommon-devel
BuildRequires:  eb-devel
BuildRequires:  m17n-lib-devel
BuildRequires:  ncurses-devel
BuildRequires:  libcurl-devel
BuildRequires:  libffi-devel
BuildRequires:  perl-XML-Parser
BuildRequires:  pkgconfig
BuildRequires:  update-desktop-files
BuildRequires:  hicolor-icon-theme
BuildRequires:  xemacs
BuildRequires:  asciidoc
%if %{build_applet}
BuildRequires:  gnome-panel-devel
%endif
%if %{build_qt4}
BuildRequires:  libqt4-devel
%endif
BuildRequires:  pkgconfig(Qt5X11Extras)
BuildRequires:  pkgconfig(anthy)
BuildRequires:  pkgconfig(expat)
BuildRequires:  pkgconfig(gdk-x11-2.0)
BuildRequires:  pkgconfig(gtk+-2.0)
BuildRequires:  pkgconfig(gtk+-3.0)
BuildRequires:  pkgconfig(openssl)
BuildRequires:  pkgconfig(sqlite3)
BuildRequires:  pkgconfig(libedit)
BuildRequires:  pkgconfig(libnotify)
BuildRequires:  pkgconfig(x11)
Recommends:     %{name}-gtk2 = %{version}
Recommends:     %{name}-gtk3 = %{version}
%if %{build_qt4}
Recommends:     %{name}-qt4 = %{version}
%endif
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}
%endif

%description
Uim is a multilingual input method framework.

%package devel
Summary:        Development files for the UIM input method framework
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}
%gtk2_immodule_requires

%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}
%gtk3_immodule_requires

%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
%endif

%if %{build_qt4}
%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
%endif

%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

%prep
%setup -q
%patch -P 1 -p1
%patch -P 2 -p0
%patch -P 3 -p0
%patch -P 4 -p1
%patch -P 5 -p0
%patch -P 6 -p0
%patch -P 7 -p0
%patch -P 8 -p0
%patch -P 9 -p0
%patch -P 10 -p0
%patch -P 11 -p0
%patch -P 12 -p0
%patch -P 13 -p0
%patch -P 14 -p0
%patch -P 15 -p0
%patch -P 16 -p0

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' \
    $RPM_SOURCE_DIR/baselibs.conf
%endif
./autogen.sh

%build
%if 0%{?suse_version} > 1600
export CC=gcc-13 CXX=g++-13
%endif
export CFLAGS="$CFLAGS -fcommon"
export CXXFLAGS="$CXXFLAGS -std=c++11"
%configure --disable-static --with-pic \
        --libexecdir=%{_prefix}/lib/uim \
        --with-canna \
        --with-anthy-utf8 \
        --with-curl \
        --with-expat \
        --with-eb \
        --with-ffi \
%if %{build_qt4}
        --with-qt4 \
        --with-qt4-immodule \
%endif
        --with-qt5 \
        --with-qt5-immodule \
        --enable-kde-applet \
        --enable-dict \
%if %{build_ssl}
        --enable-openssl \
%endif
        --disable-warnings-into-error

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}%{_distconfdir}/X11/xim.d/ja
install -m 644 $RPM_SOURCE_DIR/etc-x11-xim.d-uim \
               %{buildroot}%{_distconfdir}/X11/xim.d/uim
pushd  %{buildroot}%{_distconfdir}/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
sed -i 's/set-face-underline-p/set-face-underline/g' ./uim-var.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
%else
%find_lang uim-chardict-qt
%endif
touch uim-chardict-qt.lang
%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*

%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 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

%post gtk3
%gtk3_immodule_post

%postun gtk3
%gtk3_immodule_postun

%files -f uim.lang
%license COPYING
%doc AUTHORS NEWS* README*
%doc doc
%{_distconfdir}/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
%{_libdir}/*.so
%{_includedir}/uim/
%{_libdir}/pkgconfig/uim.pc

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

%files gtk3
%{_bindir}/uim-*-gtk3
%{_bindir}/uim-*-gtk3-*
%{_prefix}/lib/uim/uim-*-gtk3
%{_libdir}/gtk-3*/*/immodules/*.so

%if %{build_applet}
%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
%endif

%if %{build_qt4}
%files qt4 -f uim-chardict-qt.lang
%{_bindir}/uim-*-qt4
%{_prefix}/lib/uim/uim-*-qt4
%{_libdir}/qt4/plugins/inputmethods/*.so
%endif

%files qt5 -f uim-chardict-qt.lang
%{_bindir}/uim-*-qt5
%{_prefix}/lib/uim/uim-*-qt5
%{_libdir}/qt5/plugins/platforminputcontexts/*.so

%changelog
openSUSE Build Service is sponsored by