# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id$

PortSystem          1.0

name                alpine
version             2.00
revision            4
categories          mail
license             Apache-2
maintainers         nomaintainer
platforms           darwin

homepage            http://www.washington.edu/alpine/
description         alpine - a Program for Internet News and Email
long_description    Alpine is a tool for reading, sending, and \
                    managing electronic messages that was designed \
                    with novice users in mind.

master_sites        ftp://ftp.cac.washington.edu/alpine/ \
                    ftp://ftp.cac.washington.edu/alpine/old/
use_bzip2           yes
checksums           md5 84e44cbf71ed674800a5d57eed9c1c52

patchfiles          patch-Makefile.in.diff \
                    patch-configure.diff \
                    patch-imap_Makefile.diff
patch.pre_args      -p1
if {${os.platform} == "darwin" && ${os.major} >= 10} {
    patchfiles-append   alpine-osx-10.6.patch
}
post-patch {
    reinplace "s|__PREFIX__|${prefix}|" ${worksrcpath}/imap/Makefile
}

default_variants    +without_tcl

depends_lib         port:openssl \
                    port:libiconv \
                    port:gettext \
                    port:openldap \
                    port:ncurses \
                    port:cyrus-sasl2

configure.env       SSLDIR=${prefix}
configure.args      -with-lib-dir=${prefix}/lib \
                    -with-include-dir=${prefix}/include \
                    -with-krb5-include-dir=${prefix}/include \
                    -with-krb5-lib-dir=${prefix}/lib \
                    -with-ldap-include-dir=${prefix}/include \
                    -with-ldap-lib-dir=${prefix}/lib \
                    --with-ssl-include-dir=${prefix}/include/openssl \
                    --with-ssl-lib-dir=${prefix}/lib \
                    --with-local-password-cache-method \
                    --with-debug-level=0

variant universal {}

use_parallel_build  no
build.args          CC=${configure.cc} \
                    EXTRACFLAGS="[get_canonical_archflags cc]" \
                    EXTRALDFLAGS="[get_canonical_archflags ld]" \
                    SPECIALS="GSSDIR=${prefix} SSLDIR=${prefix}"

variant without_krb5 description {Disable Kerberos5 support} {
    depends_lib-delete      port:cyrus-sasl2
    configure.args-append   --without-krb5
}

variant without_ldap description {Disable LDAP support} {
    depends_lib-delete      port:openldap
    configure.args-append   --without-ldap
}

variant without_ssl description {Disable SSL support} {
    depends_lib-delete      port:openssl
    configure.args-append   --without-ssl
    build.env-append        SSLTYPE=none
}

variant without_tcl description {Disable TCL support (disables Alpine Web)} {
    configure.args-append   --without-tcl
}

variant passfile description {Enable password files support} {
    configure.args-delete   --with-local-password-cache-method
    configure.args-append   --with-passfile=".pine.pwd"
}