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

sourcehut.setup     emersion mrsh a858396b
version             0.0.0-20220914
revision            0
platforms           any
checksums           rmd160  ba54f6093edf4fa1f8a60fee3e8f469ac26d134b \
                    sha256  d7fa79295a51ae30f4476499b2c0506223a4e18b6a5b696c00ece0866c3c6861 \
                    size    83745

description         A minimal POSIX shell.
long_description \
    mrsh is a minimal shell striving for POSIX compliance, no less, no more.

categories          shells
maintainers         nomaintainer
license             MIT

depends_build       path:bin/pkg-config:pkgconfig

# legacy-support: strndup, getline
legacysupport.newest_darwin_requires_legacy 10

patchfiles-append   configure.patch \
                    frontend-readline.c.patch

compiler.c_standard 1999

configure.env-append PKG_CONFIG=${prefix}/bin/pkg-config
configure.args-append --without-readline

if {![variant_isset readline]} {
    default_variants +libedit
}

variant readline description {Enable readline support} conflicts libedit {
    depends_lib-append      port:readline
    configure.args-replace  --without-readline --with-readline=readline
    configure.cflags-append -DHAVE_READLINE \
                            -DHAVE_READLINE_REPLACE_LINE
}
variant libedit description {Enable libedit support} conflicts readline {
    depends_lib-append      port:libedit
    configure.args-replace  --without-readline --with-readline=libedit
    configure.cflags-append -DHAVE_EDITLINE
}

platform darwin {
    if {${os.major} < 11} {
        # O_CLOEXEC was added in Mac OS X 10.7. Only apply this patch on
        # system versions which need it.
        patchfiles-append   cloexec.patch
    }
}
