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

name                py-pysvn
version             1.9.22
revision            0

categories-append   devel
license             Apache-1.1
maintainers         nomaintainer

description         Python Subversion Extension (pysvn)
long_description    The pysvn module is a python interface to the Subversion version \
                    control system. This API exposes client interfaces for managing a \
                    working copy, querying a repository, and synchronizing the two.

homepage            https://pysvn.sourceforge.io/

master_sites        sourceforge:pysvn

checksums           rmd160  304166aaa9d832b853727e55dee830fd6335321b \
                    sha256  29f2e0f6dbae2a95f12689e20f4d369035c6093c0e67d8eeac2a0fad6311a3b8 \
                    size    669169

python.versions     27 39 310 311 312

set cxx_stdlibflags {}
if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} ne ""} {
    set cxx_stdlibflags -stdlib=${configure.cxx_stdlib}
}

if {${name} ne ${subport}} {
    depends_lib-append \
                    port:apr \
                    port:subversion

    patch.dir       ${worksrcpath}
    patchfiles      patch-Source_setup_configure.py.diff

    worksrcdir      ${worksrcdir}/Source

    use_configure   yes

    pre-configure {
        reinplace "s|'gcc|'${configure.cc}|g" \
            ${worksrcpath}/setup_configure.py
        reinplace "s|'g\+\+|'${configure.cxx} ${cxx_stdlibflags}|g" \
            ${worksrcpath}/setup_configure.py
    }

    configure.cmd   ${python.bin} setup.py configure
    configure.pre_args
    configure.args  --apr-inc-dir=${prefix}/include/apr-1 \
                    --apu-inc-dir=${prefix}/include/apr-1 \
                    --apr-lib-dir=${prefix}/lib \
                    --svn-bin-dir=${prefix}/bin \
                    --svn-inc-dir=${prefix}/include/subversion-1 \
                    --svn-lib-dir=${prefix}/lib \
                    --link-python-framework-via-dynamic-lookup \
                    --pycxx-dir=${worksrcpath}/../Import/pycxx-7.1.9
    configure.universal_args-delete --disable-dependency-tracking

    post-configure {
        reinplace "s|^\t@|\t|" ${worksrcpath}/Makefile
    }

    build.cmd       make
    build.target

    destroot {
        file mkdir ${destroot}${python.pkgd}
        file copy ${worksrcpath}/pysvn ${destroot}${python.pkgd}

        file copy {*}[glob ${worksrcpath}/../Examples/*] \
            ${destroot}${prefix}/share/doc/${subport}/examples
        file copy {*}[glob ${worksrcpath}/../Docs/*] \
            ${destroot}${prefix}/share/doc/${subport}
    }

    test.run        yes
    test.dir        ${worksrcpath}/../Tests
    test.cmd        make
    test.target

    livecheck.type  none
}
