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

github.setup        cern-fts davix 0_7_5 R_
version             [string map {_ .} ${github.version}]
revision            1
github.tarball_from releases
distname            ${github.project}-${version}

checksums           rmd160  beb97ac2b9009f81c3159efd1fd1f1e375645296 \
                    sha256  d920ca976846875d83af4dc50c99280bb3741fcf8351d5733453e70fa5fe6fc8 \
                    size    4343329

categories          net
maintainers         {jonesc @cjones051073} openmaintainer

description         High-performance file management over WebDAV / HTTP

long_description    Davix aims to make the task of managing files over \
                    HTTP-based protocols simple. It is being developed \
                    by IT-ST at CERN, and while the project's purpose  \
                    is its use on the CERN grid, the functionality     \
                    offered is generic.

license             LGPL-2.1
platforms           darwin

set py_ver          3.7
set py_ver_no_dot   [join [split ${py_ver} "."] ""]

depends_build-append port:pkgconfig \
                     port:python${py_ver_no_dot}

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

configure.args-append -DPYTHON_EXECUTABLE=${prefix}/bin/python${py_ver}

# gtest conflict. Disable tests for now
# https://trac.macports.org/ticket/58955
configure.args-append -DDAVIX_TESTS=FALSE

pre-configure {
    # Force use of macports python in build scripts
    # Find command finds text files containing the string to be replaced.
    set pystringtoreplace "/usr/bin/env python2"
    foreach f [ exec find ${worksrcpath} -type f -and -name "*.py" ] {
        reinplace -q "s|${pystringtoreplace}|${prefix}/bin/python${py_ver}|g" $f
    }
}