# -*- 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
PortGroup           legacysupport 1.1
PortGroup           openssl 1.0

# O_CLOEXEC: https://github.com/rakshasa/libtorrent/issues/845
legacysupport.newest_darwin_requires_legacy 10

github.setup        rakshasa libtorrent 0.16.20 v
revision            0
conflicts           libtorrent-devel
categories          net devel
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  5d8dee6d37a2d6bc08fb3e958966828242de448b \
                    sha256  f824c9a88dc7c0890476b28248134339163d10159af03127d9e9bbb2097be641 \
                    size    502926
github.tarball_from archive

use_autoreconf      yes

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

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

depends_lib-append  port:curl \
                    port:zlib

# PortGroup           active_variants 1.1
# Provisionally not required anymore.
# https://github.com/rakshasa/rtorrent/wiki/Installing#non-blocking-hostname-lookup-in-curl
# require_active_variants curl ares

compiler.cxx_standard   2017

configure.args      --disable-debug

if {${os.platform} ne "linux"} {
    configure.args-append \
                    --with-kqueue \
                    --without-epoll
}

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