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

name                subversion-perlbindings
version             1.14.3
revision            0

categories          devel perl
maintainers         nomaintainer
license             Apache-2

description         Perl bindings for the subversion version control system (svn)
long_description    Subversion (svn) is a version control system designed to be \
                    as similar to cvs(1) as possible, while fixing many \
                    outstanding problems with cvs(1). The perl bindings \
                    provide access to subversion API from perl.

homepage            https://subversion.apache.org/

set perl5.branches {5.28 5.30 5.32 5.34}
foreach branch ${perl5.branches} {
    set p_idx [lsearch ${perl5.branches} ${branch}]
    set other_perls [lreplace ${perl5.branches} $p_idx $p_idx]

    subport ${name}-${branch} {
        set perl5.branch $branch
        foreach c_perl ${other_perls} {
            conflicts-append ${name}-${c_perl}
        }
    }
}

if {${subport} eq ${name}} {
    PortGroup       stub 1.0

    # depend on a default perl version
    depends_lib     port:${name}-5.34
    # avoid conflict with old version when upgrading
    replaced_by     ${name}-5.34

    livecheck.type  regex
    livecheck.url   https://svn.apache.org/repos/asf/subversion/tags/
    livecheck.regex "(\\d+\\.\\d+\\.\\d+)/"
} else {
    master_sites    apache:subversion
    use_bzip2       yes
    checksums       rmd160  18fb11f2e65213a2878b57ef807864b245f57cc5 \
                    sha256  949efd451a09435f7e8573574c71c7b71b194d844890fa49cd61d2262ea1a440 \
                    size    8569985

    distname        subversion-${version}
    dist_subdir     subversion

    patchfiles      dynamic_lookup-11.patch

    test.run        yes
    test.target     check-swig-pl

    use_parallel_build no

    depends_build-append \
                    port:pkgconfig \
                    port:swig

    depends_lib-append \
                    port:apr \
                    port:apr-util \
                    port:expat \
                    port:gettext-runtime \
                    port:libmagic \
                    port:libutf8proc \
                    port:lz4 \
                    port:perl${perl5.branch} \
                    port:sqlite3 \
                    port:subversion \
                    port:zlib

    configure.args  --with-berkeley-db=:${prefix}/include/db48:${prefix}/lib/db48:db-4.8 \
                    --without-gnome-keyring \
                    --without-apxs \
                    --without-boost

    configure.env   ac_cv_path_PERL=${prefix}/bin/perl${perl5.branch}

    build.target    swig-pl
    destroot.target install-swig-pl-lib DESTDIR=${destroot} && \
                    cd "${worksrcpath}/subversion/bindings/swig/perl/native" &&\
                    make pure_install

    destroot.args   INSTALLDIRS=vendor

    pre-configure {
        reinplace "s|hardcode_direct=yes|hardcode_direct=no|g" \
            ${worksrcpath}/configure
    }

    post-configure {
        reinplace "s|need_relink=yes|need_relink=no|g" \
            ${worksrcpath}/libtool
    }

    variant no_bdb description {Build without support for BerkeleyDB repositories} {
        depends_lib-delete      port:db48
        configure.args-delete   --with-berkeley-db=:${prefix}/include/db48:${prefix}/lib/db48:db-4.8
        configure.args-append   --without-berkeley-db
    }

    post-destroot {
        foreach packlist [exec find ${destroot} -name .packlist] {
            ui_info "Fixing packlist ${packlist}"
            reinplace "s|${destroot}||" ${packlist}
        }
    }

    # CarbonCore/MacTypes.h: No such file or directory
    platform puredarwin {
        configure.args-append   --disable-keychain
    }

    livecheck.type  none
}
