# $Id: Portfile,v 1.29 2006/08/08 07:07:54 yeled Exp $

PortSystem 1.0
name                lftp
version             3.5.1
categories          net
maintainers         yeled@opendarwin.org
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/
platforms           darwin 

depends_lib  port:expat port:gettext port:libiconv port:ncurses port:readline

master_sites        ftp://ftp.wiretapped.net/pub/mirrors/${name}/ \
            ftp://ftp.wiretapped.net/pub/mirrors/${name}/old/ \
                    ftp://ftp.cs.tu-berlin.de/pub/net/ftp/${name}/ \
                    http://ftp.yars.free.net/pub/source/${name}/
use_bzip2           yes
checksums           md5 c6d48782cdad4759000bf7cd24555723

default_variants    +tls

pre-configure {
# for some bogus Apple headers.
        reinplace "s|poll_works=yes|poll_works=no|g" ${worksrcpath}/configure
        reinplace "s|need_relink=yes|need_relink=no|g" ${worksrcpath}/ltmain.sh
# for _optopt errors
        reinplace "s|^.*LIBOBJS=\"\$LIBOBJS getopt.\$ac_objext\" ;;|  *) LIBOBJS=\"\$LIBOBJS\" ;;|g" ${worksrcpath}/configure
        reinplace "s|^.*LIBOBJS=\"\$LIBOBJS getopt1.\$ac_objext\" ;;|  *) LIBOBJS=\"\$LIBOBJS\" ;;|g" ${worksrcpath}/configure
# for ssl/tls breakage.
        reinplace "s|CDECL void srandom(unsigned seed);||g" ${worksrcpath}/src/ResMgr.cc
}

configure.env   CPPFLAGS="-no-cpp-precomp -Wno-long-double -DBIND_8_COMPAT" \
                LDFLAGS="-Wl,-search_paths_first"

configure.args  --mandir=${prefix}/share/man \
                --with-pic --disable-share --enable-static --without-openssl \
                --without-included-readline --without-gnutls

post-destroot { xinstall -d ${destroot}${prefix}/share/doc/${name}
                xinstall -m 644 -v -W ${worksrcpath} \
                BUGS ChangeLog COPYING FAQ FEATURES NEWS \
                README README.debug-levels README.modules \
                THANKS TODO \
                ${destroot}${prefix}/share/doc/${name}
}

variant ssl {
    configure.args-append --with-openssl --without-gnutls
    configure.args-delete --without-openssl --with-gnutls
    depends_lib-append port:openssl
}

variant tls {
    configure.args-append --without-openssl --with-gnutls
    configure.args-delete --with-openssl --without-gnutls
    depends_lib-append port:gnutls
}
