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

name                bison
subport             bison-runtime {}

epoch               1
version             3.8.2
if {${subport} eq "bison"} {
    revision        2
} else {
    revision        0
}
categories          devel
if {${subport} eq "bison-runtime"} {
    supported_archs noarch
    platforms       any
}
# an exception in file "parse-gram.h" allows generated parser not to be GPL
license             {GPL-3+ Permissive}
maintainers         {mascguy @mascguy} openmaintainer

if {${subport} eq "bison-runtime"} {
    description         Localization support for Bison-generated parsers
    long_description    The Bison parser generator provides \
                        translations for its parser diagnostics. \
                        Programs that contain Bison-generated parsers \
                        can use these translations to generate \
                        localized error messages.
    installs_libs       no
} else {
    description         The Yacc-compatible Parser Generator
    long_description    Bison is a general-purpose parser generator \
                        that converts an annotated context-free \
                        grammar into a deterministic LR or generalized \
                        LR (GLR) parser employing LALR(1) parser \
                        tables. As an experimental feature, Bison can \
                        also generate IELR(1) or canonical LR(1) \
                        parser tables. Once you are proficient with \
                        Bison, you can use it to develop a wide range \
                        of language parsers, from those used in simple \
                        desk calculators to complex programming \
                        languages.

    depends_lib-append \
                        port:gettext-runtime \
                        port:libiconv \
                        port:libtextstyle \
                        port:m4
    depends_run-append \
                        port:bison-runtime
    depends_skip_archcheck-append \
                        m4
    # libtextstyle is only used by the bison executable, not the code
    # that is incorporated into dependents. Since it is GPLv3, it would
    # otherwise make GPLv2-only dependents appear non-distributable.
    license_noconflict  libtextstyle
}
homepage            https://www.gnu.org/software/bison

master_sites        gnu
use_xz              yes

checksums           rmd160  ece257fb69ba39b80cf46f8b1668346db318e9ca \
                    sha256  9bba0214ccf7f1079c5d59210045227bcf619519840ebfa80cd3849cff5a5bf2 \
                    size    2817324

configure.args      --disable-silent-rules \
                    ac_cv_prog_HAVE_GCJ_IN_PATH= \
                    ac_cv_prog_HAVE_GIJ_IN_PATH= \
                    ac_cv_prog_HAVE_JAVA_IN_PATH= \
                    ac_cv_prog_HAVE_JAVAC_IN_PATH= \
                    ac_cv_prog_HAVE_JIKES_IN_PATH= \
                    ac_cv_prog_HAVE_JRE_IN_PATH= \
                    ac_cv_prog_HAVE_JVIEW_IN_PATH= \
                    ac_cv_prog_VALGRIND=

# Fix for Rosetta: https://trac.macports.org/ticket/64486
platform darwin 10 {
    if {${build_arch} eq "ppc"} {
        configure.args-append \
            --build=powerpc-apple-darwin${os.major} \
            CC="${configure.cc} -arch ppc"
    }
}

if {${subport} eq "bison-runtime"} {
    configure.args-append \
                    gt_cv_func_gnugettext2_libintl=yes
    build.dir       ${worksrcpath}/runtime-po
    livecheck.type  none
} else {
    patchfiles-append skip-runtime-po.patch

    test.run        yes
    test.target     check
}

platform darwin 8 {
    # https://trac.macports.org/ticket/58819
    depends_build-append port:flex
    configure.args-append ac_cv_prog_LEX=${prefix}/bin/flex
}
