1 package ExtUtils::MM_Win32;
5 ExtUtils::MM_Win32 - methods to override UN*X behaviour in ExtUtils::MakeMaker
9 use ExtUtils::MM_Win32; # Done internally by ExtUtils::MakeMaker if needed
13 See ExtUtils::MM_Unix for a documentation of the methods provided
14 there. This package overrides the implementation of these methods, not
26 Exporter::import('ExtUtils::MakeMaker',
27 qw( $Verbose &neatvalue));
29 $ENV{EMXSHELL} = 'sh'; # to run `commands`
30 unshift @MM::ISA, 'ExtUtils::MM_Win32';
33 my($self,%attribs) = @_;
35 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
36 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
37 my($imports) = $attribs{IMPORTS} || $self->{IMPORTS} || {};
39 (my $boot = $self->{NAME}) =~ s/:/_/g;
41 if (not $self->{SKIPHASH}{'dynamic'}) {
43 $self->{BASEEXT}.def: Makefile.PL
45 q! $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Mksymlists \\
46 -e "Mksymlists('NAME' => '!, $self->{NAME},
47 q!', 'DLBASE' => '!,$self->{DLBASE},
48 q!', 'DL_FUNCS' => !,neatvalue($funcs),
49 q!, 'IMPORTS' => !,neatvalue($imports),
50 q!, 'DL_VARS' => !, neatvalue($vars), q!);"
56 sub replace_manpage_separator {
64 return "$file.exe" if -e "$file.exe";
68 sub file_name_is_absolute {
70 $file =~ m{^([a-z]:)?[\\/]}i ;
74 my($self, $ver, $names, $dirs, $trace) = @_;
77 print "Looking for perl $ver by these names:
83 foreach $dir (@$dirs){
84 next unless defined $dir; # $self->{PERL_SRC} may be undefined
85 foreach $name (@$names){
87 if ($self->file_name_is_absolute($name)) { # /foo/bar
89 } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # foo
90 $abs = $self->catfile($dir, $name);
92 $abs = $self->canonpath($self->catfile($self->curdir, $name));
94 print "Checking $abs\n" if ($trace >= 2);
95 next unless $self->maybe_command($abs);
96 print "Executing $abs\n" if ($trace >= 2);
97 $val = `$abs -e "require $ver;" 2>&1`;
99 print "Using PERL=$abs\n" if $trace;
101 } elsif ($trace >= 2) {
102 print "Result: `$val'\n";
106 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
107 0; # false and not empty
114 # append a slash to each argument unless it has one there
115 $_ .= "\\" if $_ eq '' or substr($_,-1) ne "\\";
117 my $result = $self->canonpath(join('', @args));
123 Concatenate one or more directory names and a filename to form a
124 complete path ending with a filename
131 return $file unless @_;
132 my $dir = $self->catdir(@_);
134 $dir .= "\\" unless substr($dir,length($dir)-1,1) eq "\\";
141 &ExtUtils::MM_Unix::init_others;
142 $self->{'TOUCH'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e touch';
143 $self->{'CHMOD'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e chmod';
144 $self->{'CP'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e cp';
145 $self->{'RM_F'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e rm_f';
146 $self->{'RM_RF'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e rm_rf';
147 $self->{'MV'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mv';
148 $self->{'NOOP'} = 'rem';
149 $self->{'TEST_F'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e test_f';
150 $self->{'LD'} = 'link';
151 $self->{'DEV_NULL'} = '> NUL';
152 # $self->{'NOECHO'} = ''; # till we have it working
158 my $path = $ENV{'PATH'} || $ENV{'Path'} || $ENV{'path'};
159 my @path = split(';',$path);
160 foreach(@path) { $_ = '.' if $_ eq '' }
166 Defines how to produce the *.a (or equivalent) files.
172 # Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
173 # return '' unless $self->needs_linking(); #might be because of a subdir
175 return '' unless $self->has_link_code;
179 $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists
182 # If this extension has it's own library (eg SDBM_File)
183 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
184 push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
187 q{ lib -nologo -out:$@ $(OBJECT)
188 }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
192 # Old mechanism - still available:
194 push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs}."\n\n"
195 if $self->{PERL_SRC};
197 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
203 =item dynamic_lib (o)
205 Defines how to produce the *.so (or equivalent) files.
210 my($self, %attribs) = @_;
211 return '' unless $self->needs_linking(); #might be because of a subdir
213 return '' unless $self->has_link_code;
215 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
216 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
217 my($ldfrom) = '$(LDFROM)';
220 # This section creates the dynamically loadable $(INST_DYNAMIC)
221 # from $(OBJECT) and possibly $(MYEXTLIB).
222 OTHERLDFLAGS = '.$otherldflags.'
223 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
225 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
228 push(@m,' $(LD) -out:$@ $(LDDLFLAGS) '.$ldfrom.
229 ' $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)');
234 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
240 return '$(PERL_INC)\perl$(LIB_EXT)';
246 return "$self->{BASEEXT}.def";
251 No physical check on the filesystem, but a logical cleanup of a
252 path. On UNIX eliminated successive slashes and successive "/.".
257 my($self,$path) = @_;
258 $path =~ s/^([a-z]:)/\u$1/;
260 $path =~ s|\\+|\\|g ; # xx////xx -> xx/xx
261 $path =~ s|(\\\.)+\\|\\|g ; # xx/././xx -> xx/xx
262 $path =~ s|^(\.\\)+|| unless $path eq ".\\"; # ./xx -> xx
264 unless $path =~ m#^([a-z]:)?\\#; # xx/ -> xx
265 $path .= '.' if $path =~ m#\\$#;
271 Takes one argument, a file name, and returns the file name, if the
272 argument is likely to be a perl script. On MM_Unix this is true for
273 any ordinary, readable file.
278 my($self,$file) = @_;
279 return "$file.pl" if -r "$file.pl" && -f _;
285 Defines target that copies all files in the hash PM to their
286 destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
292 my($autodir) = $self->catdir('$(INST_LIB)','auto');
294 pm_to_blib: $(TO_INST_PM)
295 }.$self->{NOECHO}.q{$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \
296 "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \
297 -e "pm_to_blib(qw{ <<pmfiles.dat },'}.$autodir.q{')"
301 }.$self->{NOECHO}.q{$(TOUCH) $@
305 =item test_via_harness (o)
307 Helper method to write the test targets
311 sub test_via_harness {
312 my($self, $perl, $tests) = @_;
313 "\t$perl".q! -Mblib -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e "use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;" !."$tests\n";
316 =item tool_autosplit (override)
318 Use Win32 quoting on command line.
323 my($self, %attribs) = @_;
325 $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
327 # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
328 AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MAutoSplit }.$asl.q{ -e "autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1);"
332 =item tools_other (o)
336 Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in
337 the Makefile. Also defines the perl programs MKPATH,
338 WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL.
345 my $bin_sh = $Config{sh} || 'cmd /c';
350 for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) {
351 push @m, "$_ = $self->{$_}\n";
355 # The following is a portable way to say mkdir -p
356 # To see which directories are created, change the if 0 to if 1
357 MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath
359 # This helps us to minimize the effect of the .exists files A yet
360 # better solution would be to have a stable file in the perl
361 # distribution with a timestamp of zero. But this solution doesn't
362 # need any changes to the core distribution and works with older perls
363 EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime
367 return join "", @m if $self->{PARENT};
370 # Here we warn users that an old packlist file was found somewhere,
371 # and that they should call some uninstall routine
372 WARN_IF_OLD_PACKLIST = $(PERL) -lwe "exit unless -f $$ARGV[0];" \\
373 -e "print 'WARNING: I have found an old package in';" \\
374 -e "print ' ', $$ARGV[0], '.';" \\
375 -e "print 'Please make sure the two installations are not conflicting';"
380 MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \
381 -e "install({@ARGV},'$(VERBINST)',0,'$(UNINST)');"
383 DOC_INSTALL = $(PERL) -e "$$\=\"\n\n\";" \
384 -e "print '=head2 ', scalar(localtime), ': C<', shift, '>', ' L<', shift, '>';" \
385 -e "print '=over 4';" \
386 -e "while (defined($$key = shift) and defined($$val = shift)){print '=item *';print 'C<', \"$$key: $$val\", '>';}" \
389 UNINSTALL = $(PERL) -MExtUtils::Install \
390 -e "uninstall($$ARGV[0],1,1); print \"\nUninstall is deprecated. Please check the";" \
391 -e "print \" packlist above carefully.\n There may be errors. Remove the\";" \
392 -e "print \" appropriate files manually.\n Sorry for the inconveniences.\n\""
400 We don't want manpage process. XXX add pod2html support later.
405 return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n";
410 Same as MM_Unix version (changes command-line quoting).
419 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=maniread \\
420 -e "@all = keys %{ maniread() };" \\
421 -e "print(\"Executing $(CI) @all\n\"); system(\"$(CI) @all\");" \\
422 -e "print(\"Executing $(RCS_LABEL) ...\n\"); system(\"$(RCS_LABEL) @all\");"
429 Same as MM_Unix version (changes command-line quoting).
437 dist : $(DIST_DEFAULT)
438 }.$self->{NOECHO}.q{$(PERL) -le "print \"Warning: Makefile possibly out of date with $$vf\" if " \
439 -e "-e ($$vf=\"$(VERSION_FROM)\") and -M $$vf < -M \"}.$self->{MAKEFILE}.q{\";"
441 tardist : $(DISTVNAME).tar$(SUFFIX)
443 zipdist : $(DISTVNAME).zip
445 $(DISTVNAME).tar$(SUFFIX) : distdir
448 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
449 $(RM_RF) $(DISTVNAME)
450 $(COMPRESS) $(DISTVNAME).tar
453 $(DISTVNAME).zip : distdir
455 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
456 $(RM_RF) $(DISTVNAME)
459 uutardist : $(DISTVNAME).tar$(SUFFIX)
460 uuencode $(DISTVNAME).tar$(SUFFIX) \\
461 $(DISTVNAME).tar$(SUFFIX) > \\
462 $(DISTVNAME).tar$(SUFFIX)_uu
466 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
467 $(RM_RF) $(DISTVNAME)
475 Defines the string that is passed to recursive make calls in
482 return "PASTHRU = /nologo"