#!/usr/bin/perl

# Use this script as an alternative to "perl Makefile.PL && make build_perl" if you don't have GHC installed.

=pod

  ./make_build_perl5; 
  perl util/src_to_blib.pl;
  util/prove6 t/01-sanity

There might be a few modules missing, install them from CPAN. You will see the
tc files after you run the tests.

This script is dumb about finding the right 'make' to use.
You may need to edit it to provide the correct value. 

=cut 

$MAKE = 'make';

my @cmds = for_perl5("cd __DIR__ && perl Makefile.PL && $MAKE");

for (@cmds) {
    system($_);
}

####

sub for_perl5 {
    my $cmd = shift;
    $cmd =~ s{\n}{}g;
    my @cmds;
    foreach my $dir (grep { -d } glob('perl5/*')) {
        -e "$dir/Makefile.PL" or next;

        # Skip XS modules for now
        next if glob("$dir/*.xs") or glob("$dir/*.i");

        my $this = $cmd;
        $this =~ s{__DIR__}{$dir}g;
        push @cmds, $this;
    }
    # Changed from Makefile.PL to just return the commands
    return @cmds;
}

# vim:ft=perl