# $Id: Portfile 55500 2009-08-12 09:30:44Z ryandesign@macports.org $

PortSystem              1.0
PortGroup               muniversal 1.0

name                    curl
# keep the version in sync with the curl-ca-bundle port
version                 7.19.6
categories              net www
maintainers             ryandesign
homepage                http://curl.haxx.se/
platforms               darwin freebsd
use_bzip2               yes
use_parallel_build      yes

description \
    Tool for transferring files with URL syntax

long_description \
    curl is a client to get documents/files from servers, using any of \
    the supported protocols. The command is designed to work without \
    user interaction or any kind of interactivity.

# keep the master_sites in sync with the curl-ca-bundle port
master_sites \
    http://curl.haxx.se/download/ \
    ftp://ftp.sunet.se/pub/www/utilities/curl/ \
    http://curl.sourceforge.net/download/ \
    http://cool.haxx.se/curl/ \
    http://www.execve.net/curl/

checksums \
    md5     8402c1f654c51ad7287aad57c3aa79be \
    sha1    b7cb98c7a6577de7073d0b0c23eecdb8ed993e8e \
    rmd160  7627d78ec681a513972be0cb5473b26805f44d83 \

configure.args \
    --disable-ipv6 \
    --without-libidn \
    --without-libssh2 \
    --without-ssl \
    --disable-ldap \
    --with-zlib=${prefix}

configure.env \
    PKG_CONFIG_PATH=${prefix}

depends_build \
    port:pkgconfig

depends_lib \
    port:zlib

test.run                yes
test.target             test-full

post-build {
    if {[variant_isset universal]} {
        foreach arch ${universal_archs} {
            reinplace "s|[muniversal_get_arch_flag ${arch}]||" \
                ${worksrcpath}-${arch}/curl-config \
                ${worksrcpath}-${arch}/libcurl.pc
        }
    }
}

set docdir ${prefix}/share/doc/${name}-${version}

post-destroot {
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} \
        CHANGES \
        COPYING \
        README \
        RELEASE-NOTES \
        ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath}/docs \
        BUGS \
        CONTRIBUTE \
        FAQ \
        FEATURES \
        HISTORY \
        INTERNALS \
        KNOWN_BUGS \
        MANUAL \
        RESOURCES \
        THANKS \
        TODO \
        VERSIONS \
        ${destroot}${docdir}
}

variant ssl {
    depends_lib-append      port:openssl \
                            port:curl-ca-bundle
    configure.args-append   --with-ca-bundle=${prefix}/share/curl/curl-ca-bundle.crt
    configure.args-delete   --without-ssl
}

variant ipv6 {
    configure.args-delete   --disable-ipv6
    configure.args-append   --enable-ipv6
}

variant ares description {Add support for resolving names asynchronously} {
    depends_lib-append      lib:libcares:c-ares
    configure.args-append   --enable-ares=${prefix}
}

variant idn description {Add support for internationalized domain names} {
    depends_lib-append      port:libidn
    configure.args-delete   --without-libidn
}

variant spnego description {Enable SPNEGO authentication support} {
    # kind of broken?
    depends_lib-append      port:fbopenssl
    configure.args-append   --with-spnego=${prefix}
}

variant gnutls conflicts ssl {
    depends_lib-append      port:gnutls
    configure.args-append   --with-gnutls
}

variant gss {
    configure.args-append   --with-gssapi
}

variant openldap {
    depends_lib-append      port:openldap
    configure.args-delete   --disable-ldap
}

variant sftp_scp description {Add SFTP/SCP support via libssh2} {
    depends_lib-append      port:libssh2
    configure.args-delete   --without-libssh2
}

variant doc {
    post-destroot {
        xinstall -d ${destroot}${docdir}/html/libcurl
        xinstall -m 0644 -W ${worksrcpath}/docs TheArtOfHttpScripting ${destroot}${docdir}/html
        eval xinstall -m 0644 [glob ${worksrcpath}/docs/*.html] ${destroot}${docdir}/html
        eval xinstall -m 0644 [glob ${worksrcpath}/docs/libcurl/*.html] \
            ${destroot}${docdir}/html/libcurl

        xinstall -d ${destroot}${docdir}/pdf/libcurl
        xinstall -m 0644 -W ${worksrcpath}/docs curl-config.pdf curl.pdf ${destroot}${docdir}/pdf
        eval xinstall -m 0644 [glob ${worksrcpath}/docs/libcurl/*.pdf] ${destroot}${docdir}/pdf/libcurl
    }
}

livecheck.check             freshmeat
livecheck.regex             (?i)<title>curl and libcurl (.*)</title>
