# -*- 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           active_variants 1.1
PortGroup           compiler_blacklist_versions 1.0
PortGroup           conflicts_build 1.0
PortGroup           cxx11 1.1
PortGroup           github 1.0

github.setup        arvidn libtorrent 1_2_2 libtorrent-
name                libtorrent-rasterbar
version             [string map {_ .} ${version}]
license             BSD
categories          net
maintainers         {devans @dbevans} openmaintainer
platforms           darwin
homepage            https://libtorrent.org/

description         A C++ bittorrent library (not the same as port libtorrent)

long_description    A C++ bittorrent library designed to run on anything from embedded systems to large scale \
                    seed servers. It comes with python bindings and detailed documentation.

checksums           rmd160  958815f337d4ff51cf4c6c095463398110c12710 \
                    sha256  41ff8d269c1e988fec5d2f50f6588af9e5bd2866e5bab96e5a12c8bdccb734f8 \
                    size    3584080

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

depends_lib         port:boost \
                    path:lib/libssl.dylib:openssl

patchfiles          patch-configure.ac.diff

# don't overwrite any existing blacklist
# Apple clang less than 900.0.39.2 fails to build
compiler.blacklist-append  *gcc-3.* *gcc-4.* {clang < 900.0.39.2}

configure.args      --disable-silent-rules \
                    --enable-python-binding \
                    --with-boost-libdir="${prefix}/lib" \
                    --with-boost-python="boost_python-mt"

configure.cmd       ./autotool.sh && ./configure

universal_variant   no

conflicts_build     ${name}

variant python27 conflicts python37 description {Build bindings for Python 2.7} {
        require_active_variants boost python27
        depends_lib-append port:python27
        configure.python ${prefix}/bin/python2.7
        configure.env-append \
                PYTHON_INSTALL_PARAMS=--prefix=${destroot}${frameworks_dir}/Python.framework/Versions/2.7 \
                PYTHON_EXTRA_LIBS=
}

variant python37 conflicts python27 description {Build bindings for Python 3.7} {
        require_active_variants boost python37
        depends_lib-append port:python37
        configure.python ${prefix}/bin/python3.7
        configure.env-append \
                PYTHON_INSTALL_PARAMS=--prefix=${destroot}${frameworks_dir}/Python.framework/Versions/3.7 \
                PYTHON_EXTRA_LIBS=
}

variant error_logging description {Enable logging of errors to disk} {
        configure.args-append --enable-logging=errors
}

if {![variant_isset python37]} {
    default_variants    +python27
}