# -*- 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: Portfile 84550 2011-09-27 21:05:11Z snc@macports.org $

PortSystem 1.0

name    alpine
version 2.00
revision 4
categories  mail
maintainers nomaintainer
description alpine - a Program for Internet News and Email
homepage  http://www.washington.edu/alpine/
platforms darwin
use_parallel_build  no

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/
checksums  md5 84e44cbf71ed674800a5d57eed9c1c52
use_bzip2  yes

patchfiles patch-Makefile.in.diff \
           patch-configure.diff
patch.pre_args -p1

if {${os.platform} == "darwin" && ${os.major} >= 10} {
  patchfiles-append alpine-osx-10.6.patch
}

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 \
  -with-ssl-lib-dir=${prefix}/lib \
  --with-local-password-cache-method \
  --with-debug-level=0

build.args \
  SPECIALS="GSSLIB=${prefix}/lib 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"
}

variant universal {
  build.args-append \
    EXTRACFLAGS="${configure.universal_cflags}" \
    EXTRALDFLAGS="${configure.universal_ldflags}"
}
