# $Id: Portfile 120108 2014-05-15 18:04:37Z dluke@macports.org $

PortSystem 1.0

name			subversion-javahlbindings
version			1.8.9
categories		devel java
platforms		darwin
maintainers		geeklair.net:dluke blair
description		Java (javahl) bindings for the subversion version control system (svn)
license			Apache-2

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		http://subversion.apache.org/
master_sites		apache:subversion
use_bzip2		yes
checksums	md5	bd495517a760ddd764ce449a891971db \
		sha1	424ee12708f39a126efd905886666083dcc4eeaf \
		rmd160	768752414673988b23b8257c5d13e889daaa229d
		
distname		subversion-${version}
dist_subdir		subversion

depends_build		port:junit

depends_lib		port:expat \
			port:apr port:apr-util \
			port:db46 port:subversion \
			port:sqlite3 port:gettext \
			port:libiconv port:serf1 \
			port:cyrus-sasl2 \
			port:libmagic port:libcomerr \
			port:zlib

configure.args		--with-berkeley-db=:${prefix}/include/db46:${prefix}/lib/db46:db-4.6 \
			--with-apr=${prefix}/bin/apr-1-config \
			--with-apr-util=${prefix}/bin/apu-1-config --without-apxs \
			--mandir=\\\${prefix}/share/man \
			--with-serf=${prefix} \
			--with-sasl=${prefix} \
			--with-libmagic=${prefix} \
			--without-gnome-keyring \
			--enable-javahl --without-jikes \
			--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:db46
			configure.args-delete	--with-berkeley-db=:${prefix}/include/db46:${prefix}/lib/db46:db-4.6
			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
				}

pre-activate	{
		#- this port used to create a symlink directly in ${prefix} which was fixed in 1.8.1_1
		#- we need to remove this symlink fromo ${prefix} though, so upgrades work
		#- this can eventually be removed, origionally added 2013-07-25
		set badfile ${prefix}/lib/libsvnjavahl-1.jnilib
		if {[file exists ${badfile}] && [registry_file_registered ${badfile}] == "0"} {
			if {[catch {delete ${badfile}}]} {
				ui_warn "Cannot delete ${badfile}; please remove it manually"
			}
		}

		}

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