PortSystem 1.0

name			subversion-python27bindings
version			1.12.2
categories		devel python
platforms		darwin
maintainers		{geeklair.net:dluke @danielluke}
description		Python 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 python bindings \
			provide access to subversion API from python.

homepage		https://subversion.apache.org/
master_sites		apache:subversion
use_bzip2		yes
checksums	rmd160	8197a89bf5879f1a871ae0547dfdaecb8fa052ac \
		sha256	3bd0b5c8e4c5175263dc9a92fd9aef94ce917e80af034f26fe5c45fde7e0f771 \
		size	8506584
		
distname		subversion-${version}
dist_subdir		subversion

depends_lib		port:expat \
			port:apr port:apr-util \
			port:db48 port:subversion \
			port:python27 \
			port:sqlite3 \
			port:gettext port:libiconv \
			port:serf1 port:cyrus-sasl2 \
			port:libmagic port:libcomerr \
			port:zlib port:libutf8proc \
			port:lz4

depends_build		port:swig

post-patch {
	system "export LANG=C; cd ${worksrcpath}; find build* Makefile.in subversion/bindings/swig/python -type f -print0 | xargs -0 sed -i -e 's/libsvn_swig_py/libsvn_swig_py27/g'"
	file rename \
		${worksrcpath}/subversion/bindings/swig/python/libsvn_swig_py \
		${worksrcpath}/subversion/bindings/swig/python/libsvn_swig_py27
}

configure.args		--with-berkeley-db=:${prefix}/include/db48:${prefix}/lib/db48:db-4.8 \
			--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
if {[vercmp [macports_version] 2.5.99] >= 0} {
configure.env		ac_cv_path_PYTHON=${prefix}/bin/python2.7 \
			ac_cv_python_includes=-I${frameworks_dir}/Python.framework/Versions/2.7/include/python2.7 \
			"ac_cv_python_link=${configure.cc} -L${prefix}/lib -bundle -undefined dynamic_lookup ${frameworks_dir}/Python.framework/Versions/2.7/Python" \
			"ac_cv_python_libs=-L${prefix}/lib -bundle -undefined dynamic_lookup ${frameworks_dir}/Python.framework/Versions/2.7/Python" \
			ac_cv_python_compile=${configure.cc}
} else {
configure.env		ac_cv_path_PYTHON=${prefix}/bin/python2.7 \
			ac_cv_python_includes=-I${frameworks_dir}/Python.framework/Versions/2.7/include/python2.7 \
			ac_cv_python_link="${configure.cc} -L${prefix}/lib -bundle -undefined dynamic_lookup ${frameworks_dir}/Python.framework/Versions/2.7/Python" \
			ac_cv_python_libs="-L${prefix}/lib -bundle -undefined dynamic_lookup ${frameworks_dir}/Python.framework/Versions/2.7/Python" \
			ac_cv_python_compile=${configure.cc}
}

use_parallel_build      yes
build.target		swig-py
destroot.target		install-swig-py DESTDIR=${destroot}

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

pre-test {
			set x {}
			fs-traverse dir ${worksrcpath}/subversion {
				if {[file tail ${dir}] == ".libs" && [file isdirectory ${dir}]} {
				lappend x ${dir}
				continue
				}
			}
			test.env-append DYLD_LIBRARY_PATH=[join ${x} ":"]
			}

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 {
		set PYTHON_PATH ${frameworks_dir}/Python.framework/Versions/2.7/lib/python2.7

		xinstall -m 755 -d ${destroot}${PYTHON_PATH}/site-packages
		xinstall -m 755 ${filespath}/svn-python.pth \
			${destroot}${PYTHON_PATH}/site-packages
		reinplace "s|@PREFIX@|${prefix}|g" \
			${destroot}${PYTHON_PATH}/site-packages/svn-python.pth

		file rename "${destroot}${prefix}/lib/svn-python" \
			"${destroot}${prefix}/lib/svn-python2.7"
		}

# 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+)/"