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

# clock_gettime
legacysupport.newest_darwin_requires_legacy 15

name                    libmongoose
github.setup            cesanta mongoose 7.19
revision                0
categories              devel net
maintainers             nomaintainer
license                 GPL-2
description             Embedded Web Server / Embedded Networking Library
long_description        {*}${description}
homepage                https://mongoose.ws
checksums               rmd160  53ab232841491ff8f9580af320e205647f808e1c \
                        sha256  7ae38c9d673559d1d9c1bd72c0bdd4a98a2cae995e87cae98b4604d5951762b8 \
                        size    13648493
github.tarball_from     archive

# Patches from https://github.com/xfangfang/wiliwili
patchfiles-append       0001-Support-CMake-and-Nintendo-Switch.patch \
                        0002-Add-arpa-inet.h-for-switch.patch \
                        0003-Disable-SO_EXCLUSIVEADDRUSE-in-Windows-as-we-need-th.patch \
                        0004-support-psv.patch \
                        0005-Support-enable-ipv6.patch

patchfiles-append       patch-dynamic-lib.diff

compiler.c_standard     1999

configure.args-append   -DBUILD_SHARED_LIBS=ON \
                        -DMG_ENABLE_IPV6=ON

destroot {
    copy ${cmake.build_dir}/${name}.dylib ${destroot}${prefix}/lib/
    xinstall -m 644 ${worksrcpath}/mongoose.h ${destroot}${prefix}/include/
    system "install_name_tool -id ${prefix}/lib/${name}.dylib ${destroot}${prefix}/lib/${name}.dylib"
}
