##
##  alpine.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:         alpine
Summary:      Programm for Internet News & Email (AlPINE)
URL:          http://www.washington.edu/alpine/
Vendor:       University of Washington
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Mail
License:      ASF
Version:      2.00
Release:      20080827

#   package options
%option       with_ssl   no
%option       with_ldap  no

#   list of sources
Source0:      ftp://ftp.cac.washington.edu/alpine/alpine-%{version}.tar.bz2
Source1:      alpine.conf
Source2:      alpine.conf.fixed

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, MTA, make, gcc
PreReq:       OpenPKG, openpkg >= 20160101, MTA
%if "%{with_ssl}" == "yes"
BuildPreReq:  openssl
PreReq:       openssl
%endif
%if "%{with_ldap}" == "yes"
BuildPreReq:  openldap
PreReq:       openldap
%endif

%description
    Alpine -- a Program for Internet News & Email -- is a tool for
    reading, sending, and managing electronic messages. Alpine was
    developed by Computing & Communications at the University of
    Washington. Alpine is the successor to Pine.

%track
    prog alpine = {
        version   = %{version}
        url       = ftp://ftp.cac.washington.edu/alpine/
        regex     = alpine-(__VER__)\.tar\.bz2
    }

%prep
    %setup -q

%build
    #   configure program
    CC="%{l_cc}" \
    CFLAGS="%{l_cflags -O}" \
    CPPFLAGS="%{l_cppflags}" \
    LDFLAGS="%{l_ldflags}" \
    LIBS="" \
    ./configure \
        --prefix=%{l_prefix} \
        --mandir=%{l_prefix}/man \
        --with-smtp-msa=%{l_prefix}/sbin/sendmail \
        --with-system-pinerc=%{l_prefix}/etc/alpine/alpine.conf \
        --with-system-fixed-pinerc=%{l_prefix}/etc/alpine/alpine.conf.fixed \
%if "%{with_ssl}" == "yes"
        --with-ssl \
        --with-ssl-dir=%{l_prefix} \
%else
        --without-ssl \
%endif
%if "%{with_ldap}" == "yes"
        --with-ldap \
        --with-ldap-dir=%{l_prefix} \
%else
        --without-ldap \
%endif
        --without-krb5 \
        --without-pthread \
        --disable-nls

    #   build program
    %{l_make} %{l_mflags -O}

%install
    #   install program
    %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"

    #   create directories and install files
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/etc/alpine
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        %{SOURCE alpine.conf.fixed} %{SOURCE alpine.conf} \
        $RPM_BUILD_ROOT%{l_prefix}/etc/alpine/

    #   determine installation files
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%config %{l_prefix}/etc/alpine/*'

%files -f files

%clean

