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

set real_name       rtorrent
github.setup        rakshasa ${real_name} 0.16.18 v
revision            0
conflicts           ${real_name}-devel
categories          net p2p
maintainers         nomaintainer
license             {GPL-2+ OpenSSLException}
description         Console-based BitTorrent client
long_description    rTorrent is a console-based BitTorrent client. It aims to \
                    be a fully-featured and efficient client with the ability to \
                    run in the background using screen. It supports fast-resume \
                    and session management.
checksums           rmd160  74f470bef8bedce8beaeb306537cdabe4e4122cc \
                    sha256  0c7d4902cc914fabe984284330333c7b82aec9951c55915712cdd10acaae65cb \
                    size    868689
github.tarball_from releases

depends_build-append \
                    port:libtool \
                    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:libtorrent \
                    port:ncurses \
                    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   2011

configure.args      --disable-debug \
                    --mandir=${prefix}/share/man \
                    --with-xmlrpc-c=no

# https://github.com/rakshasa/rtorrent/issues/1896
if {[string match *gcc* ${configure.compiler}] && ${configure.build_arch} in [list arm i386 ppc]} {
    configure.ldflags-append \
                    -latomic
}

legacysupport.redirect_bins rtorrent

variant xmlrpc description "Enable XMLRPC interface" {
    configure.args-replace  --with-xmlrpc-c=no --with-xmlrpc-c
    depends_lib-append      port:xmlrpc-c
}

# https://github.com/rakshasa/rtorrent/issues/1808
notes "
You may need to set ulimit before running rtorrent:
`ulimit -n 2048`
"
