# -*- 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-javahlbindings
version             1.14.3
revision            0

categories          devel java
platforms           darwin
license             Apache-2
maintainers         nomaintainer

description         Java (javahl) 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 java bindings provide access to subversion API from java.

homepage            https://subversion.apache.org/

master_sites        apache:subversion
use_bzip2           yes

checksums           rmd160  18fb11f2e65213a2878b57ef807864b245f57cc5 \
                    sha256  949efd451a09435f7e8573574c71c7b71b194d844890fa49cd61d2262ea1a440 \
                    size    8569985

distname            subversion-${version}
dist_subdir         subversion

depends_build-append \
                    port:pkgconfig \
                    port:gettext \
                    port:junit

depends_lib-append  port:apr \
                    port:apr-util \
                    port:cyrus-sasl2 \
                    port:db48 \
                    port:expat \
                    port:gettext-runtime \
                    port:libmagic \
                    port:libutf8proc \
                    port:lz4 \
                    port:serf1 \
                    port:subversion \
                    port:sqlite3 \
                    port:zlib

configure.args      --with-berkeley-db=:${prefix}/include/db48:${prefix}/lib/db48:db-4.8 \
                    --without-gnome-keyring \
                    --without-apxs \
                    --enable-javahl \
                    --without-jikes \
                    --without-boost \
                    --with-junit=${prefix}/share/java/junit.jar

build.target        javahl
destroot.target     install-javahl

use_parallel_build  no

test.run            yes
test.target         check-javahl

destroot.violate_mtree  yes

patchfiles          patch-configure.diff

pre-configure {
    reinplace "s|hardcode_direct=yes|hardcode_direct=no|g" \
        ${worksrcpath}/configure
    reinplace "s|\\(LINK_JAVAHL_CXX.*\\)-rpath|\\1-dynamiclib -rpath|g" \
        ${worksrcpath}/Makefile.in
    reinplace "s|@@DESTROOT@@|${destroot}|g" ${worksrcpath}/configure
}

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

platform darwin 10 {
    pre-fetch {
        if {![file isfile "/System/Library/Frameworks/JavaVM.framework/Headers/jni.h"]} {
            return -code error "\n********************\n${name} requires the Java for Mac OS X Developer Package from Apple.\nPlease download and install this package:\nhttps://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=20719\n********************"
        }
    }
}

platform darwin 9 {
    pre-fetch {
        if {![file isfile "/System/Library/Frameworks/JavaVM.framework/Headers/jni.h"]} {
            return -code error "\n********************\n${name} requires the Java for Mac OS X Developer Package from Apple.\nPlease download and install this package:\nhttps://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=20720\n********************"
        }
    }
}

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 {
    file mkdir ${destroot}/Library/Java/Extensions
    system "ln -sf ${prefix}/lib/libsvnjavahl-1.dylib ${destroot}/Library/Java/Extensions/libsvnjavahl.jnilib"
    file mkdir ${destroot}${prefix}/share/java
    system "ln -sf ${prefix}/lib/svn-javahl/svn-javahl.jar ${destroot}${prefix}/share/java/svn-javahl.jar"
}

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

livecheck.type  regex
livecheck.url   https://svn.apache.org/repos/asf/subversion/tags/
livecheck.regex "(\\d+\\.\\d+\\.\\d+)/"
