This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Change File::Find's tests to look for taint.t instead of commonsense.t
[perl5.git] / write_buildcustomize.pl
... / ...
CommitLineData
1#!./miniperl -w
2
3use strict;
4if (@ARGV) {
5 my $dir = shift;
6 chdir $dir or die "Can't chdir '$dir': $!";
7 unshift @INC, 'lib';
8}
9
10my $file = 'lib/buildcustomize.pl';
11
12# To clarify, this isn't the entire suite of modules considered "toolchain"
13# It's not even all modules needed to build ext/
14# It's just the source paths of the (minimum complete set of) modules in ext/
15# needed to build the nonxs modules
16# After which, all nonxs modules are in lib, which was always sufficient to
17# allow miniperl to build everything else.
18# Term::ReadLine is not here for building but for allowing the debugger to
19# run under miniperl when nothing but miniperl will build :-(.
20
21my @toolchain = qw(cpan/AutoLoader/lib
22 dist/Carp/lib
23 dist/Cwd dist/Cwd/lib
24 dist/ExtUtils-Command/lib
25 dist/ExtUtils-Install/lib
26 cpan/ExtUtils-MakeMaker/lib
27 dist/ExtUtils-Manifest/lib
28 cpan/File-Path/lib
29 ext/re
30 dist/Term-ReadLine/lib
31 dist/Exporter/lib
32 );
33
34# Used only in ExtUtils::Liblist::Kid::_win32_ext()
35push @toolchain, 'cpan/Text-ParseWords/lib' if $^O eq 'MSWin32';
36push @toolchain, 'ext/VMS-Filespec/lib' if $^O eq 'VMS';
37
38unshift @INC, @toolchain;
39require File::Spec::Functions;
40
41# lib must be last, as the toolchain modules write themselves into it
42# as they build, and it's important that @INC order ensures that the partially
43# written files are always masked by the complete versions.
44
45my $inc = join ",\n ",
46 map { "q\0$_\0" }
47 (map {File::Spec::Functions::rel2abs($_)} @toolchain, 'lib'), '.';
48
49open my $fh, '>', $file
50 or die "Can't open $file: $!";
51
52my $error;
53
54# If any of the system's build tools are written in Perl, then this module
55# may well be loaded by a much older version than we are building. So keep it
56# as backwards compatible as is easy.
57print $fh <<"EOT" or $error = "Can't print to $file: $!";
58#!perl
59
60# We are miniperl, building extensions
61# Reset \@INC completely, adding the directories we need, and removing the
62# installed directories (which we don't need to read, and may confuse us)
63\@INC = ($inc);
64EOT
65
66if ($error) {
67 close $fh
68 or warn "Can't unlink $file after error: $!";
69} else {
70 if (close $fh) {
71 do $file and exit;
72 $error = "Can't load generated $file: $@";
73 } else {
74 $error = "Can't close $file: $!";
75 }
76}
77
78# It's going very wrong, so try to remove the botched file.
79
80unlink $file
81 or warn "Can't unlink $file after error: $!";
82die $error;
83
84# Local variables:
85# cperl-indent-level: 4
86# indent-tabs-mode: nil
87# End:
88#
89# ex: set ts=8 sts=4 sw=4 et: