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

github.setup        rakudo rakudo 2026.06
revision            0
description         Raku compiler
long_description    Rakudo is a compiler for the Raku language \
                    Rakudo is built using NQP (Not Quite Perl), \
                    which in turn is targeting the Moar virtual machine. \
                    See https://raku.org for more information.
maintainers         nomaintainer
categories          lang perl
license             Artistic-2
homepage            https://rakudo.org/
# master_sites      https://rakudo.org/downloads/rakudo/

github.tarball_from releases

checksums           rmd160  37d5a6cf4ce53a214e0320e99f2010dbbc21ed7d \
                    sha256  62da87c09e9757abd19bb34329b2398ba32c3015665dfa910cc86cde2a2ea6b8 \
                    size    8357755

depends_build-append \
                    path:bin/perl:perl5

depends_lib-append  port:MoarVM \
                    port:nqp

legacysupport.redirect_bins \
                    perl6 perl6-m perl6-debug perl6-debug-m \
                    rakudo rakudo-m rakudo-debug rakudo-debug-m

configure.cmd       ${prefix}/bin/perl Configure.pl
configure.args      --prefix=${prefix} \
                    --backends=moar \
                    --with-nqp=${prefix}/bin/nqp

# Please match compiler blacklist from MoarVM port to avoid failures
compiler.c_standard 2011
compiler.blacklist-append \
                    {clang < 700}

# https://github.com/MoarVM/MoarVM/issues/414
# it's also possible that i386 doesn't build at all
universal_variant   no

# Unsupported by Configure.pl
# configure.universal_args-delete --disable-dependency-tracking

test.run            yes
# test.target       test spectest
# other targets: localtest stresstest ...

# Replicate condition from legacysupport:
if {${os.platform} eq "darwin" && ${configure.cxx_stdlib} ne "libc++"} {
    # After legacysupport has done its job:
    post-activate {
        # Problem: raku and raku-debug are not binaries but symlinks, and when they point to legacysupport wrappers, the latter invoke raku-orig,
        # which does not exist. Specify binary names explicitly. Then symlinks work as if no legacysupport were involved.
        reinplace "s|\${0}-orig|rakudo-orig|" ${prefix}/bin/rakudo
        reinplace "s|\${0}-orig|rakudo-debug-orig|" ${prefix}/bin/rakudo-debug
    }
}
