# -*- 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
PortGroup           github 1.0
PortGroup           xcode 1.0

github.setup        karelia CurlHandle 3.1.1 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                curlhandle
set my_name         CURLHandle
categories          devel framework
platforms           {macosx >= 10}
supported_archs     arm64 i386 x86_64
maintainers         nomaintainer
license             public-domain

description         CURLHandle is a framework wrapper around cURL

long_description    {*}${description}

checksums           rmd160  b51edd914a5d8ca06d3244315e44196b1c149a61 \
                    sha256  a6830387b2b869de112b7da260b83ad8ed46cb92351183bbdb406c9b2385828c

depends_lib         port:curl

patch.dir           ${worksrcpath}/${my_name}Source
build.dir           ${patch.dir}

post-extract {
    # Replace the bundled curl library with ours.
    delete {*}[glob ${build.dir}/*dylib*]
    ln -s ${prefix}/lib/libcurl.dylib ${build.dir}
}

patchfiles          patch-CURLFTPSession.m.diff \
                    patch-CURLHandle.xcodeproj-project.pbxproj.diff

xcode.target        ${my_name}

xcode.destroot.type framework

post-destroot {
    set framework ${frameworks_dir}/${my_name}.framework
    delete ${destroot}${framework}/Versions/Current/Frameworks/libcurl.dylib
    set docdir ${framework}/Versions/Current/Resources/Documentation
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 {*}[glob ${worksrcpath}/Documentation/*.html] ${destroot}${docdir}
}