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

# getline, fmemopen
legacysupport.newest_darwin_requires_legacy 16

sourcehut.setup     rwa cgmnlm 1.8
revision            0
categories          net gemini
license             GPL-3
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         ${name} is a colorful Gemini line mode client
long_description    {*}${description}

checksums           rmd160  58366d152b12069d820673f021147b9878c019ff \
                    sha256  09b73b2778351ced258bb5e5409781ad793e7d4900a9ef0f9d95d0977159c5f3 \
                    size    53001

depends_build-append \
                    path:bin/pkg-config:pkgconfig
depends_lib-append  port:bearssl
depends_run-append  port:xdg-utils

patchfiles          patch-client.c.diff

# src/url.c: error: variable 'clen' set but not used [-Werror,-Wunused-but-set-variable]
# src/gmnlm.c: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
# _DARWIN_C_SOURCE is needed due to _XOPEN_SOURCE=700 usage, which otherwise hides some functions.
patchfiles-append   patch-config.sh.diff

if {${os.platform} eq "darwin" && ${os.major} < 17} {
    # The build uses a weird shell script to configure; it does not accept configure.ldflags.
    patchfiles-append \
                    patch-legacy.diff
    post-patch {
        reinplace "s|@PREFIX@|${prefix}|" ${worksrcpath}/config.sh
    }
}

compiler.c_standard 2011
