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

PortSystem          1.0
PortGroup           github 1.0

github.setup        tadzik panda 2016.02
description         Perl 6 module installer 
long_description    ${description}
maintainers         mojca coleda.com:will openmaintainer
categories          lang perl
license             Artistic-2
platforms           darwin

checksums           rmd160  3822231cf9077afecbca73087bf5bf08ec53c862 \
                    sha256  736b2350441b40b6ef09512370b190e7ff16acca1f697746819964678cb447f6

# probably also MoarVM, nqp
depends_build       port:git \
                    port:rakudo
depends_run         port:rakudo

# not sure if this is considered configure or build
use_configure       no
build.cmd           ${prefix}/bin/perl6 bootstrap.pl
# this doesn't really work anyway
build.target        --prefix=${prefix}

# there must be a better way to do this
destroot {
    set perl6_share ${prefix}/share/perl6
    set src         ${workpath}/.home/.perl6

    # sources
    xinstall -d -m 0755 ${destroot}/${perl6_share}
    foreach d {dist resources short sources} {
        xinstall -d -m 0755 ${destroot}/${perl6_share}/${d}
        foreach f [glob -type f ${src}/${d}/*] {
            xinstall -W ${src}/${d} ${f} ${destroot}/${perl6_share}/${d}
        }
    }

    # bin
    foreach f [glob -type f ${src}/bin/*] {
        # reinplace "s|/usr/bin/env perl6|${prefix}/bin/perl6|g" ${f}
        xinstall ${f} ${destroot}/${prefix}/bin
    }

    # TODO: state file inside panda
}