# -*- 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
PortGroup           muniversal 1.0

name                lftp
version             4.7.3
categories          net
platforms           darwin
maintainers         mps openmaintainer
license             GPL-3+

description         Sophisticated file transfer program
long_description    Lftp is a shell-like command line ftp client. It is \
                    reliable, can retry operations and does reget \
                    automatically. It can do several transfers \
                    simultaneously in background. You can start a transfer \
                    in background and continue browsing the ftp site or \
                    another one. This all is done in one process. Background \
                    jobs will be completed in nohup mode if you exit or \
                    close modem connection. Lftp has reput, mirror, reverse \
                    mirror among its features.

homepage            http://lftp.yar.ru/
master_sites        ${homepage}ftp/
use_xz              yes

checksums           rmd160  3dd882bbd3cde872bee8c573a4586319cd1c289a \
                    sha256  3b22259cdc4c1a6ae349057d16bda4b4816929e04d223242ab8927bc31a48e7c

depends_build       port:autoconf \
                    port:automake

depends_lib         port:expat \
                    port:gettext \
                    port:libiconv \
                    port:ncurses \
                    path:lib/libssl.dylib:openssl \
                    port:readline \
                    port:zlib

# look for ncurses first, fix 4.7.x build issues
patchfiles          patch-configure.diff \
                    patch-src.diff

configure.args      --with-openssl \
                    --without-gnutls \
                    --with-readline=${prefix} \
                    --enable-nls

pre-patch {
	# needed for 4.7.x build issues
	move ${worksrcpath}/src/lftp_rl.c ${worksrcpath}/src/lftp_rl.cc
}

post-destroot {
    set docdir ${destroot}${prefix}/share/doc/${name}
    xinstall -d ${docdir}
    xinstall -m 644 -W ${worksrcpath} AUTHORS BUGS ChangeLog COPYING FAQ FEATURES \
        NEWS README README.debug-levels README.modules MIRRORS THANKS TODO \
        ${docdir}
    file delete -force "${destroot}${prefix}/lib/charset.alias"
}

variant tls description {Use GnuTLS instead of OpenSSL} {
    depends_build-append    port:pkgconfig
    depends_lib-replace     path:lib/libssl.dylib:openssl port:gnutls

    configure.args-replace  --with-openssl --without-openssl
    configure.args-replace  --without-gnutls --with-gnutls
}

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     ${name}-(\\d+(?:\\.\\d+)*) released