summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/perl/perl-5.12.2/parallel_build_fix_5.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/perl/perl-5.12.2/parallel_build_fix_5.patch')
-rw-r--r--meta/recipes-devtools/perl/perl-5.12.2/parallel_build_fix_5.patch428
1 files changed, 428 insertions, 0 deletions
diff --git a/meta/recipes-devtools/perl/perl-5.12.2/parallel_build_fix_5.patch b/meta/recipes-devtools/perl/perl-5.12.2/parallel_build_fix_5.patch
new file mode 100644
index 0000000000..abc1922cbe
--- /dev/null
+++ b/meta/recipes-devtools/perl/perl-5.12.2/parallel_build_fix_5.patch
@@ -0,0 +1,428 @@
1Rebased by Nitin A Kamble <nitin.a.kamble@intel.com> on 3/11/2011
2
3commit 5e4c4c91bd52a48de59520d5e9b4e3478e49c613
4Author: Nicholas Clark <nick@ccl4.org>
5Date: Mon Feb 14 10:14:18 2011 +0000
6
7 Use a buildcustomize.pl to set @INC in miniperl when building extensions.
8
9 With the build tools now shipped in various subdirectories of cpan/ and dist/
10 we need to add several paths to @INC when invoking MakeMaker (etc) to build
11 extensions.
12
13 The previous approach of using $ENV{PERL5LIB} was fragile, because:
14 a: It was hitting the length limit for %ENV variables on VMS
15 b: It was running the risk of race conditions in a parallel build -
16 ExtUtils::Makemaker "knows" to add -I../..lib, which puts lib at the *front*
17 of @INC, but if one parallel process happens to copy a module into lib/
18 whilst another is searching for it, the second may get a partial read
19 c: Overwriting $ENV{PERL5LIB} breaks any system where any of the installed
20 build tools are actually implemented in Perl, if they are relying on
21 $ENV{PERL5LIB} for setup
22
23 This approach
24
25 a: Doesn't have %ENV length limits
26 b: Ensures that lib/ is last, so copy targets are always shadowing copy
27 sources
28 c: Only affects miniperl, and doesn't touch $ENV{PERL5LIB}
29
30 Approaches that turned out to have fatal flaws:
31
32 1: Using $ENV{PERL5OPT} with a module fails because ExtUtils::MakeMaker
33 searches for the build perl without setting lib, and treats the error
34 caused by a failed -M as "not a valid perl 5 binary"
35 2: Refactoring ExtUtils::MakeMaker to *not* use -I for lib, and instead rely
36 on $ENV{PERL5LIB} [which includes "../../lib"] fails because:
37 some extensions have subdirectories, and on these EU::MM correctly uses
38 -I../../../lib, where as $ENV{PERL5LIB} only has space for relative paths,
39 and only with two levels.
40
41 This approach actually takes advantage of ExtUtils::MakeMaker setting an -I
42 option correct for the depth of directory being built.
43
44Index: perl-5.12.2/Cross/Makefile-cross-SH
45===================================================================
46--- perl-5.12.2.orig/Cross/Makefile-cross-SH
47+++ perl-5.12.2/Cross/Makefile-cross-SH
48@@ -324,7 +324,7 @@ $spitshell >>$Makefile <<'!NO!SUBS!'
49
50 CONFIGPM = xlib/$(CROSS_NAME)/Config.pm
51
52-private = preplibrary $(CONFIGPM) $(CROSS_LIB)/Config.pod
53+private = preplibrary $(CONFIGPM) $(CROSS_LIB)/Config.pod lib/buildcustomize.pl
54
55 shextract = Makefile cflags config.h makeaperl makedepend \
56 makedir myconfig writemain pod/Makefile
57@@ -752,6 +752,9 @@ lib/lib.pm: miniperl $(CONFIGPM)
58 @-rm -f $@
59 $(LDLIBPTH) ./miniperl -Ilib -MCross lib/lib_pm.PL
60
61+lib/buildcustomize.pl: $(MINIPERL_EXE) write_buildcustomize.pl
62+ $(MINIPERL) write_buildcustomize.pl >lib/buildcustomize.pl
63+
64 unidatafiles $(unidatafiles): uni.data
65
66 uni.data: miniperl$(EXE_EXT) $(CONFIGPM) lib/unicore/mktables
67@@ -922,16 +925,16 @@ manicheck: FORCE
68
69
70
71-$(DYNALOADER): preplibrary FORCE
72+$(DYNALOADER): lib/buildcustomize.pl preplibrary FORCE
73 @$(LDLIBPTH) $(RUN) ./miniperl$(EXE_EXT) -Ilib make_ext.pl --cross $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=static $(STATIC_LDFLAGS)
74
75-d_dummy $(dynamic_ext): miniperl$(EXE_EXT) preplibrary makeppport $(DYNALOADER) FORCE
76+d_dummy $(dynamic_ext): miniperl$(EXE_EXT) lib/buildcustomize.pl preplibrary makeppport $(DYNALOADER) FORCE
77 @$(LDLIBPTH) $(RUN) ./miniperl$(EXE_EXT) -Ilib make_ext.pl --cross $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=dynamic
78
79-s_dummy $(static_ext): miniperl$(EXE_EXT) preplibrary makeppport $(DYNALOADER) FORCE
80+s_dummy $(static_ext): miniperl$(EXE_EXT) lib/buildcustomize.pl preplibrary makeppport $(DYNALOADER) FORCE
81 @$(LDLIBPTH) $(RUN) ./miniperl$(EXE_EXT) -Ilib make_ext.pl --cross $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=static $(STATIC_LDFLAGS)
82
83-n_dummy $(nonxs_ext): miniperl$(EXE_EXT) preplibrary $(DYNALOADER) FORCE
84+n_dummy $(nonxs_ext): miniperl$(EXE_EXT) lib/buildcustomize.pl preplibrary $(DYNALOADER) FORCE
85 @$(LDLIBPTH) $(RUN) ./miniperl$(EXE_EXT) -Ilib make_ext.pl --cross $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
86 !NO!SUBS!
87
88Index: perl-5.12.2/MANIFEST
89===================================================================
90--- perl-5.12.2.orig/MANIFEST
91+++ perl-5.12.2/MANIFEST
92@@ -4747,6 +4747,7 @@ win32/wince.c WinCE port
93 win32/wince.h WinCE port
94 win32/wincesck.c WinCE port
95 writemain.SH Generate perlmain.c from miniperlmain.c+extensions
96+write_buildcustomize.pl Generate lib/buildcustomize.pl
97 x2p/a2p.c Output of a2p.y run through byacc
98 x2p/a2p.h Global declarations
99 x2p/a2p.pod Pod for awk to perl translator
100Index: perl-5.12.2/Makefile.SH
101===================================================================
102--- perl-5.12.2.orig/Makefile.SH
103+++ perl-5.12.2/Makefile.SH
104@@ -428,7 +428,7 @@ esac
105 ## In the following dollars and backticks do not need the extra backslash.
106 $spitshell >>$Makefile <<'!NO!SUBS!'
107
108-private = preplibrary $(CONFIGPM) $(CONFIGPOD) lib/ExtUtils/Miniperl.pm git_version.h
109+private = preplibrary $(CONFIGPM) $(CONFIGPOD) lib/ExtUtils/Miniperl.pm git_version.h lib/buildcustomize.pl
110
111 # Files to be built with variable substitution before miniperl
112 # is available.
113@@ -991,6 +991,9 @@ $(plextract): $(MINIPERL_EXE) $(CONFIGPM
114 x2p/s2p: $(MINIPERL_EXE) $(CONFIGPM) $(dynamic_ext) x2p/s2p.PL
115 cd x2p; $(LDLIBPTH) $(MAKE) s2p
116
117+lib/buildcustomize.pl: $(MINIPERL_EXE) write_buildcustomize.pl
118+ $(MINIPERL) write_buildcustomize.pl >lib/buildcustomize.pl
119+
120 unidatafiles $(unidatafiles) pod/perluniprops.pod: uni.data
121
122 uni.data: $(MINIPERL_EXE) $(CONFIGPM) lib/unicore/mktables $(nonxs_ext)
123@@ -1160,16 +1163,16 @@ manicheck: FORCE
124 #
125 # DynaLoader may be needed for extensions that use Makefile.PL.
126
127-$(DYNALOADER): $(MINIPERL_EXE) preplibrary FORCE $(nonxs_ext)
128+$(DYNALOADER): $(MINIPERL_EXE) lib/buildcustomize.pl preplibrary FORCE $(nonxs_ext)
129 $(MINIPERL) make_ext.pl $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=static $(STATIC_LDFLAGS)
130
131-d_dummy $(dynamic_ext): $(MINIPERL_EXE) preplibrary makeppport $(DYNALOADER) FORCE $(PERLEXPORT)
132+d_dummy $(dynamic_ext): $(MINIPERL_EXE) lib/buildcustomize.pl preplibrary makeppport $(DYNALOADER) FORCE $(PERLEXPORT)
133 $(MINIPERL) make_ext.pl $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=dynamic
134
135-s_dummy $(static_ext): $(MINIPERL_EXE) preplibrary makeppport $(DYNALOADER) FORCE
136+s_dummy $(static_ext): $(MINIPERL_EXE) lib/buildcustomize.pl preplibrary makeppport $(DYNALOADER) FORCE
137 $(MINIPERL) make_ext.pl $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=static $(STATIC_LDFLAGS)
138
139-n_dummy $(nonxs_ext): $(MINIPERL_EXE) preplibrary FORCE
140+n_dummy $(nonxs_ext): $(MINIPERL_EXE) lib/buildcustomize.pl preplibrary FORCE
141 $(MINIPERL) make_ext.pl $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
142 !NO!SUBS!
143
144Index: perl-5.12.2/installperl
145===================================================================
146--- perl-5.12.2.orig/installperl
147+++ perl-5.12.2/installperl
148@@ -714,6 +714,8 @@ sub installlib {
149 # ignore the test extensions
150 return if $dir =~ m{\bXS/(?:APItest|Typemap)\b};
151 return if $name =~ m{\b(?:APItest|Typemap)\.pm$};
152+ # ignore the build support code
153+ return if $name =~ /\bbuildcustomize\.pl$/;
154 # ignore the demo files
155 return if $dir =~ /\b(?:demos?|eg)\b/;
156
157Index: perl-5.12.2/make_ext.pl
158===================================================================
159--- perl-5.12.2.orig/make_ext.pl
160+++ perl-5.12.2/make_ext.pl
161@@ -4,11 +4,9 @@ use warnings;
162 use Config;
163 BEGIN {
164 if ($^O eq 'MSWin32') {
165- unshift @INC, ('../cpan/Cwd', '../cpan/Cwd/lib');
166- require File::Spec::Functions;
167+ unshift @INC, '../cpan/Cwd';
168 require FindExt;
169- }
170- else {
171+ } else {
172 unshift @INC, 'cpan/Cwd';
173 }
174 }
175@@ -18,27 +16,6 @@ my $is_Win32 = $^O eq 'MSWin32';
176 my $is_VMS = $^O eq 'VMS';
177 my $is_Unix = !$is_Win32 && !$is_VMS;
178
179-# To clarify, this isn't the entire suite of modules considered "toolchain"
180-# It's not even all modules needed to build ext/
181-# It's just the source paths of the (minimum complete set of) modules in ext/
182-# needed to build the nonxs modules
183-# After which, all nonxs modules are in lib, which was always sufficient to
184-# allow miniperl to build everything else.
185-
186-# This list cannot get any longer without overflowing the length limit for
187-# environment variables on VMS
188-my @toolchain = qw(cpan/AutoLoader/lib
189- cpan/Cwd cpan/Cwd/lib
190- cpan/ExtUtils-Command/lib
191- dist/ExtUtils-Install/lib
192- cpan/ExtUtils-MakeMaker/lib
193- cpan/ExtUtils-Manifest/lib
194- cpan/File-Path/lib
195- );
196-
197-# Used only in ExtUtils::Liblist::Kid::_win32_ext()
198-push @toolchain, 'cpan/Text-ParseWords/lib' if $is_Win32;
199-
200 my @ext_dirs = qw(cpan dist ext);
201 my $ext_dirs_re = '(?:' . join('|', @ext_dirs) . ')';
202
203@@ -295,16 +272,7 @@ sub build_extension {
204 $perl ||= "$up/miniperl";
205 my $return_dir = $up;
206 my $lib_dir = "$up/lib";
207- # $lib_dir must be last, as we're copying files into it, and in a parallel
208- # make there's a race condition if one process tries to open a module that
209- # another process has half-written.
210- my @new_inc = ((map {"$up/$_"} @toolchain), $lib_dir);
211- if ($is_Win32) {
212- @new_inc = map {File::Spec::Functions::rel2abs($_)} @new_inc;
213- }
214- $ENV{PERL5LIB} = join $Config{path_sep}, @new_inc;
215 $ENV{PERL_CORE} = 1;
216- # warn $ENV{PERL5LIB};
217
218 my $makefile;
219 if ($is_VMS) {
220@@ -375,7 +343,7 @@ EOM
221 @cross = '-MCross';
222 }
223
224- my @args = (@cross, 'Makefile.PL');
225+ my @args = ("-I$lib_dir", @cross, 'Makefile.PL');
226 if ($is_VMS) {
227 my $libd = VMS::Filespec::vmspath($lib_dir);
228 push @args, "INST_LIB=$libd", "INST_ARCHLIB=$libd";
229Index: perl-5.12.2/vms/descrip_mms.template
230===================================================================
231--- perl-5.12.2.orig/vms/descrip_mms.template
232+++ perl-5.12.2/vms/descrip_mms.template
233@@ -360,7 +360,7 @@ CRTLOPTS =,$(CRTL)/Options
234 unidatadirs = lib/unicore/To lib/unicore/lib
235
236 # Modules which must be installed before we can build extensions
237-LIBPREREQ = $(ARCHDIR)Config.pm $(ARCHDIR)Config_heavy.pl [.lib.VMS]Filespec.pm $(ARCHDIR)vmspipe.com [.lib]re.pm
238+LIBPREREQ = $(ARCHDIR)Config.pm $(ARCHDIR)Config_heavy.pl [.lib.VMS]Filespec.pm $(ARCHDIR)vmspipe.com [.lib]re.pm [.lib]buildcustomize.pl
239
240 utils1 = [.lib.pods]perldoc.com [.lib.ExtUtils]Miniperl.pm [.utils]c2ph.com [.utils]h2ph.com
241 utils2 = [.utils]h2xs.com [.utils]libnetcfg.com [.lib]perlbug.com [.utils]dprofpp.com
242@@ -458,6 +458,9 @@ archcorefiles : $(ac) $(ARCHAUTO)time.st
243 [.lib]re.pm : [.ext.re]re.pm
244 Copy/NoConfirm/Log $(MMS$SOURCE) [.lib]
245
246+[.lib]buildcustomize.pl : write_buildcustomize.pl $(MINIPERL_EXE)
247+ $(MINIPERL) write_buildcustomize.pl > [.lib]buildcustomize.pl
248+
249 vmspipe.com : [.vms]vmspipe.com
250 Copy/NoConfirm/Log $(MMS$SOURCE) []
251
252@@ -561,7 +564,7 @@ unidatafiles.ts : $(MINIPERL_EXE) [.lib]
253 @ If F$Search("$(MMS$TARGET)").nes."" Then Delete/NoLog/NoConfirm $(MMS$TARGET);*
254 @ Copy/NoConfirm _NLA0: $(MMS$TARGET)
255
256-DynaLoader$(O) : $(ARCHDIR)Config.pm $(MINIPERL_EXE) [.lib.VMS]Filespec.pm
257+DynaLoader$(O) : [.lib]buildcustomize.pl $(ARCHDIR)Config.pm $(MINIPERL_EXE) [.lib.VMS]Filespec.pm
258 $(MINIPERL) make_ext.pl "MAKE=$(MMS)" "DynaLoader"
259
260 dynext : $(LIBPREREQ) $(DBG)perlshr$(E) unidatafiles.ts DynaLoader$(O) preplibrary makeppport $(MINIPERL_EXE)
261@@ -1856,6 +1859,7 @@ tidy : cleanlis
262 - If F$Search("[.utils]*.com;-1").nes."" Then Purge/NoConfirm/Log [.utils]*.com
263 - If F$Search("[.x2p]*.com;-1").nes."" Then Purge/NoConfirm/Log [.x2p]*.com
264 - If F$Search("[.lib.pods]*.com;-1").nes."" Then Purge/NoConfirm/Log [.lib.pods]*.com
265+ - If F$Search("[.lib]buildcustomize.pl;-1").nes."" Then Purge/NoConfirm/Log [.lib]buildcustomize.pl
266
267 clean : tidy cleantest
268 - $(MINIPERL) make_ext.pl "MAKE=$(MMS)" "--all" "--target=clean"
269Index: perl-5.12.2/win32/Makefile
270===================================================================
271--- perl-5.12.2.orig/win32/Makefile
272+++ perl-5.12.2/win32/Makefile
273@@ -923,6 +923,9 @@ $(CONFIGPM) : $(MINIPERL) ..\config.sh c
274 -$(MINIPERL) -I..\lib $(ICWD) config_h.PL "INST_VER=$(INST_VER)"
275 if errorlevel 1 $(MAKE) /$(MAKEFLAGS) $(CONFIGPM)
276
277+..\lib\buildcustomize.pl: $(MINIPERL) ..\write_buildcustomize.pl
278+ $(MINIPERL) -I..\lib ..\write_buildcustomize.pl .. >..\lib\buildcustomize.pl
279+
280 $(MINIPERL) : $(MINIDIR) $(MINI_OBJ)
281 $(LINK32) -subsystem:console -out:$@ @<<
282 $(LINK_FLAGS) $(LIBFILES) $(MINI_OBJ)
283@@ -1045,24 +1048,24 @@ MakePPPort: $(MINIPERL) $(CONFIGPM) Exte
284 #-------------------------------------------------------------------------------
285 # There's no direct way to mark a dependency on
286 # DynaLoader.pm, so this will have to do
287-Extensions: ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
288+Extensions: ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
289 $(XCOPY) ..\*.h $(COREDIR)\*.*
290 $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic
291
292-Extensions_reonly: ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
293+Extensions_reonly: ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
294 $(XCOPY) ..\*.h $(COREDIR)\*.*
295 $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic +re
296
297-Extensions_static : ..\make_ext.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM)
298+Extensions_static : ..\make_ext.pl ..\lib\buildcustomize.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM)
299 $(XCOPY) ..\*.h $(COREDIR)\*.*
300 $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --static
301 $(MINIPERL) -I..\lib list_static_libs.pl > Extensions_static
302
303-Extensions_nonxs: ..\make_ext.pl $(PERLDEP) $(CONFIGPM)
304+Extensions_nonxs: ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM)
305 $(XCOPY) ..\*.h $(COREDIR)\*.*
306 $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --nonxs
307
308-$(DYNALOADER) : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs
309+$(DYNALOADER) : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs
310 $(XCOPY) ..\*.h $(COREDIR)\*.*
311 $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --dynaloader
312
313@@ -1159,6 +1162,7 @@ distclean: realclean
314 -del /f $(LIBDIR)\Win32CORE.pm
315 -del /f $(LIBDIR)\Win32API\File.pm
316 -del /f $(LIBDIR)\Win32API\File\cFile.pc
317+ -del /f $(LIBDIR)\buildcustomize.pl
318 -del /f $(DISTDIR)\XSLoader\XSLoader.pm
319 -if exist $(LIBDIR)\App rmdir /s /q $(LIBDIR)\App
320 -if exist $(LIBDIR)\Archive rmdir /s /q $(LIBDIR)\Archive
321Index: perl-5.12.2/win32/makefile.mk
322===================================================================
323--- perl-5.12.2.orig/win32/makefile.mk
324+++ perl-5.12.2/win32/makefile.mk
325@@ -1215,6 +1215,10 @@ $(CONFIGPM) : $(MINIPERL) ..\config.sh c
326 $(MINIPERL) -I..\lib $(ICWD) config_h.PL "INST_VER=$(INST_VER)" \
327 || $(MAKE) $(MAKEMACROS) $(CONFIGPM) $(MAKEFILE)
328
329+..\lib\buildcustomize.pl: $(MINIPERL) ..\write_buildcustomize.pl
330+ $(MINIPERL) -I..\lib ..\write_buildcustomize.pl .. >..\lib\buildcustomize.pl
331+
332+
333 $(MINIPERL) : $(MINIDIR) $(MINI_OBJ) $(CRTIPMLIBS)
334 .IF "$(CCTYPE)" == "BORLAND"
335 if not exist $(CCLIBDIR)\PSDK\odbccp32.lib \
336@@ -1423,24 +1427,24 @@ MakePPPort: $(MINIPERL) $(CONFIGPM) Exte
337 #-------------------------------------------------------------------------------
338 # There's no direct way to mark a dependency on
339 # DynaLoader.pm, so this will have to do
340-Extensions : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
341+Extensions : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
342 $(XCOPY) ..\*.h $(COREDIR)\*.*
343 $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic
344
345-Extensions_reonly : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
346+Extensions_reonly : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
347 $(XCOPY) ..\*.h $(COREDIR)\*.*
348 $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic +re
349
350-Extensions_static : ..\make_ext.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM)
351+Extensions_static : ..\make_ext.pl ..\lib\buildcustomize.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM)
352 $(XCOPY) ..\*.h $(COREDIR)\*.*
353 $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --static
354 $(MINIPERL) -I..\lib list_static_libs.pl > Extensions_static
355
356-Extensions_nonxs : ..\make_ext.pl $(PERLDEP) $(CONFIGPM)
357+Extensions_nonxs : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM)
358 $(XCOPY) ..\*.h $(COREDIR)\*.*
359 $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --nonxs
360
361-$(DYNALOADER) : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs
362+$(DYNALOADER) : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs
363 $(XCOPY) ..\*.h $(COREDIR)\*.*
364 $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --dynaloader
365
366@@ -1534,6 +1538,7 @@ distclean: realclean
367 -del /f $(LIBDIR)\Win32CORE.pm
368 -del /f $(LIBDIR)\Win32API\File.pm
369 -del /f $(LIBDIR)\Win32API\File\cFile.pc
370+ -del /f $(LIBDIR)\buildcustomize.pl
371 -del /f $(DISTDIR)\XSLoader\XSLoader.pm
372 -if exist $(LIBDIR)\App rmdir /s /q $(LIBDIR)\App
373 -if exist $(LIBDIR)\Archive rmdir /s /q $(LIBDIR)\Archive
374Index: perl-5.12.2/write_buildcustomize.pl
375===================================================================
376--- /dev/null
377+++ perl-5.12.2/write_buildcustomize.pl
378@@ -0,0 +1,50 @@
379+#!./miniperl -w
380+
381+use strict;
382+if (@ARGV) {
383+ my $dir = shift;
384+ chdir $dir or die "Can't chdir '$dir': $!";
385+ unshift @INC, 'lib';
386+}
387+
388+unshift @INC, ('cpan/Cwd', 'cpan/Cwd/lib');
389+require File::Spec::Functions;
390+
391+# To clarify, this isn't the entire suite of modules considered "toolchain"
392+# It's not even all modules needed to build ext/
393+# It's just the source paths of the (minimum complete set of) modules in ext/
394+# needed to build the nonxs modules
395+# After which, all nonxs modules are in lib, which was always sufficient to
396+# allow miniperl to build everything else.
397+
398+my @toolchain = qw(cpan/AutoLoader/lib
399+ cpan/Cwd cpan/Cwd/lib
400+ cpan/ExtUtils-Command/lib
401+ dist/ExtUtils-Install/lib
402+ cpan/ExtUtils-MakeMaker/lib
403+ cpan/ExtUtils-Manifest/lib
404+ cpan/File-Path/lib
405+ );
406+
407+# Used only in ExtUtils::Liblist::Kid::_win32_ext()
408+push @toolchain, 'cpan/Text-ParseWords/lib' if $^O eq 'MSWin32';
409+
410+# lib must be last, as the the toolchain modules write themselves into it
411+# as they build, and it's important that @INC order ensures that the partially
412+# written files are always masked by the complete versions.
413+
414+my $inc = join ",\n ",
415+ map { "q\0$_\0" }
416+ (map {File::Spec::Functions::rel2abs($_)} @toolchain, 'lib'), '.';
417+
418+# If any of the system's build tools are written in Perl, then this module
419+# may well be loaded by a much older version than we are building. So keep it
420+# as backwards compatible as is easy.
421+print <<"EOT";
422+#!perl
423+
424+# We are miniperl, building extensions
425+# Reset \@INC completely, adding the directories we need, and removing the
426+# installed directories (which we don't need to read, and may confuse us)
427+\@INC = ($inc);
428+EOT