PortSystem          1.0
PortGroup           muniversal 1.0

name                libsockets
version             2.3.9.9
revision            3
categories          devel net
platforms           darwin
license             GPL-2
maintainers         nomaintainer
description         C++ Sockets is a C++ wrapper for BSD-style sockets.
long_description    {*}${description}

homepage            http://www.alhem.net/Sockets/
master_sites        ${homepage}

checksums           rmd160  9507b1b7e0a4e6a9471c90b2ee8efd73017e58b9 \
                    sha256  5b88723fe26836fb42dc9d8c974e801fdb7a404c27511247e560455bef0ebc60

patchfiles          patch-HttpRequest.cpp.diff \
                    patch-Makefile.diff \
                    TcpSocket.cpp.patch

depends_lib         path:lib/libssl.dylib:openssl port:libxml2

distname            Sockets-${version}

post-extract {
    xinstall -m 755 ${filespath}/configure ${worksrcpath}
    xinstall -m 755 ${filespath}/create-dylib.sh ${worksrcpath}
}

configure.env-append PLATFORM=macosx PREFIX=${prefix}
configure.cflags-append -I${prefix}/include/libxml2
configure.ldflags-append -lxml2
build.target-append libSockets.dylib

pre-destroot {
    set paths {}
    if {[variant_exists universal] && [variant_isset universal]} {
        foreach arch ${universal_archs_to_use} {
            lappend paths ${worksrcpath}-${arch} ${destroot}-${arch}
        }
    } else {
        lappend paths ${worksrcpath} ${destroot}
    }
    foreach {wpath dpath} ${paths} {
        xinstall -d ${dpath}${prefix}/lib
        xinstall -m 755 -W ${wpath} \
            libSockets.1.0.0.dylib libSockets.dylib ${dpath}${prefix}/lib
    }
}

livecheck.type      regex
livecheck.url       http://www.alhem.net/Sockets/download.html
livecheck.regex     Sockets-(\[0-9.\]+)${extract.suffix}