# -*- 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       muniversal 1.0

name            neon
version         0.33.0
revision        0
categories      www
maintainers     nomaintainer
description     An HTTP and WebDAV client library with a C interface
license         LGPL-2+

long_description \
                neon is an HTTP and WebDAV client library with a C language API. \
                It provides a high-level interface to HTTP and WebDAV methods and a \
                low-level interface to HTTP request handling, easily allowing the \
                implementation of new methods.

homepage        https://notroj.github.io/neon
master_sites    ${homepage}

depends_build   port:pkgconfig
depends_lib     port:expat \
                port:gettext \
                port:libiconv \
                port:kerberos5 \
                port:libcomerr \
                port:libproxy \
                path:lib/libssl.dylib:openssl \
                port:zlib

checksums       rmd160  73dae619e37495488cb5976eda157f0f7c6edc93 \
                sha256  659a5cc9cea05e6e7864094f1e13a77abbbdbab452f04d751a8c16a9447cf4b8 \
                size    912146

patchfiles      libressl.patch

configure.args  --with-ssl \
                --enable-shared \
                --with-expat \
                --with-libproxy

pre-test {
    set x {}

    fs-traverse dir ${worksrcpath} {
        if {[file tail ${dir}] == ".libs" && [file isdirectory ${dir}]} {
            lappend x ${dir}
            continue
        }
    }

    test.env-append DYLD_LIBRARY_PATH=[join ${x} ":"]
}

post-destroot {
    if {[variant_exists universal] && [variant_isset universal]} {
        if {${configure.universal_cppflags} ne ""} {
            reinplace "s|${configure.universal_cppflags}||g" \
                ${destroot}${prefix}/bin/neon-config \
                ${destroot}${prefix}/lib/pkgconfig/neon.pc
        }
        if {${configure.universal_ldflags} ne ""} {
            reinplace "s|${configure.universal_ldflags}||g" \
                ${destroot}${prefix}/bin/neon-config \
                ${destroot}${prefix}/lib/pkgconfig/neon.pc
        }
    }
}

test.run        yes
test.target     check

livecheck.regex  {neon/neon-(\d+(?:\.\d+)*)}
