# $Id: Portfile 57375 2009-09-10 08:16:41Z ryandesign@macports.org $

PortSystem      1.0
PortGroup       xcode 1.0

name            curlhandle
set my_name     CURLHandle
version         1.9
categories      devel framework
maintainers     nomaintainer
description     CURLHandle is a framework wrapper around a CURL

long_description \
    ${description}

homepage        http://curlhandle.sourceforge.net/
master_sites    ${homepage}
distname        ${my_name}_${version}
extract.suffix  .tgz

checksums       md5 7b1d79b09777b0818370ea1b5b2f002a \
                sha1 76e4ac1e40397afa00035a57ab10573d2e1e3f38 \
                rmd160 4620ce536d636da764d60835c80bd374b9a747e4

# curlhandle is linked against curl statically so it only needs it at build time.
depends_build   port:curl

xcode.project       ${my_name}Source/${my_name}.pbproj
xcode.destroot.type framework

post-patch {
    set pbxproject ${worksrcpath}/${xcode.project}/project.pbxproj

    reinplace "s|/tmp/curl|${worksrcpath}/curl|g" ${pbxproject}
    reinplace "s|/usr/local/lib/libcurl|${prefix}/lib/libcurl|g" ${pbxproject}
}

extract.dir ${worksrcpath}

pre-extract {
    file mkdir ${worksrcpath}
}

post-destroot {
    xinstall -d ${destroot}/Library/Frameworks
    copy "${worksrcpath}/[file dirname ${xcode.project}]/build/UninstalledProducts/${my_name}.framework" \
        ${destroot}/Library/Frameworks

    set framework /Library/Frameworks/${my_name}.framework
    set docdir ${framework}/Versions/A/Resources/Documentation
    xinstall -d ${destroot}${docdir}
    eval xinstall -m 0644 [glob ${worksrcpath}/Documentation/*.html] ${destroot}${docdir}
    system "cd ${destroot}${framework} && ln -s Versions/A/Resources"
}

universal_variant   no

livecheck.type  regex
livecheck.url   ${homepage}
livecheck.regex <td>(\\d+(?:\\.\\d+)*)</td>

