# -*- 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.4.1 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  47023c524c736b75ae7c416d0101f0e1a9f43144 \
                    sha256  472e6cfa77b6f80ff2cc176bc59f6cb2856df7e30e8f31afcbd1fc94ffd2f828 \
                    size    19997574

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
}
