diff options
Diffstat (limited to 'Master/tlpkg/tlperl/lib/ExtUtils/MM_Win32.pm')
-rw-r--r-- | Master/tlpkg/tlperl/lib/ExtUtils/MM_Win32.pm | 212 |
1 files changed, 97 insertions, 115 deletions
diff --git a/Master/tlpkg/tlperl/lib/ExtUtils/MM_Win32.pm b/Master/tlpkg/tlperl/lib/ExtUtils/MM_Win32.pm index 0a2fb606f45..9844d837b7b 100644 --- a/Master/tlpkg/tlperl/lib/ExtUtils/MM_Win32.pm +++ b/Master/tlpkg/tlperl/lib/ExtUtils/MM_Win32.pm @@ -22,25 +22,26 @@ the semantics. use ExtUtils::MakeMaker::Config; use File::Basename; use File::Spec; -use ExtUtils::MakeMaker qw( neatvalue ); +use ExtUtils::MakeMaker qw(neatvalue _sprintf562); require ExtUtils::MM_Any; require ExtUtils::MM_Unix; our @ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix ); -our $VERSION = '7.10_02'; +our $VERSION = '7.24'; +$VERSION = eval $VERSION; $ENV{EMXSHELL} = 'sh'; # to run `commands` -my ( $BORLAND, $GCC, $DLLTOOL ) = _identify_compiler_environment( \%Config ); +my ( $BORLAND, $GCC, $MSVC ) = _identify_compiler_environment( \%Config ); sub _identify_compiler_environment { my ( $config ) = @_; - my $BORLAND = $config->{cc} =~ /^bcc/i ? 1 : 0; + my $BORLAND = $config->{cc} =~ /\bbcc/i ? 1 : 0; my $GCC = $config->{cc} =~ /\bgcc\b/i ? 1 : 0; - my $DLLTOOL = $config->{dlltool} || 'dlltool'; + my $MSVC = $config->{cc} =~ /\b(?:cl|icl)/i ? 1 : 0; # MSVC can come as clarm.exe, icl=Intel C - return ( $BORLAND, $GCC, $DLLTOOL ); + return ( $BORLAND, $GCC, $MSVC ); } @@ -54,31 +55,18 @@ sub _identify_compiler_environment { sub dlsyms { my($self,%attribs) = @_; + return '' if $self->{SKIPHASH}{'dynamic'}; + $self->xs_dlsyms_iterator(\%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); - - if (not $self->{SKIPHASH}{'dynamic'}) { - push(@m," -$self->{BASEEXT}.def: Makefile.PL -", - q! $(PERLRUN) -MExtUtils::Mksymlists \\ - -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!);" -!); - } - join('',@m); +=item xs_dlsyms_ext + +On Win32, is C<.def>. + +=cut + +sub xs_dlsyms_ext { + '.def'; } =item replace_manpage_separator @@ -292,104 +280,76 @@ MAKE_FRAG return $make_frag; } +=item static_lib_pure_cmd -=item static_lib - -Changes how to run the linker. - -The rest is duplicate code from MM_Unix. Should move the linker code -to its own method. +Defines how to run the archive utility =cut -sub static_lib { - my($self) = @_; - return '' unless $self->has_link_code; - - my(@m); - push(@m, <<'END'); -$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists - $(RM_RF) $@ -END - - # If this extension has its own library (eg SDBM_File) - # then copy that to $(INST_STATIC) and add $(OBJECT) into it. - push @m, <<'MAKE_FRAG' if $self->{MYEXTLIB}; - $(CP) $(MYEXTLIB) $@ -MAKE_FRAG - - push @m, -q{ $(AR) }.($BORLAND ? '$@ $(OBJECT:^"+")' - : ($GCC ? '-ru $@ $(OBJECT)' - : '-out:$@ $(OBJECT)')).q{ - $(CHMOD) $(PERM_RWX) $@ - $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld -}; - - # Old mechanism - still available: - push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS}; - $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs -MAKE_FRAG - - join('', @m); +sub static_lib_pure_cmd { + my ($self, $from) = @_; + $from =~ s/(\$\(\w+)(\))/$1:^"+"$2/g if $BORLAND; + sprintf qq{\t\$(AR) %s\n}, ($BORLAND ? '$@ ' . $from + : ($GCC ? '-ru $@ ' . $from + : '-out:$@ ' . $from)); } - =item dynamic_lib -Complicated stuff for Win32 that I don't understand. :( +Methods are overridden here: not dynamic_lib itself, but the utility +ones that do the OS-specific work. =cut -sub dynamic_lib { - my($self, %attribs) = @_; - return '' unless $self->needs_linking(); #might be because of a subdir - - return '' unless $self->has_link_code; - - my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': ''); - my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || ""; - my($ldfrom) = '$(LDFROM)'; - my(@m); - - push(@m,' -# This section creates the dynamically loadable $(INST_DYNAMIC) -# from $(OBJECT) and possibly $(MYEXTLIB). -OTHERLDFLAGS = '.$otherldflags.' -INST_DYNAMIC_DEP = '.$inst_dynamic_dep.' - -$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVEDEP) $(INST_DYNAMIC_DEP) -'); +sub xs_make_dynamic_lib { + my ($self, $attribs, $from, $to, $todir, $ldfrom, $exportlist) = @_; + my @m = sprintf '%s : %s $(MYEXTLIB) %s$(DFSEP).exists %s $(PERL_ARCHIVEDEP) $(INST_DYNAMIC_DEP)'."\n", $to, $from, $todir, $exportlist; if ($GCC) { - push(@m, - q{ }.$DLLTOOL.q{ --def $(EXPORT_LIST) --output-exp dll.exp - $(LD) -o $@ -Wl,--base-file -Wl,dll.base $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) "$(PERL_ARCHIVE)" $(LDLOADLIBS) dll.exp - }.$DLLTOOL.q{ --def $(EXPORT_LIST) --base-file dll.base --output-exp dll.exp - $(LD) -o $@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) "$(PERL_ARCHIVE)" $(LDLOADLIBS) dll.exp }); + # per https://rt.cpan.org/Ticket/Display.html?id=78395 no longer + # uses dlltool - relies on post 2002 MinGW + # 1 2 + push @m, _sprintf562 <<'EOF', $exportlist, $ldfrom; + $(LD) %1$s -o $@ $(LDDLFLAGS) %2$s $(OTHERLDFLAGS) $(MYEXTLIB) "$(PERL_ARCHIVE)" $(LDLOADLIBS) -Wl,--enable-auto-image-base +EOF } elsif ($BORLAND) { - push(@m, - q{ $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) }.$ldfrom.q{,$@,,} - .($self->is_make_type('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)}); + my $ldargs = $self->is_make_type('dmake') + ? q{"$(PERL_ARCHIVE:s,/,\,)" $(LDLOADLIBS:s,/,\,) $(MYEXTLIB:s,/,\,),} + : q{"$(subst /,\,$(PERL_ARCHIVE))" $(subst /,\,$(LDLOADLIBS)) $(subst /,\,$(MYEXTLIB)),}; + my $subbed; + if ($exportlist eq '$(EXPORT_LIST)') { + $subbed = $self->is_make_type('dmake') + ? q{$(EXPORT_LIST:s,/,\,)} + : q{$(subst /,\,$(EXPORT_LIST))}; + } else { + # in XSMULTI, exportlist is per-XS, so have to sub in perl not make + ($subbed = $exportlist) =~ s#/#\\#g; + } + push @m, sprintf <<'EOF', $ldfrom, $ldargs . $subbed; + $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) %s,$@,,%s,$(RESFILES) +EOF } else { # VC - push(@m, - q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) } - .q{$(MYEXTLIB) "$(PERL_ARCHIVE)" $(LDLOADLIBS) -def:$(EXPORT_LIST)}); - + push @m, sprintf <<'EOF', $ldfrom, $exportlist; + $(LD) -out:$@ $(LDDLFLAGS) %s $(OTHERLDFLAGS) $(MYEXTLIB) "$(PERL_ARCHIVE)" $(LDLOADLIBS) -def:%s +EOF # Embed the manifest file if it exists - push(@m, q{ - if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2 + push(@m, q{ if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2 if exist $@.manifest del $@.manifest}); } - push @m, ' - $(CHMOD) $(PERM_RWX) $@ -'; + push @m, "\n\t\$(CHMOD) \$(PERM_RWX) \$\@\n"; + + join '', @m; +} - join('',@m); +sub xs_dynamic_lib_macros { + my ($self, $attribs) = @_; + my $otherldflags = $attribs->{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': ''); + my $inst_dynamic_dep = $attribs->{INST_DYNAMIC_DEP} || ""; + sprintf <<'EOF', $otherldflags, $inst_dynamic_dep; +# This section creates the dynamically loadable objects from relevant +# objects and possibly $(MYEXTLIB). +OTHERLDFLAGS = %s +INST_DYNAMIC_DEP = %s +EOF } =item extra_clean_files @@ -458,14 +418,16 @@ EOF return $self->SUPER::quote_dep($arg); } -=item xs_o -This target is stubbed out. Not sure why. +=item xs_obj_opt + +Override to fixup -o flags for MSVC. =cut -sub xs_o { - return '' +sub xs_obj_opt { + my ($self, $output_file) = @_; + ($MSVC ? "/Fo" : "-o ") . $output_file; } @@ -478,7 +440,10 @@ banner. sub pasthru { my($self) = shift; - return "PASTHRU = " . ($self->is_make_type('nmake') ? "-nologo" : ""); + my $old = $self->SUPER::pasthru; + return $old unless $self->is_make_type('nmake'); + $old =~ s/(PASTHRU\s*=\s*)/$1 -nologo /; + $old; } @@ -658,6 +623,23 @@ PERLTYPE = $self->{PERLTYPE} } +=item make_type + +Returns a suitable string describing the type of makefile being written. + +=cut + +sub make_type { + my ($self) = @_; + my $make = $self->make; + $make = +( File::Spec->splitpath( $make ) )[-1]; + $make =~ s!\.exe$!!i; + if ( $make =~ m![^A-Z0-9]!i ) { + ($make) = grep { m!make!i } split m![^A-Z0-9]!i, $make; + } + return "$make-style"; +} + 1; __END__ |