# $Id: Portfile,v 1.3 2005/08/24 04:08:21 ben Exp $
PortSystem		1.0

name			curlhandle
version			1.9
categories		devel framework
platforms		darwin
maintainers		ben@opendarwin.org
description		CURLHandle is a framework wrapper around a CURL
long_description	${description}
homepage		http://curlhandle.sourceforge.net/
master_sites	${homepage}
set framework	CURLHandle
distname		${framework}_${version}
extract.suffix	.tgz
checksums		md5 7b1d79b09777b0818370ea1b5b2f002a

set xcodebuilddir               build

platform darwin 8 {
if {$xcodeversion == "2.1"} {
        set xcodebuilddir       build/Deployment
}
}

depends_lib		lib:libz.1:zlib \
			lib:libssl.0.9:openssl \
			port:curl

extract.dir		${worksrcpath}
pre-extract		{ file mkdir ${worksrcpath} }

patchfiles		patch-CURLHandle.m
post-patch {
	cd ${worksrcpath}
	reinplace "s|/tmp/curl|${worksrcpath}/curl|g" \
		${framework}Source/${framework}.pbproj/project.pbxproj
	reinplace "s|/usr/local/lib/libcurl|${prefix}/lib/libcurl|g" \
		${framework}Source/${framework}.pbproj/project.pbxproj
	reinplace "s|/Library/Frameworks/${framework}.framework|../${framework}Source/${xcodebuilddir}/${framework}.framework|" \
		${framework}TesterSource/${framework}Tester.pbproj/project.pbxproj
}

use_configure	no

build.dir		${worksrcpath}/${framework}Source
build.type		pbx
build.target	-target ${framework}
build.args		-buildstyle Deployment
post-build {
	cd ${worksrcpath}
	system "install_name_tool \
		-id /Library/Frameworks/${framework}.framework/${framework} \
		${framework}Source/${xcodebuilddir}/${framework}.framework/${framework}"

 	system "mkdir -p ${framework}TesterSource/${xcodebuilddir}"
        system "ln -s ${worksrcpath}/${framework}Source/${xcodebuilddir}/${framework}.framework \
                ${worksrcpath}/${framework}TesterSource/${xcodebuilddir}/${framework}.framework"
	build.dir		${framework}TesterSource
	build.target	-target ${framework}Tester
	system "[command build]"
}

destroot {
	cd ${worksrcpath}
	xinstall -d -m 0755 ${destroot}/Library/Frameworks
	system "cp -R ${framework}Source/${xcodebuilddir}/${framework}.framework \
		${destroot}/Library/Frameworks"
	xinstall -d -m 0755 ${destroot}/Applications/DarwinPorts
	system "cp -R ${framework}TesterSource/${xcodebuilddir}/${framework}Tester.app \
		${destroot}/Applications/DarwinPorts"
	xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${framework}
	xinstall -m 0644 ReleaseNotes.txt DevNotes.txt \
		${destroot}${prefix}/share/doc/${framework}
	system "cp -R Documentation \
		${destroot}${prefix}/share/doc/${framework}/Documentation"
}

