# -*- 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 88370 2011-12-29 20:08:12Z ryandesign@macports.org $

PortSystem          1.0

name                libtorrent
conflicts           libtorrent-devel
version             0.12.9
categories          net
platforms           darwin
maintainers         gmail.com:gardnermj
license             GPL-2+

description         BitTorrent library

long_description    libTorrent is a BitTorrent library written in C++ for \
                    *nix. It is designed to avoid redundant copying and \
                    storing of data that other clients and libraries suffer from.

homepage            http://libtorrent.rakshasa.no/
master_sites        ${homepage}downloads/

checksums           sha1    176a836c6e685e4dad71ac08c0e09caaa5b7757c \
                    rmd160  a898e882da94977973d62f34a5dd82577fd83cf5

depends_build       port:pkgconfig

depends_lib         port:openssl \
                    port:libsigcxx2

# Remove this when updating to 0.13.0
if {${configure.compiler} == "clang"} {
    configure.compiler llvm-gcc-4.2
}

configure.args      --disable-debug \
                    --enable-ipv6 \
                    --with-kqueue

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} AUTHORS COPYING ChangeLog NEWS README \
        ${destroot}${docdir}
}

if {${os.platform} == "darwin" && ${os.major} <= 9} {
    # currently broken, ticket #27289
    pre-fetch {
        return -code error "$name currently cannot be compiled on Mac OS X 10.5 or earlier."
    }
    # clear deps so users don't waste time installing them for a broken port
    depends_lib
    depends_build

    patchfiles-append   no_posix_memalign.patch
    configure.compiler  gcc-4.2
    if {![file executable ${configure.cc}]} {
        depends_build-append port:apple-gcc42
        configure.compiler   apple-gcc-4.2
        # base (as of 2.0.3) doesn't set cxx for apple-gcc-4.2
        configure.cxx        ${prefix}/bin/g++-apple-4.2
    }
}

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