MM_Win32.pm revision 7c478bd95313f5f23a4c958a745db2134aa03244
use strict;
=head1 NAME
ExtUtils::MM_Win32 - methods to override UN*X behaviour in ExtUtils::MakeMaker
=head1 SYNOPSIS
use ExtUtils::MM_Win32; # Done internally by ExtUtils::MakeMaker if needed
=head1 DESCRIPTION
See ExtUtils::MM_Unix for a documentation of the methods provided
there. This package overrides the implementation of these methods, not
the semantics.
=cut
use Config;
$VERSION = '1.09';
=head2 Overridden methods
=over 4
=item B<dlsyms>
=cut
sub dlsyms {
my(@m);
push(@m,"
",
-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.
!);
}
join('',@m);
}
=item replace_manpage_separator
Changes the path separator with .
=cut
$man =~ s,/+,.,g;
$man;
}
=item B<maybe_command>
Since Windows has nothing as simple as an executable bit, we check the
file extension.
The PATHEXT env variable will be used to get a list of extensions that
might indicate a command, otherwise .com, .exe, .bat and .cmd will be
used by default.
=cut
sub maybe_command {
my @e = exists($ENV{'PATHEXT'})
my $e = '';
for (@e) { $e .= "\Q$_\E|" }
chop $e;
# see if file ends in one of the known extensions
if ($file =~ /($e)$/i) {
}
else {
for (@e) {
return "$file$_" if -e "$file$_";
}
}
return;
}
=item B<find_tests>
The Win9x shell does not expand globs and I'll play it safe and assume
other Windows variants don't either.
So we do it for them.
=cut
sub find_tests {
return join(' ', <t\\*.t>);
}
=item B<init_DIRFILESEP>
Using \ for Windows.
=cut
sub init_DIRFILESEP {
my($self) = shift;
# The ^ makes sure its not interpreted as an escape in nmake
$DMAKE ? '\\\\'
: '\\';
}
=item B<init_others>
Override some of the Unix specific commands with portable
ExtUtils::Command ones.
Also provide defaults for LD and AR in case the %Config values aren't
set.
LDLOADLIBS's default is changed to $Config{libs}.
Adjustments are made for Borland's quirks needing -L to come first.
=cut
sub init_others {
my ($self) = @_;
# Used in favor of echo because echo won't strip quotes. :(
# Setting SHELL from $Config{sh} can break dmake. Its ok without it.
# -Lfoo must come first for Borland, so we put it in LDDLFLAGS
if ($BORLAND) {
my $libpath = '';
while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) {
$libpath .= $1;
}
}
return 1;
}
=item init_platform (o)
Add MM_Win32_VERSION.
=item platform_constants (o)
=cut
sub init_platform {
my($self) = shift;
}
sub platform_constants {
my($self) = shift;
my $make_frag = '';
foreach my $macro (qw(MM_Win32_VERSION))
{
$make_frag .= "$macro = $self->{$macro}\n";
}
return $make_frag;
}
=item special_targets (o)
Add .USESHELL target for dmake.
=cut
sub special_targets {
my($self) = @_;
.USESHELL :
return $make_frag;
}
=item static_lib (o)
Changes how to run the linker.
The rest is duplicate code from MM_Unix. Should move the linker code
to its own method.
=cut
sub static_lib {
my($self) = @_;
my(@m);
push(@m, <<'END');
$(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,
: ($GCC ? '-ru $@ $(OBJECT)'
: '-out:$@ $(OBJECT)')).q{
};
# Old mechanism - still available:
join('', @m);
}
=item dynamic_lib (o)
Complicated stuff for Win32 that I don't understand. :(
=cut
sub dynamic_lib {
my($ldfrom) = '$(LDFROM)';
my(@m);
# 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) {
}
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)$(DIRFILESEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
');
if ($GCC) {
push(@m,
$(LD) -o $@ -Wl,--base-file -Wl,dll.base $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp
$(LD) -o $@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp });
} elsif ($BORLAND) {
push(@m,
.q{$(MYEXTLIB:s,/,\,),$(EXPORT_LIST:s,/,\,)}
.q{,$(RESFILES)});
} else { # VC
push(@m,
}
push @m, '
';
join('',@m);
}
=item clean
Clean out some extra dll.{base,exp} files which might be generated by
gcc. Otherwise, take out all *.pdb files.
=cut
sub clean
{
my ($self) = shift;
$s .= <<END;
clean ::
END
return $s;
}
=item init_linker
=cut
sub init_linker {
my $self = shift;
}
=item perl_script
Checks for the perl program under several common perl extensions.
=cut
sub perl_script {
return "$file.bat" if -r "$file.bat" && -f _;
return;
}
=item xs_o (o)
This target is stubbed out. Not sure why.
=cut
sub xs_o {
return ''
}
=item pasthru (o)
All we send is -nologo to nmake to prevent it from printing its damned
banner.
=cut
sub pasthru {
my($self) = shift;
}
=item oneliner (o)
These are based on what command.com does on Win98. They may be wrong
for other Windows shells, I don't know.
=cut
sub oneliner {
# Strip leading and trailing newlines
$cmd =~ s{^\n+}{};
$cmd =~ s{\n+$}{};
}
sub quote_literal {
# I don't know if this is correct, but it seems to work on
# Win98's command.com
$text =~ s{"}{\\"}g;
# dmake eats '{' inside double quotes and leaves alone { outside double
# quotes; however it transforms {{ into { either inside and outside double
# quotes. It also translates }} into }. The escaping below is not
# 100% correct.
if( $DMAKE ) {
$text =~ s/{/{{/g;
$text =~ s/}}/}}}/g;
}
return qq{"$text"};
}
sub escape_newlines {
# Escape newlines
$text =~ s{\n}{\\\n}g;
return $text;
}
=item max_exec_len
nmake 1.50 limits command length to 2048 characters.
=cut
sub max_exec_len {
my $self = shift;
}
=item os_flavor
Windows is Win32.
=cut
sub os_flavor {
return('Win32');
}
1;
=back
=cut