File mecab.spec of Package mecab

#
# spec file for package mecab
#
# Copyright (c) 2026 SUSE LLC and contributors
#
# 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/
#

%define libname libmecab2

Name:           mecab
Version:        0.996+git20250222.61b90ba
Release:        0
Summary:        Yet Another Part-of-Speech and Morphological Analyzer
License:        GPL-2.0-or-later OR LGPL-2.1-or-later OR BSD-3-Clause
URL:            https://github.com/taku910/mecab
Source:         %{name}-%{version}.tar.gz
Source1:        mecab.pc.in
Patch0:         libexecdir.patch
Patch1:         remove-hardcoded-cflags.patch
Group:          System/I18n/Japanese
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  c++_compiler
BuildRequires:  libtool
BuildRequires:  gettext-tools
BuildRequires:  pkg-config

%description
MeCab is a high-performance morphological analysis engine for Japanese text.
It segments sentences into tokens and assigns parts of speech, readings and
other linguistic annotations. Originally developed at the University of Kyoto,
it uses conditional random fields for statistical analysis and supports custom
dictionaries.

%package -n %{libname}
Summary:        Shared library for MeCab morphological analyzer

%description -n %{libname}
Shared library for the MeCab morphological analysis engine.

%package devel
Summary:        Development files for MeCab
Requires:       %{libname} = %{version}-%{release}

%description devel
Header files and development libraries for building applications
that use MeCab.

%prep
%autosetup -p1
cd mecab
mkdir -p m4
autoreconf -fiv --warnings=no-portability -I /usr/share/gettext/m4

%build
cd mecab
export CFLAGS="$CFLAGS %{optflags}"
export CXXFLAGS="$CXXFLAGS %{optflags}"
%configure --sysconfdir=%{_sysconfdir}/%{name} --with-charset=utf8
%make_build

%check
cd mecab
%make_build check

%install
cd mecab
%make_install
find %{buildroot} -type f \( -name "*.la" -o -name "*.a" \) -delete
strip %{buildroot}%{_bindir}/mecab
strip %{buildroot}%{_libdir}/libmecab.so.*
strip %{buildroot}%{_libexecdir}/%{name}/*
install -Dm644 %{SOURCE1} %{buildroot}%{_libdir}/pkgconfig/mecab.pc
sed -i -e 's|@PREFIX@|%{_prefix}|' \
       -e 's|@LIBDIR@|%{_libdir}|' \
       -e 's|@VERSION@|%{version}|' \
       %{buildroot}%{_libdir}/pkgconfig/mecab.pc

%ldconfig_scriptlets -n %{libname}

%files
%doc mecab/README mecab/AUTHORS
%license mecab/COPYING mecab/BSD mecab/GPL mecab/LGPL
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/mecabrc
%{_bindir}/mecab
%{_libexecdir}/%{name}
%{_mandir}/man1/*

%files -n %{libname}
%license mecab/COPYING mecab/BSD mecab/GPL mecab/LGPL
%{_libdir}/libmecab.so.*

%files devel
%{_bindir}/mecab-config
%{_includedir}/mecab.h
%{_libdir}/libmecab.so
%{_libdir}/pkgconfig/mecab.pc

%changelog
openSUSE Build Service is sponsored by