# -*-perl-*-

use File::Spec::Functions qw[ catdir tmpdir ];


my %Config;

if ( $^O eq 'linux' )
{

    %Config = (
		 'ftp' => q[/usr/bin/ftp],
		 'gpg' => q[/usr/bin/gpg],
		 'gzip' => q[/bin/gzip],
		 'lynx' => q[/usr/bin/lynx],
		 'make' => q[/usr/bin/make],
		 'ncftp' => q[],
		 'ncftpget' => q[],
		 'tar' => q[/bin/tar],
		 'unzip' => q[/usr/bin/unzip],
		 'wget' => q[/usr/bin/wget],
		);

}

elsif ( $^O eq 'solaris' )
{
    %Config = (
		 'ftp' => q[/usr/ucb/ftp],
		 'gpg' => q[],
		 'gzip' => -e q[/usr/bin/gzip]
		 ? q[/usr/bin/gzip] : q[/usr/local/bin/gzip],
		 'lynx' => q[/usr/local/bin/lynx],
		 'make' => q[/usr/ccs/bin/make],
		 'ncftpget' => q[/usr/local/bin/ncftpget],
		 'tar' => q[/usr/local/bin/gtar],
		 'unzip' => q[/usr/bin/unzip],
		 'wget' => q[/usr/local/bin/wget],
		);

}

elsif ( $^O eq 'darwin' )
{

    %Config = (
		 'gpg' => q[],
		 'gzip' => q[/usr/bin/gzip],
		 'lynx' => q[],
		 'tar' => q[/usr/bin/tar],
		 'unzip' => q[/usr/bin/unzip],
		 'wget' => q[/usr/bin/wget],
		);

}

my $MST_ROOT     = $ENV{@MST_ROOT_VAR@}     // '@MST_ROOT@';
my $MST_OTS_ROOT = $ENV{@MST_OTS_ROOT_VAR@} // "@MST_OTS_ROOT_VAL@";

$Config{patches_dir} = catdir( $MST_OTS_ROOT, qw[ import perl patches ] );
$Config{prefs_dir}   = catdir( $MST_OTS_ROOT, qw[ import perl distroprefs ] );
$Config{build_dir}   = catdir( tmpdir, $ENV{USER}, qw[ mst cpan build ] );


# check if running an MST build Perl; if so, install into site, else
# use install_base

use Config ();

my $mst_ots_root = quotemeta( $MST_OTS_ROOT );


if ( $Config::Config{siteprefix} =~ m/$mst_ots_root/ ) {

    $Config{makepl_arg}   = "INSTALLDIRS=site";
    $Config{mbuildpl_arg} = "--installdirs=site";

}

else {

    require SysArch;

    my $install_base = "$MST_OTS_ROOT/$SysArch::Vars{platform_os_generic}";

    $Config{makepl_arg}   = "INSTALL_BASE=$install_base";
    $Config{mbuildpl_arg} = "--install_base=$install_base";

}

@{$CPAN::Config}{keys %Config} = values %Config;

1;
