MM_Win32.pm revision 7c478bd95313f5f23a4c958a745db2134aa03244
=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.
=over
=cut
use Config;
#use Cwd;
require Exporter;
Exporter::import('ExtUtils::MakeMaker',
# a few workarounds for command.com (very basic)
{
# the $^O test may be overkill, but we want to be sure Win32::IsWin95()
# exists before we try it
sub xs_c {
my($self) = shift;
'
.xs.c:
'
}
sub xs_cpp {
my($self) = shift;
'
';
}
# many makes are too dumb to use xs_c then c_o
sub xs_o {
my($self) = shift;
'
';
}
} # end of command.com workarounds
sub dlsyms {
my(@m);
push(@m,"
",
-e "Mksymlists('NAME' => '!, $self->{NAME},
!);
}
join('',@m);
}
$man =~ s,/+,.,g;
$man;
}
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;
}
sub file_name_is_absolute {
$file =~ m{^([a-z]:)?[\\/]}i ;
}
sub find_perl {
if ($trace >= 2){
print "Looking for perl $ver by these names:
@$names
@$dirs
";
}
next unless defined $dir; # $self->{PERL_SRC} may be undefined
}
if ($? == 0) {
print "Using PERL=$abs\n" if $trace;
return $abs;
} elsif ($trace >= 2) {
print "Result: `$val'\n";
}
}
}
print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
0; # false and not empty
}
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 "\\";
}
$result;
}
=item catfile
Concatenate one or more directory names and a filename to form a
complete path ending with a filename
=cut
sub catfile {
my $self = shift @_;
my $file = pop @_;
return $file unless @_;
$dir =~ s/(\\\.)$//;
}
sub init_others
{
my ($self) = @_;
# -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;
}
}
# $self->{'NOECHO'} = ''; # till we have it working
}
=item constants (o)
Initializes lots of constants and .SUFFIXES and .PHONY
=cut
sub constants {
my($self) = @_;
my(@m,$tmp);
for $tmp (qw/
/ ) {
push @m, "$tmp = $self->{$tmp}\n";
}
push @m, qq{
};
push @m, qq{
};
push @m, q{
# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
# ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) !!! Deprecated from MM 5.32 !!!
# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
};
for $tmp (qw/
/ ) {
push @m, "$tmp = $self->{$tmp}\n";
}
push @m, "
# Handy lists of source code files:
";
for $tmp (qw/
/) {
push @m, "$tmp = $self->{$tmp}\n";
}
push @m, qq{
.USESHELL :
} if $DMAKE;
push @m, q{
} if $ENV{CLEARCASE_ROOT};
# why not q{} ? -- emacs
push @m, qq{
# work around a famous dec-osf make(1) feature(?):
# 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
};
push @m, q{
# Where to put things:
};
if ($self->has_link_code()) {
push @m, '
';
} else {
push @m, '
';
}
push @m, "
EXPORT_LIST = $tmp
";
push @m, "
PERL_ARCHIVE = $tmp
";
# push @m, q{
#INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{
#
#PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
#};
push @m, q{
};
join('',@m);
}
sub path {
my($self) = @_;
@path;
}
=item static_lib (o)
Defines how to produce the *.a (or equivalent) files.
=cut
sub static_lib {
my($self) = @_;
# Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
# return '' unless $self->needs_linking(); #might be because of a subdir
my(@m);
push(@m, <<'END');
$(RM_RF) $@
END
# If this extension has it's own library (eg SDBM_File)
# then copy that to $(INST_STATIC) and add $(OBJECT) into it.
push @m,
: ($GCC ? '-ru $@ $(OBJECT)'
: '-out:$@ $(OBJECT)')).q{
$(CHMOD) 755 $@
};
# Old mechanism - still available:
join('', "\n",@m);
}
=item dynamic_bs (o)
Defines targets for bootstrap files.
=cut
sub dynamic_bs {
return '
' unless $self->has_link_code();
return '
BOOTSTRAP = '."$self->{BASEEXT}.bs".'
# As Mkbootstrap might not write a file (if none is required)
# we use touch to prevent make continually trying to remake it.
# The DynaLoader only reads a non-empty file.
-MExtUtils::Mkbootstrap \
-e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
$(CHMOD) 644 $@
'."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT)
$(CHMOD) 644 $@
';
}
=item dynamic_lib (o)
Defines how to produce the *.so (or equivalent) files.
=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)\.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, '
$(CHMOD) 755 $@
';
join('',@m);
}
sub perl_archive
{
my ($self) = @_;
}
sub export_list
{
my ($self) = @_;
return "$self->{BASEEXT}.def";
}
=item canonpath
No physical check on the filesystem, but a logical cleanup of a
path. On UNIX eliminated successive slashes and successive "/.".
=cut
sub canonpath {
$path =~ s/^([a-z]:)/\u$1/;
$path =~ s|/|\\|g;
$path =~ s|\\$||
unless $path =~ m#^([a-z]:)?\\#; # xx/ -> xx
$path;
}
=item perl_script
Takes one argument, a file name, and returns the file name, if the
argument is likely to be a perl script. On MM_Unix this is true for
any ordinary, readable file.
=cut
sub perl_script {
return "$file.bat" if -r "$file.bat" && -f _;
return;
}
=item pm_to_blib
Defines target that copies all files in the hash PM to their
destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
=cut
sub pm_to_blib {
my $self = shift;
return q{
pm_to_blib: $(TO_INST_PM)
-e "pm_to_blib(}.
($NMAKE ? 'qw[ <<pmfiles.dat ],'
: $DMAKE ? 'qw[ $(mktmp,pmfiles.dat $(PM_TO_BLIB:s,\\,\\\\,)\n) ],'
: '{ qw[$(PM_TO_BLIB)] },'
).q{'}.$autodir.q{','$(PM_FILTER)')"
}. ($NMAKE ? q{
$(PM_TO_BLIB)
<<
};
}
=item test_via_harness (o)
Helper method to write the test targets
=cut
sub test_via_harness {
"\t$perl".q! -Mblib -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e "use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;" !."$tests\n";
}
=item tool_autosplit (override)
Use Win32 quoting on command line.
=cut
sub tool_autosplit{
my($asl) = "";
q{
# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MAutoSplit }.$asl.q{ -e "autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1);"
};
}
=item tools_other (o)
Win32 overrides.
Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in
the Makefile. Also defines the perl programs MKPATH,
WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL.
=cut
sub tools_other {
my($self) = shift;
my @m;
push @m, qq{
} unless $DMAKE; # dmake determines its own shell
push @m, "$_ = $self->{$_}\n";
}
push @m, q{
# The following is a portable way to say mkdir -p
# To see which directories are created, change the if 0 to if 1
# This helps us to minimize the effect of the .exists files A yet
# better solution would be to have a stable file in the perl
# distribution with a timestamp of zero. But this solution doesn't
# need any changes to the core distribution and works with older perls
};
push @m, q{
# Here we warn users that an old packlist file was found somewhere,
# and that they should call some uninstall routine
-e "print 'WARNING: I have found an old package in';" \\
-e "print ' ', $$ARGV[0], '.';" \\
-e "print 'Please make sure the two installations are not conflicting';"
UNINST=0
VERBINST=1
-e "install({ @ARGV },'$(VERBINST)',0,'$(UNINST)');"
-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';"
-e "uninstall($$ARGV[0],1,1); print \"\nUninstall is deprecated. Please check the";" \
-e "print \" packlist above carefully.\n There may be errors. Remove the\";" \
-e "print \" appropriate files manually.\n Sorry for the inconveniences.\n\""
};
return join "", @m;
}
=item xs_o (o)
Defines suffix rules to go from XS to object files directly. This is
only intended for broken make implementations.
=cut
sub xs_o { # many makes are too dumb to use xs_c then c_o
my($self) = shift;
return ''
}
=item top_targets (o)
Defines the targets all, subdirs, config, and O_FILES
=cut
sub top_targets {
# --- Target Sections ---
my($self) = shift;
my(@m);
push @m, '
#all :: config $(INST_PM) subdirs linkext manifypods
';
push @m, '
'.$self->{NOECHO}.'$(NOOP)
'
push @m, '
'.$self->{NOECHO}.'$(NOOP)
'.$self->{NOECHO}.'$(NOOP)
'.$self->{NOECHO}.'$(NOOP)
config :: $(INST_ARCHAUTODIR)\.exists
'.$self->{NOECHO}.'$(NOOP)
config :: $(INST_AUTODIR)\.exists
'.$self->{NOECHO}.'$(NOOP)
';
if (%{$self->{HTMLLIBPODS}}) {
push @m, qq[
config :: \$(INST_HTMLLIBDIR)/.exists
];
}
if (%{$self->{HTMLSCRIPTPODS}}) {
push @m, qq[
config :: \$(INST_HTMLSCRIPTDIR)/.exists
];
}
push @m, qq[
config :: \$(INST_MAN1DIR)\\.exists
];
}
push @m, qq[
config :: \$(INST_MAN3DIR)\\.exists
];
}
push @m, '
' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
push @m, q{
help:
};
push @m, q{
-e "Version_check('$(MM_VERSION)')"
};
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 {
return "\nhtmlifypods : pure_all\n\t$self->{NOECHO}\$(NOOP)\n" unless
my($dist);
my($pod2html_exe);
} else {
}
# No pod2html but some HTMLxxxPODS to be installed
print <<END;
END
$pod2html_exe = "-S pod2html";
}
my(@m);
push @m,
qq[POD2HTML_EXE = $pod2html_exe\n],
qq[POD2HTML = \$(PERL) -we "use File::Basename; use File::Path qw(mkpath); %m=\@ARGV;for (keys %m){" \\\n],
q[-e "next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M '],
-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,"\n");
push @m, "\t$self->{NOECHO}\$(POD2HTML) \\\n\t";
}
join('', @m);
}
=item manifypods (o)
We don't want manpage process.
=cut
sub manifypods {
my($self) = shift;
return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n";
}
=item dist_ci (o)
Same as MM_Unix version (changes command-line quoting).
=cut
sub dist_ci {
my($self) = shift;
my @m;
push @m, q{
ci :
-e "@all = keys %{ maniread() };" \\
-e "print(\"Executing $(CI) @all\n\"); system(\"$(CI) @all\");" \\
-e "print(\"Executing $(RCS_LABEL) ...\n\"); system(\"$(RCS_LABEL) @all\");"
};
join "", @m;
}
=item dist_core (o)
Same as MM_Unix version (changes command-line quoting).
=cut
sub dist_core {
my($self) = shift;
my @m;
push @m, q{
dist : $(DIST_DEFAULT)
-e "-e ($$vf=\"$(VERSION_FROM)\") and -M $$vf < -M \"}.$self->{MAKEFILE}.q{\";"
$(PREOP)
$(TO_UNIX)
$(POSTOP)
$(PREOP)
$(POSTOP)
$(PREOP)
$(POSTOP)
};
join "", @m;
}
=item pasthru (o)
Defines the string that is passed to recursive make calls in
subdirectories.
=cut
sub pasthru {
my($self) = shift;
}
1;
=back
=cut