# -*- 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           cxx11 1.1
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.7/libtorrent-0.13.7.tar.gz

github.setup        rakshasa libtorrent 0.13.7 v

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  e0a6f01eac616cec788cb81995318e7b9fc7baac \
                    sha256  7de1c2e2ebb23ff0f13891f1f865a2ac6899141d8e662b269156c3cb11518a4d \
                    size    356972

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

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} {
    # 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
}