# -*- 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           cmake 1.1
PortGroup           legacysupport 1.1

# LegacySupport is needed for strnlen before 10.7
legacysupport.newest_darwin_requires_legacy 10

github.setup        warmcat libwebsockets 4.5.8 v
github.tarball_from archive
revision            0
categories          devel net
license             LGPL-2.1

maintainers         {gmail.com:slewsys @slewsys} \
                    {judaew @judaew} openmaintainer

description         Canonical libwebsockets.org websocket library

long_description    \
    Libwebsockets is a lightweight pure C library built to use minimal \
    CPU and memory resources, and provide fast throughput in both directions \
    as client or server.

checksums           rmd160  a29d8e292407c6ce065945a2cef392e360691028 \
                    sha256  b6ade658f4af3a823d0dc806ae5ef0623f0f4f5e2aeb895a0f77c4783840c30e \
                    size    20167661

depends_lib-append  path:lib/libssl.dylib:openssl \
                    port:zlib \
                    port:libev \
                    port:libuv

# https://trac.macports.org/ticket/65706
compiler.blacklist-append *gcc-4.*

platform powerpc {
    # Without this, Rosetta pulls out Xcode clang
    compiler.blacklist-append clang
}

# Set LWS_BUILD_HASH directly. Otherwise, it will require a git repository.
configure.args-append \
                    -DLWS_BUILD_HASH="no_hash" \
                    -DLWS_IPV6=ON \
                    -DLWS_UNIX_SOCK=ON \
                    -DLWS_WITHOUT_TESTAPPS=ON \
                    -DLWS_WITH_ACME=ON \
                    -DLWS_WITH_HTTP2=1 \
                    -DLWS_WITH_HTTP_PROXY=ON \
                    -DLWS_WITH_LIBEV=ON \
                    -DLWS_WITH_LIBUV=ON \
                    -DLWS_WITH_RANGES=ON \
                    -DLWS_WITH_SOCKS5=ON \
                    -DLWS_WITH_ZIP_FOPS=ON

post-extract {
    reinplace "s|-Werror||g" ${worksrcpath}/CMakeLists.txt
}

post-destroot {
    delete ${destroot}${prefix}/share/${name}-test-server
}
