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

# Note - when libtorrent is next updated, consider moving to the github release
# which is under the rtorrent umbrella at
# https://github.com/rakshasa/rtorrent/releases/download/v0.9.8/libtorrent-0.13.8.tar.gz

github.setup        rakshasa libtorrent 0.13.8 v
revision            1

conflicts           libtorrent-devel
categories          net
platforms           darwin
maintainers         nomaintainer
license             {GPL-2+ OpenSSLException}

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.

checksums           rmd160  9d08970166976e287d58f30cbfade78b972fce55 \
                    sha256  a679b6408318d30de060d003d51572c6fcb6ecf839b4ca6b9d37a099d59a818c \
                    size    357770

use_autoreconf      yes
autoreconf.cmd      ./autogen.sh

depends_build-append \
                    port:pkgconfig \
                    port:autoconf \
                    port:automake \
                    port:libtool

# malformed object (unknown load command 2)
if {${os.platform} eq "darwin" && ${os.major} <= 10} {
    depends_build-append port:cctools
}

depends_lib-append \
                    path:lib/libssl.dylib:openssl \
                    port:libsigcxx2

compiler.cxx_standard   2011

configure.args      --disable-debug \
                    --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} eq "darwin" && ${os.major} <= 9} {

    # socket_fd.cc:74:43: error: 'IPV6_TCLASS' was not declared in this scope
    patchfiles-append   patch-src-net-socket-no-tclass.diff

    # error: 'posix_memalign' was not declared in this scope
    patchfiles-append   patch-leopard-no-posix-memalign.diff

}
