6 my $file = 'lib/buildcustomize.pl';
10 chdir $dir or die "Can't chdir '$dir': $!";
15 # Used during cross-compilation.
19 # To clarify, this isn't the entire suite of modules considered "toolchain"
20 # It's not even all modules needed to build ext/
21 # It's just the source paths of the (minimum complete set of) modules in ext/
22 # needed to build the nonxs modules
23 # After which, all nonxs modules are in lib, which was always sufficient to
24 # allow miniperl to build everything else.
25 # Getopt::Long is here because it's used by podlators, which is one of the
27 # Term::ReadLine is not here for building but for allowing the debugger to
28 # run under miniperl when nothing but miniperl will build :-(.
29 # Text::ParseWords is required in ExtUtils::Liblist::Kid
31 my @toolchain = qw(cpan/AutoLoader/lib
33 dist/PathTools dist/PathTools/lib
34 cpan/ExtUtils-Install/lib
35 cpan/ExtUtils-MakeMaker/lib
36 cpan/ExtUtils-Manifest/lib
39 dist/Term-ReadLine/lib
46 cpan/Text-ParseWords/lib
47 cpan/ExtUtils-PL2Bat/lib
50 # These are for XS building on Win32, since nonxs and xs build simultaneously
51 # on Win32 if parallel building
53 dist/ExtUtils-ParseXS/lib
55 cpan/ExtUtils-Constant/lib
56 ) if $^O eq 'MSWin32';
57 push @toolchain, 'ext/VMS-Filespec/lib' if $^O eq 'VMS';
59 unshift @INC, @toolchain;
60 require File::Spec::Functions;
63 my $cwd = Cwd::getcwd();
66 or die "$0: Can't determine current working directory\n";
68 # lib must be last, as the toolchain modules write themselves into it
69 # as they build, and it's important that @INC order ensures that the partially
70 # written files are always masked by the complete versions.
72 my $inc = join ",\n ",
74 (map {File::Spec::Functions::rel2abs($_, $cwd)} (
75 # faster build on the non-parallel Win32 build process
76 $^O eq 'MSWin32' ? ('lib', @toolchain ) : (@toolchain, 'lib')
79 open my $fh, '>', $file
80 or die "Can't open $file: $!";
84 # If any of the system's build tools are written in Perl, then this module
85 # may well be loaded by a much older version than we are building. So keep it
86 # as backwards compatible as is easy.
87 print $fh <<"EOT" or $error = "Can't print to $file: $!";
90 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
91 # This file is generated by write_buildcustomize.pl.
92 # Any changes made here will be lost!
94 # We are miniperl, building extensions
95 # Replace the first entry of \@INC ("lib") with the list of
96 # directories we need.
97 splice(\@INC, 0, 1, $inc);
104 or warn "Can't unlink $file after error: $!";
108 $error = "Can't load generated $file: $@";
110 $error = "Can't close $file: $!";
114 # It's going very wrong, so try to remove the botched file.
117 or warn "Can't unlink $file after error: $!";
120 # ex: set ts=8 sts=4 sw=4 et: