#!./miniperl -w
my
$osname
= $^O;
my
$file
=
'lib/buildcustomize.pl'
;
if
(
@ARGV
% 2 ) {
my
$dir
=
shift
;
chdir
$dir
or
die
"Can't chdir '$dir': $!"
;
unshift
@INC
,
'lib'
;
}
if
(
@ARGV
) {
$osname
=
$ARGV
[1];
}
my
@toolchain
=
qw(cpan/AutoLoader/lib
dist/Carp/lib
dist/PathTools dist/PathTools/lib
cpan/ExtUtils-Install/lib
cpan/ExtUtils-MakeMaker/lib
cpan/ExtUtils-Manifest/lib
cpan/File-Path/lib
ext/re
dist/Term-ReadLine/lib
dist/Exporter/lib
ext/File-Find/lib
cpan/Text-Tabs/lib
dist/constant/lib
cpan/version/lib
cpan/Getopt-Long/lib
cpan/Text-ParseWords/lib
cpan/ExtUtils-PL2Bat/lib
)
;
push
@toolchain
,
qw(
dist/ExtUtils-ParseXS/lib
cpan/parent/lib
cpan/ExtUtils-Constant/lib
dist/base/lib
)
if
$^O eq
'MSWin32'
;
push
@toolchain
,
'ext/VMS-Filespec/lib'
if
$^O eq
'VMS'
;
unshift
@INC
,
@toolchain
;
my
$cwd
= Cwd::getcwd();
defined
$cwd
or
die
"$0: Can't determine current working directory\n"
;
my
$inc
=
join
",\n "
,
map
{
"q\0$_\0"
}
(
map
{File::Spec::Functions::rel2abs(
$_
,
$cwd
)} (
$^O eq
'MSWin32'
? (
'lib'
,
@toolchain
) : (
@toolchain
,
'lib'
)
));
open
my
$fh
,
'>'
,
$file
or
die
"Can't open $file: $!"
;
my
$error
;
print
$fh
<<"EOT" or $error = "Can't print to $file: $!";
#!perl
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
# This file is generated by write_buildcustomize.pl.
# Any changes made here will be lost!
# We are miniperl, building extensions
# Replace the first entry of \@INC ("lib") with the list of
# directories we need.
splice(\@INC, 0, 1, $inc);
\$^O = '$osname';
__END__
EOT
if
(
$error
) {
close
$fh
or
warn
"Can't unlink $file after error: $!"
;
}
else
{
if
(
close
$fh
) {
do
$file
and
exit
;
$error
=
"Can't load generated $file: $@"
;
}
else
{
$error
=
"Can't close $file: $!"
;
}
}
unlink
$file
or
warn
"Can't unlink $file after error: $!"
;
die
$error
;