# -*- 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 2025.05
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         {@barracuda156 gmail.com:vital.had} openmaintainer
categories          lang perl
license             Artistic-2
homepage            https://rakudo.org/
# master_sites      https://rakudo.org/downloads/rakudo/

github.tarball_from releases

checksums           rmd160  d792cd9cdbb66643c51d018585c965d7f794c82b \
                    sha256  8dcfe832801aab6c45de07c053c3ce528cc9b0fb0d3c89143e0602346c62a210 \
                    size    7060873

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

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