diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-02-14 10:14:18 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-02-15 14:10:05 +0000 |
commit | 5e4c4c91bd52a48de59520d5e9b4e3478e49c613 (patch) | |
tree | f48289786af8d9237deb0640edf73e19f7dfda34 /win32 | |
parent | 43c0c913165d6abe1bc0cb45a784eb1c32c3700b (diff) | |
download | perl-5e4c4c91bd52a48de59520d5e9b4e3478e49c613.tar.gz |
Use a buildcustomize.pl to set @INC in miniperl when building extensions.
With the build tools now shipped in various subdirectories of cpan/ and dist/
we need to add several paths to @INC when invoking MakeMaker (etc) to build
extensions.
The previous approach of using $ENV{PERL5LIB} was fragile, because:
a: It was hitting the length limit for %ENV variables on VMS
b: It was running the risk of race conditions in a parallel build -
ExtUtils::Makemaker "knows" to add -I../..lib, which puts lib at the *front*
of @INC, but if one parallel process happens to copy a module into lib/
whilst another is searching for it, the second may get a partial read
c: Overwriting $ENV{PERL5LIB} breaks any system where any of the installed
build tools are actually implemented in Perl, if they are relying on
$ENV{PERL5LIB} for setup
This approach
a: Doesn't have %ENV length limits
b: Ensures that lib/ is last, so copy targets are always shadowing copy
sources
c: Only affects miniperl, and doesn't touch $ENV{PERL5LIB}
Approaches that turned out to have fatal flaws:
1: Using $ENV{PERL5OPT} with a module fails because ExtUtils::MakeMaker
searches for the build perl without setting lib, and treats the error
caused by a failed -M as "not a valid perl 5 binary"
2: Refactoring ExtUtils::MakeMaker to *not* use -I for lib, and instead rely
on $ENV{PERL5LIB} [which includes "../../lib"] fails because:
some extensions have subdirectories, and on these EU::MM correctly uses
-I../../../lib, where as $ENV{PERL5LIB} only has space for relative paths,
and only with two levels.
This approach actually takes advantage of ExtUtils::MakeMaker setting an -I
option correct for the depth of directory being built.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/Makefile | 14 | ||||
-rw-r--r-- | win32/makefile.mk | 15 |
2 files changed, 19 insertions, 10 deletions
diff --git a/win32/Makefile b/win32/Makefile index ceaaaa5ca4..4897a4ad35 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -858,6 +858,9 @@ $(CONFIGPM) : $(MINIPERL) ..\config.sh config_h.PL ..\minimod.pl -$(MINIPERL) -I..\lib $(ICWD) config_h.PL "INST_VER=$(INST_VER)" if errorlevel 1 $(MAKE) /$(MAKEFLAGS) $(CONFIGPM) +..\lib\buildcustomize.pl: $(MINIPERL) ..\write_buildcustomize.pl + $(MINIPERL) -I..\lib ..\write_buildcustomize.pl .. >..\lib\buildcustomize.pl + $(MINIPERL) : $(MINIDIR) $(MINI_OBJ) $(LINK32) -subsystem:console -out:$@ @<< $(LINK_FLAGS) $(LIBFILES) $(MINI_OBJ) @@ -982,24 +985,24 @@ MakePPPort: $(MINIPERL) $(CONFIGPM) Extensions_nonxs #------------------------------------------------------------------------------- # There's no direct way to mark a dependency on # DynaLoader.pm, so this will have to do -Extensions: ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER) +Extensions: ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic -Extensions_reonly: ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER) +Extensions_reonly: ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic +re -Extensions_static : ..\make_ext.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM) +Extensions_static : ..\make_ext.pl ..\lib\buildcustomize.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --static $(MINIPERL) -I..\lib list_static_libs.pl > Extensions_static -Extensions_nonxs: ..\make_ext.pl $(PERLDEP) $(CONFIGPM) +Extensions_nonxs: ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --nonxs -$(DYNALOADER) : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs +$(DYNALOADER) : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --dynaloader @@ -1094,6 +1097,7 @@ distclean: realclean -del /f $(LIBDIR)\Win32CORE.pm -del /f $(LIBDIR)\Win32API\File.pm -del /f $(LIBDIR)\Win32API\File\cFile.pc + -del /f $(LIBDIR)\buildcustomize.pl -del /f $(DISTDIR)\XSLoader\XSLoader.pm -if exist $(LIBDIR)\App rmdir /s /q $(LIBDIR)\App -if exist $(LIBDIR)\Archive rmdir /s /q $(LIBDIR)\Archive diff --git a/win32/makefile.mk b/win32/makefile.mk index f3fface05a..fcc30ac473 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -1160,6 +1160,10 @@ $(CONFIGPM) : $(MINIPERL) ..\config.sh config_h.PL ..\minimod.pl $(MINIPERL) -I..\lib $(ICWD) config_h.PL "INST_VER=$(INST_VER)" \ || $(MAKE) $(MAKEMACROS) $(CONFIGPM) $(MAKEFILE) +..\lib\buildcustomize.pl: $(MINIPERL) ..\write_buildcustomize.pl + $(MINIPERL) -I..\lib ..\write_buildcustomize.pl .. >..\lib\buildcustomize.pl + + $(MINIPERL) : $(MINIDIR) $(MINI_OBJ) $(CRTIPMLIBS) .IF "$(CCTYPE)" == "BORLAND" if not exist $(CCLIBDIR)\PSDK\odbccp32.lib \ @@ -1370,24 +1374,24 @@ MakePPPort: $(MINIPERL) $(CONFIGPM) Extensions_nonxs #------------------------------------------------------------------------------- # There's no direct way to mark a dependency on # DynaLoader.pm, so this will have to do -Extensions : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER) +Extensions : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic -Extensions_reonly : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER) +Extensions_reonly : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic +re -Extensions_static : ..\make_ext.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM) +Extensions_static : ..\make_ext.pl ..\lib\buildcustomize.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --static $(MINIPERL) -I..\lib list_static_libs.pl > Extensions_static -Extensions_nonxs : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) +Extensions_nonxs : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --nonxs -$(DYNALOADER) : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs +$(DYNALOADER) : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --dynaloader @@ -1479,6 +1483,7 @@ distclean: realclean -del /f $(LIBDIR)\Win32CORE.pm -del /f $(LIBDIR)\Win32API\File.pm -del /f $(LIBDIR)\Win32API\File\cFile.pc + -del /f $(LIBDIR)\buildcustomize.pl -del /f $(DISTDIR)\XSLoader\XSLoader.pm -if exist $(LIBDIR)\App rmdir /s /q $(LIBDIR)\App -if exist $(LIBDIR)\Archive rmdir /s /q $(LIBDIR)\Archive |