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

# _strndup, _memmem
legacysupport.newest_darwin_requires_legacy 10

github.setup        adsr mle 1.7.2 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            1

categories          editors
license             Apache-2
maintainers         {@sikmir disroot.org:sikmir} openmaintainer

description         Small, flexible, terminal-based text editor
long_description    {*}${description}

checksums           rmd160  0e0381fa710a0ef2913f950796e2e155ee24e53e \
                    sha256  6f2c7b51a04875e3e5087aefaca5ce7dd6de23b7f458806ef2c9928afbd06fa7 \
                    size    143641

post-patch {
    reinplace "s|-llua5.4|-llua|g" ${worksrcpath}/Makefile
    reinplace "s|<lua5.4/|<|g" ${worksrcpath}/mle.h

    if {[string match *gcc-4.* ${configure.compiler}]} {
        # cc1: error: unrecognized command line option "-Wno-unused-result"
        reinplace "s|-Wno-unused-result||g" ${worksrcpath}/Makefile
    }
}

configure.cflags-append \
                    -I${prefix}/include/uthash

build.args-append   prefix=${prefix}
destroot.args-append \
                    prefix=${prefix}

depends_lib-append  port:lua \
                    port:pcre2 \
                    port:uthash

post-destroot {
    set mandir ${destroot}${prefix}/share/man/man1
    xinstall ${worksrcpath}/mle.1 ${mandir}
}
