#!/usr/bin/perl

# A copy of perldist that does some strawberry-specific actions

use 5.006;
use strict;
use warnings;
use Params::Util qw{ _IDENTIFIER };
use Pod::Usage;
use Getopt::Long;
use URI;
use Perl::Dist::Machine;
use Perl::Dist::Strawberry;

use vars qw{$VERSION};
BEGIN {
	$VERSION = '1.04';
}





#####################################################################
# Handle Options

my $PERL_VERSION = undef;
my $CPAN         = undef;
my $BINARY_ROOT  = undef;
my $FORCE        = undef;
my $result       = GetOptions(
	"perl_version=s" => \$PERL_VERSION,
	"cpan=s"         => \$CPAN,
	"binary_root=s"  => \$BINARY_ROOT,
	"force"          => \$FORCE,
);

# Get the distribution class name
my $class = 'Perl::Dist::Strawberry';
unless ( $class->isa('Perl::Dist') ) {
	die "$class is not a Perl::Dist subclass";
}





# Generate options and hand off to the class
my %options = (
	# 5.8.8 may not build properly under
	# a directory with spaces in it.
	temp_dir => 'C:\\tmp',
);
if ( defined $PERL_VERSION ) {
	$options{perl_version} = $PERL_VERSION;
}
if ( defined $CPAN ) {
	$options{cpan} = URI->new( $CPAN );
}
if ( defined $BINARY_ROOT ) {
	$options{binary_root} = $BINARY_ROOT;
}
if ( defined $FORCE ) {
	$options{force} = 1;
}

# Create the machine
my $machine = Perl::Dist::Machine->new(
	class  => 'Perl::Dist::Strawberry',
	common => \%options,
);
$machine->add_dimension('version');
$machine->add_option('version',
	perl_version => '5100',
	portable     => 1,
);
$machine->add_option('version',
	perl_version => '5100',
);
$machine->add_option('version',
	perl_version => '588',
);

unless ( $machine->run ) {
	die("Failed to run");
}

chdir $machine->output;

exit(0);
