X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FExtUtils%2FMM_Win32.pm;h=76e1bd1538265851a41c0ce9936fdbc1fefc2b29;hb=a6d5bf86f91571574c0f404a036824df50194368;hp=72c32fb1950b8e3f3759aee998f15ca136b189d3;hpb=2bd2b9e04a68ec86766c4219cf4da7f0d3168395;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/ExtUtils/MM_Win32.pm b/lib/ExtUtils/MM_Win32.pm index 72c32fb..76e1bd1 100644 --- a/lib/ExtUtils/MM_Win32.pm +++ b/lib/ExtUtils/MM_Win32.pm @@ -1,5 +1,7 @@ package ExtUtils::MM_Win32; +our $VERSION = '1.00_02'; + =head1 NAME ExtUtils::MM_Win32 - methods to override UN*X behaviour in ExtUtils::MakeMaker @@ -14,17 +16,18 @@ See ExtUtils::MM_Unix for a documentation of the methods provided there. This package overrides the implementation of these methods, not the semantics. -=over +=over 4 =cut use Config; #use Cwd; use File::Basename; +use File::Spec; require Exporter; -Exporter::import('ExtUtils::MakeMaker', - qw( $Verbose &neatvalue)); +require ExtUtils::MakeMaker; +ExtUtils::MakeMaker->import(qw( $Verbose &neatvalue)); $ENV{EMXSHELL} = 'sh'; # to run `commands` unshift @MM::ISA, 'ExtUtils::MM_Win32'; @@ -33,13 +36,57 @@ $BORLAND = 1 if $Config{'cc'} =~ /^bcc/i; $GCC = 1 if $Config{'cc'} =~ /^gcc/i; $DMAKE = 1 if $Config{'make'} =~ /^dmake/i; $NMAKE = 1 if $Config{'make'} =~ /^nmake/i; -$OBJ = 1 if $Config{'ccflags'} =~ /PERL_OBJECT/i; +$PERLMAKE = 1 if $Config{'make'} =~ /^pmake/i; + +# a few workarounds for command.com (very basic) +{ + package ExtUtils::MM_Win95; + + # the $^O test may be overkill, but we want to be sure Win32::IsWin95() + # exists before we try it + + unshift @MM::ISA, 'ExtUtils::MM_Win95' + if ($^O =~ /Win32/ && Win32::IsWin95()); + + sub xs_c { + my($self) = shift; + return '' unless $self->needs_linking(); + ' +.xs.c: + $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) \\ + $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.c + ' + } + + sub xs_cpp { + my($self) = shift; + return '' unless $self->needs_linking(); + ' +.xs.cpp: + $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) \\ + $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.cpp + '; + } + + # many makes are too dumb to use xs_c then c_o + sub xs_o { + my($self) = shift; + return '' unless $self->needs_linking(); + ' +.xs$(OBJ_EXT): + $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) \\ + $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.c + $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c + '; + } +} # end of command.com workarounds sub dlsyms { my($self,%attribs) = @_; my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {}; my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || []; + my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || []; my($imports) = $attribs{IMPORTS} || $self->{IMPORTS} || {}; my(@m); (my $boot = $self->{NAME}) =~ s/:/_/g; @@ -49,9 +96,14 @@ sub dlsyms { $self->{BASEEXT}.def: Makefile.PL ", q! $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Mksymlists \\ - -e "Mksymlists('NAME' => '!, $self->{NAME}, - q!', 'DLBASE' => '!,$self->{DLBASE}, + -e "Mksymlists('NAME'=>\"!, $self->{NAME}, + q!\", 'DLBASE' => '!,$self->{DLBASE}, + # The above two lines quoted differently to work around + # a bug in the 4DOS/4NT command line interpreter. The visible + # result of the bug was files named q('extension_name',) *with the + # single quotes and the comma* in the extension build directories. q!', 'DL_FUNCS' => !,neatvalue($funcs), + q!, 'FUNCLIST' => !,neatvalue($funclist), q!, 'IMPORTS' => !,neatvalue($imports), q!, 'DL_VARS' => !, neatvalue($vars), q!);" !); @@ -67,17 +119,33 @@ sub replace_manpage_separator { sub maybe_command { my($self,$file) = @_; - return "$file.exe" if -e "$file.exe"; + my @e = exists($ENV{'PATHEXT'}) + ? split(/;/, $ENV{PATHEXT}) + : qw(.com .exe .bat .cmd); + my $e = ''; + for (@e) { $e .= "\Q$_\E|" } + chop $e; + # see if file ends in one of the known extensions + if ($file =~ /($e)$/i) { + return $file if -e $file; + } + else { + for (@e) { + return "$file$_" if -e "$file$_"; + } + } return; } sub file_name_is_absolute { - my($self,$file) = @_; - $file =~ m{^([a-z]:)?[\\/]}i ; + shift; + return File::Spec->file_name_is_absolute(@_); } sub find_perl { my($self, $ver, $names, $dirs, $trace) = @_; + $trace ||= 0; + my($name, $dir); if ($trace >= 2){ print "Looking for perl $ver by these names: @@ -90,12 +158,12 @@ in these dirs: next unless defined $dir; # $self->{PERL_SRC} may be undefined foreach $name (@$names){ my ($abs, $val); - if ($self->file_name_is_absolute($name)) { # /foo/bar + if (File::Spec->file_name_is_absolute($name)) { # /foo/bar $abs = $name; - } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # foo - $abs = $self->catfile($dir, $name); + } elsif (File::Spec->canonpath($name) eq File::Spec->canonpath(basename($name))) { # foo + $abs = File::Spec->catfile($dir, $name); } else { # foo/bar - $abs = $self->canonpath($self->catfile($self->curdir, $name)); + $abs = File::Spec->canonpath(File::Spec->catfile(File::Spec->curdir, $name)); } print "Checking $abs\n" if ($trace >= 2); next unless $self->maybe_command($abs); @@ -114,14 +182,8 @@ in these dirs: } sub catdir { - my $self = shift; - my @args = @_; - for (@args) { - # append a slash to each argument unless it has one there - $_ .= "\\" if $_ eq '' or substr($_,-1) ne "\\"; - } - my $result = $self->canonpath(join('', @args)); - $result; + shift; + return File::Spec->catdir(@_); } =item catfile @@ -132,13 +194,8 @@ complete path ending with a filename =cut sub catfile { - my $self = shift @_; - my $file = pop @_; - return $file unless @_; - my $dir = $self->catdir(@_); - $dir =~ s/(\\\.)$//; - $dir .= "\\" unless substr($dir,length($dir)-1,1) eq "\\"; - return $dir.$file; + shift; + return File::Spec->catfile(@_); } sub init_others @@ -155,21 +212,19 @@ sub init_others $self->{'TEST_F'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e test_f'; $self->{'LD'} = $Config{'ld'} || 'link'; $self->{'AR'} = $Config{'ar'} || 'lib'; - if ($GCC) - { - $self->{'LDLOADLIBS'} ||= ' '; - } - else - { - $self->{'LDLOADLIBS'} - ||= ( $BORLAND - ? 'import32.lib' - : # compiler adds msvcrtd?.lib according to debug switches - 'oldnames.lib kernel32.lib comdlg32.lib winspool.lib gdi32.lib ' - .'advapi32.lib user32.lib shell32.lib netapi32.lib ole32.lib ' - .'oleaut32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib' - ) . ' $(LIBC) odbc32.lib odbccp32.lib'; - } + $self->{'LDLOADLIBS'} ||= $Config{'libs'}; + # -Lfoo must come first for Borland, so we put it in LDDLFLAGS + if ($BORLAND) { + my $libs = $self->{'LDLOADLIBS'}; + my $libpath = ''; + while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) { + $libpath .= ' ' if length $libpath; + $libpath .= $1; + } + $self->{'LDLOADLIBS'} = $libs; + $self->{'LDDLFLAGS'} ||= $Config{'lddlflags'}; + $self->{'LDDLFLAGS'} .= " $libpath"; + } $self->{'DEV_NULL'} = '> NUL'; # $self->{'NOECHO'} = ''; # till we have it working } @@ -194,7 +249,8 @@ sub constants { INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC - PERL_INC PERL FULLPERL + PERL_INC PERL FULLPERL PERLRUN PERLRUNINST TEST_LIBS + FULL_AR PERL_CORE / ) { next unless defined $self->{$tmp}; @@ -209,7 +265,7 @@ XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\" }; push @m, qq{ -MAKEMAKER = $INC{'ExtUtils\MakeMaker.pm'} +MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'} MM_VERSION = $ExtUtils::MakeMaker::VERSION }; @@ -235,12 +291,19 @@ XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})." C_FILES = ".join(" \\\n\t", @{$self->{C}})." O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})." H_FILES = ".join(" \\\n\t", @{$self->{H}})." +HTMLLIBPODS = ".join(" \\\n\t", sort keys %{$self->{HTMLLIBPODS}})." +HTMLSCRIPTPODS = ".join(" \\\n\t", sort keys %{$self->{HTMLSCRIPTPODS}})." MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})." MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})." "; for $tmp (qw/ - INST_MAN1DIR INSTALLMAN1DIR MAN1EXT INST_MAN3DIR INSTALLMAN3DIR MAN3EXT + INST_HTMLPRIVLIBDIR INSTALLHTMLPRIVLIBDIR + INST_HTMLSITELIBDIR INSTALLHTMLSITELIBDIR + INST_HTMLSCRIPTDIR INSTALLHTMLSCRIPTDIR + INST_HTMLLIBDIR HTMLEXT + INST_MAN1DIR INSTALLMAN1DIR MAN1EXT + INST_MAN3DIR INSTALLMAN3DIR MAN3EXT /) { next unless defined $self->{$tmp}; push @m, "$tmp = $self->{$tmp}\n"; @@ -261,10 +324,10 @@ makemakerdflt: all .SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT) -# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that -# some make implementations will delete the Makefile when we rebuild it. Because -# we call false(1) when we rebuild it. So make(1) is not completely wrong when it -# does so. Our milage may vary. +# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to +# recall, that some make implementations will delete the Makefile when we +# rebuild it. Because we call false(1) when we rebuild it. So make(1) is +# not completely wrong when it does so. Our milage may vary. # .PRECIOUS: Makefile # seems to be not necessary anymore .PHONY: all config static dynamic test linkext manifest @@ -276,11 +339,11 @@ CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h my @parentdir = split(/::/, $self->{PARENT_NAME}); push @m, q{ # Where to put things: -INST_LIBDIR = }. $self->catdir('$(INST_LIB)',@parentdir) .q{ -INST_ARCHLIBDIR = }. $self->catdir('$(INST_ARCHLIB)',@parentdir) .q{ +INST_LIBDIR = }. File::Spec->catdir('$(INST_LIB)',@parentdir) .q{ +INST_ARCHLIBDIR = }. File::Spec->catdir('$(INST_ARCHLIB)',@parentdir) .q{ -INST_AUTODIR = }. $self->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{ -INST_ARCHAUTODIR = }. $self->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{ +INST_AUTODIR = }. File::Spec->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{ +INST_ARCHAUTODIR = }. File::Spec->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{ }; if ($self->has_link_code()) { @@ -323,12 +386,7 @@ PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{ sub path { - local $^W = 1; - my($self) = @_; - my $path = $ENV{'PATH'} || $ENV{'Path'} || $ENV{'path'}; - my @path = split(';',$path); - foreach(@path) { $_ = '.' if $_ eq '' } - @path; + return File::Spec->path(); } =item static_lib (o) @@ -349,7 +407,7 @@ sub static_lib { $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)\.exists $(RM_RF) $@ END - # If this extension has it's own library (eg SDBM_File) + # If this extension has its own library (eg SDBM_File) # then copy that to $(INST_STATIC) and add $(OBJECT) into it. push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB}; @@ -419,6 +477,18 @@ sub dynamic_lib { my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || ""; my($ldfrom) = '$(LDFROM)'; my(@m); + +# one thing for GCC/Mingw32: +# we try to overcome non-relocateable-DLL problems by generating +# a (hopefully unique) image-base from the dll's name +# -- BKS, 10-19-1999 + if ($GCC) { + my $dllname = $self->{BASEEXT} . "." . $self->{DLEXT}; + $dllname =~ /(....)(.{0,4})/; + my $baseaddr = unpack("n", $1 ^ $2); + $otherldflags .= sprintf("-Wl,--image-base,0x%x0000 ", $baseaddr); + } + push(@m,' # This section creates the dynamically loadable $(INST_DYNAMIC) # from $(OBJECT) and possibly $(MYEXTLIB). @@ -433,11 +503,18 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists $(LD) -o $@ -Wl,--base-file -Wl,dll.base $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp dlltool --def $(EXPORT_LIST) --base-file dll.base --output-exp dll.exp $(LD) -o $@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp }); - } else { - push(@m, $BORLAND ? - q{ $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) }.$ldfrom.q{,$@,,$(PERL_ARCHIVE:s,/,\,) $(LDLOADLIBS:s,/,\,) $(MYEXTLIB:s,/,\,),$(EXPORT_LIST:s,/,\,),$(RESFILES)} : - q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)} - ); + } elsif ($BORLAND) { + push(@m, + q{ $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) }.$ldfrom.q{,$@,,} + .($DMAKE ? q{$(PERL_ARCHIVE:s,/,\,) $(LDLOADLIBS:s,/,\,) } + .q{$(MYEXTLIB:s,/,\,),$(EXPORT_LIST:s,/,\,)} + : q{$(subst /,\,$(PERL_ARCHIVE)) $(subst /,\,$(LDLOADLIBS)) } + .q{$(subst /,\,$(MYEXTLIB)),$(subst /,\,$(EXPORT_LIST))}) + .q{,$(RESFILES)}); + } else { # VC + push(@m, + q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) } + .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)}); } push @m, ' $(CHMOD) 755 $@ @@ -447,14 +524,24 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists join('',@m); } +sub clean +{ + my ($self) = @_; + my $s = &ExtUtils::MM_Unix::clean; + my $clean = $GCC ? 'dll.base dll.exp' : '*.pdb'; + $s .= <{CAPI} eq 'TRUE') { - return '$(PERL_INC)\perlCAPI$(LIB_EXT)'; - } - } return '$(PERL_INC)\\'.$Config{'libperl'}; } @@ -494,7 +581,9 @@ any ordinary, readable file. sub perl_script { my($self,$file) = @_; + return $file if -r $file && -f _; return "$file.pl" if -r "$file.pl" && -f _; + return "$file.bat" if -r "$file.bat" && -f _; return; } @@ -507,15 +596,16 @@ destination and autosplits them. See L sub pm_to_blib { my $self = shift; - my($autodir) = $self->catdir('$(INST_LIB)','auto'); + my($autodir) = File::Spec->catdir('$(INST_LIB)','auto'); return q{ pm_to_blib: $(TO_INST_PM) }.$self->{NOECHO}.q{$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \ "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \ - -e "pm_to_blib(qw[ }. - ($NMAKE ? '<', ' L<', shift, '>';" \ +-e "print '=head2 ', scalar(localtime), ': C<', shift, '>', ' L<', $$arg=shift, '|', $$arg, '>';" \ -e "print '=over 4';" \ -e "while (defined($$key = shift) and defined($$val = shift)) { print '=item *';print 'C<', \"$$key: $$val\", '>'; }" \ -e "print '=back';" @@ -645,7 +735,7 @@ sub top_targets { '; push @m, ' -all :: pure_all manifypods +all :: pure_all htmlifypods manifypods '.$self->{NOECHO}.'$(NOOP) ' unless $self->{SKIPHASH}{'all'}; @@ -667,13 +757,25 @@ config :: $(INST_AUTODIR)\.exists '.$self->{NOECHO}.'$(NOOP) '; - push @m, qq{ -config :: Version_check + push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]); + + if (%{$self->{HTMLLIBPODS}}) { + push @m, qq[ +config :: \$(INST_HTMLLIBDIR)/.exists $self->{NOECHO}\$(NOOP) -} unless $self->{PARENT} or ($self->{PERL_SRC} && $self->{INSTALLDIRS} eq "perl") or $self->{NO_VC}; +]; + push @m, $self->dir_target(qw[$(INST_HTMLLIBDIR)]); + } + + if (%{$self->{HTMLSCRIPTPODS}}) { + push @m, qq[ +config :: \$(INST_HTMLSCRIPTDIR)/.exists + $self->{NOECHO}\$(NOOP) - push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]); +]; + push @m, $self->dir_target(qw[$(INST_HTMLSCRIPTDIR)]); + } if (%{$self->{MAN1PODS}}) { push @m, qq[ @@ -711,13 +813,67 @@ Version_check: join('',@m); } +=item htmlifypods (o) + +Defines targets and routines to translate the pods into HTML manpages +and put them into the INST_HTMLLIBDIR and INST_HTMLSCRIPTDIR +directories. + +Same as MM_Unix version (changes command-line quoting). + +=cut + +sub htmlifypods { + my($self, %attribs) = @_; + return "\nhtmlifypods : pure_all\n\t$self->{NOECHO}\$(NOOP)\n" unless + %{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}}; + my($dist); + my($pod2html_exe); + if (defined $self->{PERL_SRC}) { + $pod2html_exe = File::Spec->catfile($self->{PERL_SRC},'pod','pod2html'); + } else { + $pod2html_exe = File::Spec->catfile($Config{scriptdirexp},'pod2html'); + } + unless ($pod2html_exe = $self->perl_script($pod2html_exe)) { + # No pod2html but some HTMLxxxPODS to be installed + print <{MAKEFILE}, q[';" \\ +-e "print qq(Htmlifying $$m{$$_}\n);" \\ +-e "$$dir = dirname($$m{$$_}); mkpath($$dir) unless -d $$dir;" \\ +-e "system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2HTML_EXE) ].qq[$$_>$$m{$$_}])==0 or warn qq(Couldn\\047t install $$m{$$_}\n);" \\ +-e "chmod(oct($(PERM_RW))), $$m{$$_} or warn qq(chmod $(PERM_RW) $$m{$$_}: $$!\n);}" +]; + push @m, "\nhtmlifypods : pure_all "; + push @m, join " \\\n\t", keys %{$self->{HTMLLIBPODS}}, keys %{$self->{HTMLSCRIPTPODS}}; + + push(@m,"\n"); + if (%{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}}) { + push @m, "\t$self->{NOECHO}\$(POD2HTML) \\\n\t"; + push @m, join " \\\n\t", %{$self->{HTMLLIBPODS}}, %{$self->{HTMLSCRIPTPODS}}; + } + join('', @m); +} + =item manifypods (o) -We don't want manpage process. XXX add pod2html support later. +We don't want manpage process. =cut sub manifypods { + my($self) = shift; return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n"; }