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

# clock_gettime
legacysupport.newest_darwin_requires_legacy 15

github.setup            verilator verilator 5.038 v
revision                0
categories              science electronics
license                 {LGPL-3 Artistic-2}
maintainers             {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
description             Verilog compiler and simulator
long_description        Verilator is a {*}${description}.

checksums               rmd160  e91ac49bf49836e9e0faa04780a22f16f86e65c3 \
                        sha256  f8c03105224fa034095ba6c8a06443f61f6f59e1d72f76b718f89060e905a0d4 \
                        size    35611791
github.tarball_from     archive

# https://github.com/verilator/verilator/pull/6292
patchfiles              0001-verilatedos.h-improve-powerpc-support.patch \
                        0002-verilatedos_c.h-do-not-include-cpuid.h-on-powerpc.patch

compiler.cxx_standard   2014

use_autoconf            yes

depends_lib-append      port:systemc

installs_libs           no

set perl_ver            5.36
set py_ver              3.11
set py_ver_nodot        [string map {. {}} ${py_ver}]

depends_build-append    port:help2man

depends_lib-append      port:perl${perl_ver}
configure.perl          ${prefix}/bin/perl${perl_ver}

depends_build-append    port:flex
configure.env-append    LEX=${prefix}/bin/flex

depends_build-append    port:bison
configure.env-append    YACC=${prefix}/bin/bison

depends_lib-append      port:python${py_ver_nodot}
configure.python        ${prefix}/bin/python${py_ver}
configure.env-append    PYTHON3=${configure.python}

post-patch {
    foreach fl {verilator verilator_coverage verilator_includer} {
        reinplace "s|^#!/usr/bin/env perl\$|#!${configure.perl}|" ${worksrcpath}/bin/${fl}
    }
    foreach fl {verilator_ccache_report verilator_difftree verilator_gantt verilator_profcfunc} {
        reinplace "s|^#!/usr/bin/env python3\$|#!${configure.python}|" ${worksrcpath}/bin/${fl}
    }
}
