# -*- 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

name                kelbt
version             0.15
categories          lang textproc devel
platforms           darwin
maintainers         hhhh.org:wiml
license             GPL-2+
description         Backtracking LALR(1) parser generator
long_description    Kelbt generates backtracking LALR(1) parsers. \
                    Where traditional LALR(1) parser generators \
                    require static resolution of shift/reduce \
                    conflicts, Kelbt generates parsers that handle \
                    conflicts by backtracking at runtime. Kelbt is \
                    able to generate a parser for any context-free \
                    grammar that is free of hidden left recursion.

homepage            http://www.complang.org/kelbt/
master_sites        ${homepage}

checksums           rmd160  baa8a9d616f2594fe0315c3b059a1286e8ac7ccc \
                    sha256  000ae8e0906f34de13c3448f2422065e48407b6d85c61bbe51490ffdab0bc565

patchfiles          invalid_cxx.patch

variant universal {}

# configure does substitution of CXXFLAGS but Makefile uses CFLAGS for some reason
# configure also doesn't substitute LDFLAGS
build.args          CFLAGS="${configure.cxxflags} [get_canonical_archflags cxx]" \
                    LDFLAGS="[get_canonical_archflags ld]"

test.run            yes
test.dir            ${worksrcpath}/test
test.target

destroot.destdir    prefix=${destroot}${prefix}

# TODO: Install kelbt.vim as well?

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        COPYING \
        CREDITS \
        ChangeLog \
        TODO \
        ${destroot}${docdir}
}

livecheck.type      regex
livecheck.regex     ${name}-(\[0-9.\]+)${extract.suffix}