# -*- 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                antlr
version             2.7.7
revision            5
categories          lang java
license             public-domain
maintainers         {@Dave-Allured noaa.gov:dave.allured} \
                    openmaintainer

description         ${name} is ANother Tool for Language Recognition
long_description    This is ANTLR version 2, ANother Tool for Language Recognition. \
                    ANTLR is a language tool that provides a framework for constructing \
                    recognizers, compilers and translators from grammatical descriptions \
                    containing Java, C# or C++ actions.

homepage            https://www.antlr2.org
master_sites        ${homepage}/download/ \
                    https://www.mirrorservice.org/sites/distfiles.finkmirrors.net/

checksums           rmd160  0b7951a28b748e912721fe0f6de4095d9f8da57d \
                    sha256  853aeb021aef7586bda29e74a6b03006bcb565a755c86b66032d8ec31b67dbb9 \
                    size    1816180

# This because *.a files are arch specific, but test can not currently detect.
test.ignore_archs   yes

patchfiles          patch-configure.diff antlr-DESTDIR.patch \
                    patch-lib-cpp-antlr-CharScanner.hpp.diff

variant             universal {}

if {${configure.build_arch} in [list ppc ppc64]} {
    # It is easier to do this way rather than tweak the PG.
    set java_ver    8
    depends_lib-append \
                    port:openjdk${java_ver}
    configure.env-append \
                    PATH=/Library/Java/JavaVirtualMachines/openjdk${java_ver}/Contents/Home/bin:${prefix}/bin:${prefix}/sbin:/usr/bin:/usr/sbin:/bin:sbin
} else {
    PortGroup       java 1.0

    # Required java version. Java portgroup decides the LTS version and fallback version, as needed.
    java.version    1.4+

    # JDK only needed at build time, but java PG sets lib dependency.
    # So declare no conflict to allow redistribution of binaries.
    license_noconflict  ${java.fallback}
}

configure.env-append \
                    CLASSPATH=.
configure.args      --disable-csharp

build.args          CXXFLAGS="${configure.cxxflags} [get_canonical_archflags cxx]" \
                    LDFLAGS="${configure.ldflags} [get_canonical_archflags ld]"

livecheck.type      regex
livecheck.url       ${homepage}download.html
livecheck.regex     ${name}-(\\d+(?:\\.\\d+)*)
