This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade ExtUtils::CBuilder from version 0.280223 to 0.280224
[perl5.git] / write_buildcustomize.pl
CommitLineData
5e4c4c91
NC
1#!./miniperl -w
2
3use strict;
fdf90be3
JR
4
5my $osname = $^O;
6my $file = 'lib/buildcustomize.pl';
7
8if ( @ARGV % 2 ) {
5e4c4c91
NC
9 my $dir = shift;
10 chdir $dir or die "Can't chdir '$dir': $!";
11 unshift @INC, 'lib';
12}
13
fdf90be3
JR
14if ( @ARGV ) {
15 # Used during cross-compilation.
16 $osname = $ARGV[1];
17}
b78ac715 18
5e4c4c91
NC
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.
f61462d5
CB
25# Term::ReadLine is not here for building but for allowing the debugger to
26# run under miniperl when nothing but miniperl will build :-(.
5e4c4c91
NC
27
28my @toolchain = qw(cpan/AutoLoader/lib
634ff085 29 dist/Carp/lib
cb8c8458 30 dist/PathTools dist/PathTools/lib
d393d7e5 31 cpan/ExtUtils-Install/lib
5e4c4c91 32 cpan/ExtUtils-MakeMaker/lib
854a00d8 33 cpan/ExtUtils-Manifest/lib
5e4c4c91 34 cpan/File-Path/lib
7353f64c 35 ext/re
f61462d5 36 dist/Term-ReadLine/lib
3110a055 37 dist/Exporter/lib
6de85bb4 38 ext/File-Find/lib
f4e064af 39 cpan/Text-Tabs/lib
70c90635 40 dist/constant/lib
5e4c4c91
NC
41 );
42
3bdc51af
DD
43# Text-ParseWords used only in ExtUtils::Liblist::Kid::_win32_ext()
44# the rest are for XS building on Win32, since nonxs and xs build simultaneously
45# on Win32 if parallel building
46push @toolchain, qw(
47 cpan/Text-ParseWords/lib
48 dist/ExtUtils-ParseXS/lib
49 cpan/Getopt-Long/lib
50 cpan/parent/lib
51 cpan/ExtUtils-Constant/lib
52) if $^O eq 'MSWin32';
2d11a7e9
NC
53push @toolchain, 'ext/VMS-Filespec/lib' if $^O eq 'VMS';
54
55unshift @INC, @toolchain;
56require File::Spec::Functions;
3bdc51af
DD
57require Cwd;
58
59my $cwd = Cwd::getcwd();
5e4c4c91 60
2effe01f 61# lib must be last, as the toolchain modules write themselves into it
5e4c4c91
NC
62# as they build, and it's important that @INC order ensures that the partially
63# written files are always masked by the complete versions.
64
65my $inc = join ",\n ",
66 map { "q\0$_\0" }
3bdc51af 67 (map {File::Spec::Functions::rel2abs($_, $cwd)} (
8ce7a7e8
DD
68# faster build on the non-parallel Win32 build process
69 $^O eq 'MSWin32' ? ('lib', @toolchain ) : (@toolchain, 'lib')
70 ));
5e4c4c91 71
b78ac715
NC
72open my $fh, '>', $file
73 or die "Can't open $file: $!";
74
75my $error;
76
5e4c4c91
NC
77# If any of the system's build tools are written in Perl, then this module
78# may well be loaded by a much older version than we are building. So keep it
79# as backwards compatible as is easy.
b78ac715 80print $fh <<"EOT" or $error = "Can't print to $file: $!";
5e4c4c91
NC
81#!perl
82
66ff7d34
FC
83# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
84# This file is generated by write_buildcustomize.pl.
85# Any changes made here will be lost!
86
5e4c4c91 87# We are miniperl, building extensions
a462003e
FC
88# Replace the first entry of \@INC ("lib") with the list of
89# directories we need.
8ce7a7e8 90${\($^O eq 'MSWin32' ? '${^WIN32_SLOPPY_STAT} = 1;':'')}
a462003e 91splice(\@INC, 0, 1, $inc);
fdf90be3 92\$^O = '$osname';
f4eedc6b 93__END__
5e4c4c91 94EOT
b78ac715
NC
95
96if ($error) {
97 close $fh
98 or warn "Can't unlink $file after error: $!";
99} else {
8e6dd9cb
NC
100 if (close $fh) {
101 do $file and exit;
102 $error = "Can't load generated $file: $@";
103 } else {
104 $error = "Can't close $file: $!";
105 }
b78ac715
NC
106}
107
108# It's going very wrong, so try to remove the botched file.
109
110unlink $file
111 or warn "Can't unlink $file after error: $!";
112die $error;
113
b78ac715 114# ex: set ts=8 sts=4 sw=4 et: