# -*- 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 - releases for libtorrent are provided at https://github.com/rakshasa/rtorrent
# rather than at the projects own repo, https://github.com/rakshasa/libtorrent
github.setup        rakshasa rtorrent 0.16.8 v
github.tarball_from releases
name                libtorrent
distname            libtorrent-${github.version}
homepage            https://github.com/rakshasa/libtorrent
revision            0

conflicts           libtorrent-devel
categories          net
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  b4d586f70986ac9d2337b90d3782218ba9c4e22e \
                    sha256  78f6a4ab1a5e3e16d300ec92622f6f42269cee460671e307fb16478406d8bb54 \
                    size    901180

use_autoreconf      yes

depends_build-append \
                    path:bin/pkg-config:pkgconfig

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

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

compiler.cxx_standard   2017

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

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} AUTHORS COPYING README.md ${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

}
