This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #123659] [Win32] Add "-ld" to archname for dmake "long double" builds of perl
[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
2ca4a82e 31 cpan/ExtUtils-Command/lib
d393d7e5 32 cpan/ExtUtils-Install/lib
5e4c4c91 33 cpan/ExtUtils-MakeMaker/lib
854a00d8 34 cpan/ExtUtils-Manifest/lib
5e4c4c91 35 cpan/File-Path/lib
7353f64c 36 ext/re
f61462d5 37 dist/Term-ReadLine/lib
3110a055 38 dist/Exporter/lib
6de85bb4 39 ext/File-Find/lib
f4e064af 40 cpan/Text-Tabs/lib
70c90635 41 dist/constant/lib
5e4c4c91
NC
42 );
43
44# Used only in ExtUtils::Liblist::Kid::_win32_ext()
45push @toolchain, 'cpan/Text-ParseWords/lib' if $^O eq 'MSWin32';
2d11a7e9
NC
46push @toolchain, 'ext/VMS-Filespec/lib' if $^O eq 'VMS';
47
48unshift @INC, @toolchain;
49require File::Spec::Functions;
5e4c4c91 50
2effe01f 51# lib must be last, as the toolchain modules write themselves into it
5e4c4c91
NC
52# as they build, and it's important that @INC order ensures that the partially
53# written files are always masked by the complete versions.
54
55my $inc = join ",\n ",
56 map { "q\0$_\0" }
8ce7a7e8
DD
57 (map {File::Spec::Functions::rel2abs($_)} (
58# faster build on the non-parallel Win32 build process
59 $^O eq 'MSWin32' ? ('lib', @toolchain ) : (@toolchain, 'lib')
60 ));
5e4c4c91 61
b78ac715
NC
62open my $fh, '>', $file
63 or die "Can't open $file: $!";
64
65my $error;
66
5e4c4c91
NC
67# If any of the system's build tools are written in Perl, then this module
68# may well be loaded by a much older version than we are building. So keep it
69# as backwards compatible as is easy.
b78ac715 70print $fh <<"EOT" or $error = "Can't print to $file: $!";
5e4c4c91
NC
71#!perl
72
66ff7d34
FC
73# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
74# This file is generated by write_buildcustomize.pl.
75# Any changes made here will be lost!
76
5e4c4c91 77# We are miniperl, building extensions
a462003e
FC
78# Replace the first entry of \@INC ("lib") with the list of
79# directories we need.
8ce7a7e8 80${\($^O eq 'MSWin32' ? '${^WIN32_SLOPPY_STAT} = 1;':'')}
a462003e 81splice(\@INC, 0, 1, $inc);
fdf90be3 82\$^O = '$osname';
f4eedc6b 83__END__
5e4c4c91 84EOT
b78ac715
NC
85
86if ($error) {
87 close $fh
88 or warn "Can't unlink $file after error: $!";
89} else {
8e6dd9cb
NC
90 if (close $fh) {
91 do $file and exit;
92 $error = "Can't load generated $file: $@";
93 } else {
94 $error = "Can't close $file: $!";
95 }
b78ac715
NC
96}
97
98# It's going very wrong, so try to remove the botched file.
99
100unlink $file
101 or warn "Can't unlink $file after error: $!";
102die $error;
103
104# Local variables:
105# cperl-indent-level: 4
106# indent-tabs-mode: nil
107# End:
108#
109# ex: set ts=8 sts=4 sw=4 et: