%ifarch x86_64
%bcond_without doc
%else
%bcond_with doc
%endif

Name:           mailutils
Summary:        GNU Mailutils: General-Purpose Mail Package
Summary(ja):    GNU Mailutils: 汎用メールユーティリティパッケージ
Version:        3.17
Release:        1%{_dist_release}
Group:          internet
Vendor:         Project Vine
Distribution:   Vine Linux

License:        GPL3+
URL:            https://mailutils.org/
Source0:        https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz

BuildRequires:  bzip2-devel
BuildRequires:  flex
BuildRequires:  gdbm-devel
BuildRequires:  gnutls-devel
BuildRequires:  info
BuildRequires:  libgcrypt-devel
BuildRequires:  libunistring-devel
BuildRequires:  libtool-ltdl-devel
BuildRequires:  openldap-devel
BuildRequires:  pam-devel
BuildRequires:  perl
BuildRequires:  readline-devel
BuildRequires:  pkgconfig(zlib)

Requires:       mailutils-libs = %{version}-%{release}

%global         mailx_version 8.1.2.20180807-2
Conflicts:      mailx < %{mailx_version}
Obsoletes:      mailx < %{mailx_version}
Provides:       mailx = %{mailx_version}
Provides:       config(mailx) = %{mailx_version}
Provides:       /bin/mail

%description
GNU Mailutils is a rich and powerful protocol-independent mail
framework. It contains a series of useful mail libraries, clients,
and servers. These are the primary mail utilities for the GNU system.
The central library is capable of handling electronic mail in various
mailbox formats and protocols, both local and remote.  Specifically,
this project contains a POP3 server, an IMAP4 server, and a Sieve mail
filter. It also provides a POSIX `mailx' client, and a collection of
other handy tools.


%package        libs
Summary:        GNU Mailutils: mailbox access library.
Group:          system
License:        LGPL3+

%description    libs
The runtime library libmailbox contains various mailbox access
routines and support for a number of mailbox types, such as mbox,
maildir, mh, POP3, and IMAP4. It also supports MIME message
handling, and sending mail via SMTP and /sbin/sendmail.


%package        devel
Summary:        GNU Mailutils: mailbox access development.
Group:          programming
License:        LGPL3+
Requires:       mailutils-libs = %{version}-%{release}

%description    devel
GNU Mailutils: mailbox access development.


%package        mh
Summary:        GNU Mailutils: The Message Handling System.
Group:          internet
License:        GPL3+
Requires:       mailutils-libs = %{version}-%{release}

%description mh
The GNU MH (Message Handling System).


%if %{with doc}
%package        doc
Summary:        GNU Mailutils: documentation.
Group:          documentation
License:        GFDL-1.2
BuildArch:      noarch

%description    doc
API reference for libmailbox and user documentation for the rest of
the GNU Mailutils.
%endif


%debug_package


%prep
%setup -q
if [ %version = 3.12 ]; then
    echo "#endif" >> include/mailutils/sys/streamtrans.h
fi


%build
autoreconf -fiv

%configure \
    --disable-static \
    --disable-rpath \
    --enable-ipv6 \
    --with-mail-spool=/var/spool/mail \
    --with-mh-bindir=%{_libexecdir}/mu-mh \
    --disable-build-pop3d \
    --disable-build-imap4d \
    --disable-build-comsat \
    --disable-build-mda \
    --disable-build-lmtpd \
    --disable-build-putmail \
    --disable-build-sieve \
    --without-guile \
    --disable-python \
    %{nil}

# SMP-incompatible build.
make V=1


%install
%make_install

install -d %{buildroot}/bin
mv -f %{buildroot}%{_bindir}/mail %{buildroot}/bin/
ln -s ./mail %{buildroot}/bin/Mail
ln -s ./mail %{buildroot}/bin/mailx
ln -s ../../bin/mail %{buildroot}%{_bindir}/mail
ln -s ../../bin/mail %{buildroot}%{_bindir}/Mail
ln -s ../../bin/mail %{buildroot}%{_bindir}/mailx

%find_lang %name

# unshipped files
find %{buildroot}%{_libdir} -name "*.la" -delete
rm -f %{buildroot}%{_mandir}/man1/{imap4d,pop3d,popauth}.1*
rm -f %{buildroot}%{_infodir}/dir

# x86_64 only (noarch)
%if !%{with doc}
rm -rf %{buildroot}%{_infodir}
%endif


%check
#make check MH=/dev/null || { cat mh/tests/testsuite.log; exit 1; }
make check


%files -f %name.lang
%license COPYING*
%doc AUTHORS THANKS NEWS README* TODO ChangeLog
/bin/Mail
/bin/mail
/bin/mailx
%{_bindir}/mailutils
%{_bindir}/dotlock
%{_bindir}/frm
%{_bindir}/from
%{_bindir}/Mail
%{_bindir}/mail
%{_bindir}/mailx
%{_bindir}/messages
%{_bindir}/mimeview
%{_bindir}/movemail
%{_bindir}/readmsg
%{_bindir}/decodemail
%{_mandir}/*/mail*
%dir %{_libexecdir}/mailutils
%{_libexecdir}/mailutils/*
%dir %{_datadir}/%{name}

%files libs
%dir %{_libdir}/mailutils
%{_libdir}/mailutils/*.so
%{_libdir}/*.so.*

%files mh
%dir %{_libexecdir}/mu-mh
%{_libexecdir}/mu-mh/*
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/mh

%files devel
%{_bindir}/mailutils-config
%{_includedir}/mailutils
%{_libdir}/*.so
%{_datadir}/aclocal/mailutils.m4

%if %{with doc}
%files doc
%{_infodir}/*
%endif


%changelog
* Mon Jun 17 2024 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 3.17-1
- new upstream release.

* Fri Nov 18 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 3.15-1
- new upstream release.

* Fri Jan 14 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 3.14-1
- new upstream release.
- dropped install-info scriptlets.

* Fri Aug 06 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 3.13-1
- new upstream release.

* Thu Mar 18 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 3.12-1
- initial build for Vine Linux.
