##
##  nail.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package information
Name:         nail
Summary:      MIME-capable Berkeley Mail Command
URL:          http://heirloom.sourceforge.net/mailx.html
Vendor:       BSD, Gunnar Ritter
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        BASE
Group:        Mail
License:      BSD
Version:      12.4
Release:      20100418

#   list of sources
Source0:      http://download.sourceforge.net/heirloom/mailx-%{version}.tar.bz2
Patch0:       nail.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, MTA
PreReq:       OpenPKG, openpkg >= 20160101, MTA
BuildPreReq:  openssl
PreReq:       openssl

%description
    Heirloom "mailx" (formerly "nail") is a mail user agent derived from
    Berkeley Mail 8.1 and contains builtin support for MIME messages.
    This means it can handle international character sets as well as
    attachments. In recent system environments, nail is Unicode/UTF-8
    capable. It further contains some minor enhancements like the
    ability to set a From Address.

%track
    prog nail = {
        version   = %{version}
        url       = http://sourceforge.net/projects/heirloom/files/
        regex     = mailx-(__VER__)\.tar\.bz2
    }

%prep
    %setup -q -n mailx-%{version}
    %patch -p0

%build
    %{l_make} %{l_mflags} \
        CC="%{l_cc}" \
        CFLAGS="%{l_cflags -O}" \
        CPPFLAGS="%{l_cppflags}" \
        LDFLAGS="%{l_ldflags}" \
        PREFIX=%{l_prefix} \
        MANDIR='$(PREFIX)/man' \
        SYSCONFDIR=%{l_prefix}/etc/nail \
        SENDMAIL=%{l_prefix}/sbin/sendmail \
        UCBINSTALL="%{l_shtool} install -c"

%install
    %{l_make} %{l_mflags} install \
        PREFIX=%{l_prefix} \
        MANDIR='$(PREFIX)/man' \
        SYSCONFDIR=%{l_prefix}/etc/nail \
        SENDMAIL=%{l_prefix}/sbin/sendmail \
        UCBINSTALL="%{l_shtool} install -c" \
        DESTDIR=$RPM_BUILD_ROOT
    ln  $RPM_BUILD_ROOT%{l_prefix}/bin/mailx \
        $RPM_BUILD_ROOT%{l_prefix}/bin/mail
    ln  $RPM_BUILD_ROOT%{l_prefix}/bin/mailx \
        $RPM_BUILD_ROOT%{l_prefix}/bin/nail
    ln  $RPM_BUILD_ROOT%{l_prefix}/man/man1/mailx.1 \
        $RPM_BUILD_ROOT%{l_prefix}/man/man1/mail.1
    ln  $RPM_BUILD_ROOT%{l_prefix}/man/man1/mailx.1 \
        $RPM_BUILD_ROOT%{l_prefix}/man/man1/nail.1
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%config %{l_prefix}/etc/nail/nail.rc'

%files -f files

%clean

