# -*- 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

PortSystem          1.0
PortGroup           github 1.0
PortGroup           muniversal 1.0

github.setup        lavv17 lftp 4.9.3 v
revision            0
categories          net
maintainers         {mps @Schamschula} 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/

github.tarball_from releases

checksums           rmd160  170508811414ae87c7011c98582f5f1e799f5321 \
                    sha256  68116cc184ab660a78a4cef323491e89909e5643b59c7b5f0a14f7c2b20e0a29 \
                    size    3385456

depends_build       port:autoconf \
                    port:automake \
                    port:bison \
                    port:gettext

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

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

compiler.blacklist-append \
                    *gcc-4.0 *gcc-4.2

use_autoreconf      yes
autoreconf.args     --install --verbose --force

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

configure.checks.implicit_function_declaration.whitelist-append \
                    MIN \
                    posix_fallocate \
                    re_compile_pattern \
                    re_search \
                    re_set_syntax \
                    strchr

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 path:lib/pkgconfig/gnutls.pc:gnutls

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