This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix two leaks in Thread.xs (from Eugene Alterman
[perl5.git] / lib / ExtUtils / MM_Win32.pm
CommitLineData
68dc0745
PP
1package ExtUtils::MM_Win32;
2
3=head1 NAME
4
5ExtUtils::MM_Win32 - methods to override UN*X behaviour in ExtUtils::MakeMaker
6
7=head1 SYNOPSIS
8
9 use ExtUtils::MM_Win32; # Done internally by ExtUtils::MakeMaker if needed
10
11=head1 DESCRIPTION
12
13See ExtUtils::MM_Unix for a documentation of the methods provided
14there. This package overrides the implementation of these methods, not
15the semantics.
16
17=over
18
19=cut
20
3e3baf6d 21use Config;
68dc0745
PP
22#use Cwd;
23use File::Basename;
24require Exporter;
25
26Exporter::import('ExtUtils::MakeMaker',
27 qw( $Verbose &neatvalue));
28
29$ENV{EMXSHELL} = 'sh'; # to run `commands`
30unshift @MM::ISA, 'ExtUtils::MM_Win32';
31
3e3baf6d 32$BORLAND = 1 if $Config{'cc'} =~ /^bcc/i;
5b0d9cbe 33$GCC = 1 if $Config{'cc'} =~ /^gcc/i;
3e3baf6d
TB
34$DMAKE = 1 if $Config{'make'} =~ /^dmake/i;
35$NMAKE = 1 if $Config{'make'} =~ /^nmake/i;
dc0d354b 36$PERLMAKE = 1 if $Config{'make'} =~ /^pmake/i;
9d8a25dc 37$OBJ = 1 if $Config{'ccflags'} =~ /PERL_OBJECT/i;
3e3baf6d 38
68dc0745
PP
39sub dlsyms {
40 my($self,%attribs) = @_;
41
42 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
43 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
762efda7 44 my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
68dc0745
PP
45 my($imports) = $attribs{IMPORTS} || $self->{IMPORTS} || {};
46 my(@m);
47 (my $boot = $self->{NAME}) =~ s/:/_/g;
48
49 if (not $self->{SKIPHASH}{'dynamic'}) {
50 push(@m,"
51$self->{BASEEXT}.def: Makefile.PL
52",
53 q! $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Mksymlists \\
54 -e "Mksymlists('NAME' => '!, $self->{NAME},
55 q!', 'DLBASE' => '!,$self->{DLBASE},
56 q!', 'DL_FUNCS' => !,neatvalue($funcs),
762efda7 57 q!, 'FUNCLIST' => !,neatvalue($funclist),
68dc0745
PP
58 q!, 'IMPORTS' => !,neatvalue($imports),
59 q!, 'DL_VARS' => !, neatvalue($vars), q!);"
60!);
61 }
62 join('',@m);
63}
64
65sub replace_manpage_separator {
66 my($self,$man) = @_;
67 $man =~ s,/+,.,g;
68 $man;
69}
70
71sub maybe_command {
72 my($self,$file) = @_;
846f184a
GS
73 my @e = exists($ENV{'PATHEXT'})
74 ? split(/;/, $ENV{PATHEXT})
75 : qw(.com .exe .bat .cmd);
76 my $e = '';
77 for (@e) { $e .= "\Q$_\E|" }
78 chop $e;
79 # see if file ends in one of the known extensions
2b2708c8 80 if ($file =~ /($e)$/i) {
846f184a
GS
81 return $file if -e $file;
82 }
83 else {
84 for (@e) {
85 return "$file$_" if -e "$file$_";
86 }
87 }
68dc0745
PP
88 return;
89}
90
91sub file_name_is_absolute {
92 my($self,$file) = @_;
93 $file =~ m{^([a-z]:)?[\\/]}i ;
94}
95
96sub find_perl {
97 my($self, $ver, $names, $dirs, $trace) = @_;
98 my($name, $dir);
99 if ($trace >= 2){
100 print "Looking for perl $ver by these names:
101@$names
102in these dirs:
103@$dirs
104";
105 }
106 foreach $dir (@$dirs){
107 next unless defined $dir; # $self->{PERL_SRC} may be undefined
108 foreach $name (@$names){
109 my ($abs, $val);
110 if ($self->file_name_is_absolute($name)) { # /foo/bar
111 $abs = $name;
112 } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # foo
113 $abs = $self->catfile($dir, $name);
114 } else { # foo/bar
115 $abs = $self->canonpath($self->catfile($self->curdir, $name));
116 }
117 print "Checking $abs\n" if ($trace >= 2);
118 next unless $self->maybe_command($abs);
119 print "Executing $abs\n" if ($trace >= 2);
120 $val = `$abs -e "require $ver;" 2>&1`;
121 if ($? == 0) {
122 print "Using PERL=$abs\n" if $trace;
123 return $abs;
124 } elsif ($trace >= 2) {
125 print "Result: `$val'\n";
126 }
127 }
128 }
129 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
130 0; # false and not empty
131}
132
133sub catdir {
134 my $self = shift;
135 my @args = @_;
136 for (@args) {
137 # append a slash to each argument unless it has one there
138 $_ .= "\\" if $_ eq '' or substr($_,-1) ne "\\";
139 }
140 my $result = $self->canonpath(join('', @args));
141 $result;
142}
143
144=item catfile
145
146Concatenate one or more directory names and a filename to form a
147complete path ending with a filename
148
149=cut
150
151sub catfile {
152 my $self = shift @_;
153 my $file = pop @_;
154 return $file unless @_;
155 my $dir = $self->catdir(@_);
96e4d5b1
PP
156 $dir =~ s/(\\\.)$//;
157 $dir .= "\\" unless substr($dir,length($dir)-1,1) eq "\\";
68dc0745
PP
158 return $dir.$file;
159}
160
161sub init_others
162{
163 my ($self) = @_;
164 &ExtUtils::MM_Unix::init_others;
165 $self->{'TOUCH'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e touch';
166 $self->{'CHMOD'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e chmod';
167 $self->{'CP'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e cp';
168 $self->{'RM_F'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e rm_f';
169 $self->{'RM_RF'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e rm_rf';
170 $self->{'MV'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mv';
171 $self->{'NOOP'} = 'rem';
172 $self->{'TEST_F'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e test_f';
3e3baf6d
TB
173 $self->{'LD'} = $Config{'ld'} || 'link';
174 $self->{'AR'} = $Config{'ar'} || 'lib';
944acd49 175 $self->{'LDLOADLIBS'} ||= $Config{'libs'};
e47a9bbc 176 # -Lfoo must come first for Borland, so we put it in LDDLFLAGS
944acd49
GS
177 if ($BORLAND) {
178 my $libs = $self->{'LDLOADLIBS'};
179 my $libpath = '';
e47a9bbc 180 while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) {
944acd49
GS
181 $libpath .= ' ' if length $libpath;
182 $libpath .= $1;
183 }
184 $self->{'LDLOADLIBS'} = $libs;
185 $self->{'LDDLFLAGS'} ||= $Config{'lddlflags'};
186 $self->{'LDDLFLAGS'} .= " $libpath";
187 }
68dc0745
PP
188 $self->{'DEV_NULL'} = '> NUL';
189 # $self->{'NOECHO'} = ''; # till we have it working
190}
191
3e3baf6d
TB
192
193=item constants (o)
194
195Initializes lots of constants and .SUFFIXES and .PHONY
196
197=cut
198
199sub constants {
200 my($self) = @_;
201 my(@m,$tmp);
202
203 for $tmp (qw/
204
205 AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION
206 VERSION_SYM XS_VERSION INST_BIN INST_EXE INST_LIB
207 INST_ARCHLIB INST_SCRIPT PREFIX INSTALLDIRS
208 INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB
209 INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB
210 PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
211 FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC
212 PERL_INC PERL FULLPERL
213
214 / ) {
215 next unless defined $self->{$tmp};
216 push @m, "$tmp = $self->{$tmp}\n";
217 }
218
219 push @m, qq{
220VERSION_MACRO = VERSION
221DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
222XS_VERSION_MACRO = XS_VERSION
223XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
224};
225
226 push @m, qq{
227MAKEMAKER = $INC{'ExtUtils\MakeMaker.pm'}
228MM_VERSION = $ExtUtils::MakeMaker::VERSION
229};
230
231 push @m, q{
232# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
233# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
234# ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) !!! Deprecated from MM 5.32 !!!
235# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
236# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
237};
238
239 for $tmp (qw/
240 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
241 LDFROM LINKTYPE
242 / ) {
243 next unless defined $self->{$tmp};
244 push @m, "$tmp = $self->{$tmp}\n";
245 }
246
247 push @m, "
248# Handy lists of source code files:
249XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
250C_FILES = ".join(" \\\n\t", @{$self->{C}})."
251O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
252H_FILES = ".join(" \\\n\t", @{$self->{H}})."
cae6c631
JD
253HTMLLIBPODS = ".join(" \\\n\t", sort keys %{$self->{HTMLLIBPODS}})."
254HTMLSCRIPTPODS = ".join(" \\\n\t", sort keys %{$self->{HTMLSCRIPTPODS}})."
3e3baf6d
TB
255MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
256MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
257";
258
259 for $tmp (qw/
cae6c631
JD
260 INST_HTMLPRIVLIBDIR INSTALLHTMLPRIVLIBDIR
261 INST_HTMLSITELIBDIR INSTALLHTMLSITELIBDIR
262 INST_HTMLSCRIPTDIR INSTALLHTMLSCRIPTDIR
263 INST_HTMLLIBDIR HTMLEXT
264 INST_MAN1DIR INSTALLMAN1DIR MAN1EXT
265 INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
3e3baf6d
TB
266 /) {
267 next unless defined $self->{$tmp};
268 push @m, "$tmp = $self->{$tmp}\n";
269 }
270
271 push @m, qq{
272.USESHELL :
273} if $DMAKE;
274
275 push @m, q{
276.NO_CONFIG_REC: Makefile
277} if $ENV{CLEARCASE_ROOT};
278
279 # why not q{} ? -- emacs
280 push @m, qq{
281# work around a famous dec-osf make(1) feature(?):
282makemakerdflt: all
283
284.SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
285
286# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
287# some make implementations will delete the Makefile when we rebuild it. Because
288# we call false(1) when we rebuild it. So make(1) is not completely wrong when it
289# does so. Our milage may vary.
290# .PRECIOUS: Makefile # seems to be not necessary anymore
291
292.PHONY: all config static dynamic test linkext manifest
293
294# Where is the Config information that we are using/depend on
295CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h
296};
297
298 my @parentdir = split(/::/, $self->{PARENT_NAME});
299 push @m, q{
300# Where to put things:
301INST_LIBDIR = }. $self->catdir('$(INST_LIB)',@parentdir) .q{
302INST_ARCHLIBDIR = }. $self->catdir('$(INST_ARCHLIB)',@parentdir) .q{
303
304INST_AUTODIR = }. $self->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
305INST_ARCHAUTODIR = }. $self->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
306};
307
308 if ($self->has_link_code()) {
309 push @m, '
310INST_STATIC = $(INST_ARCHAUTODIR)\$(BASEEXT)$(LIB_EXT)
311INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT)
312INST_BOOT = $(INST_ARCHAUTODIR)\$(BASEEXT).bs
313';
314 } else {
315 push @m, '
316INST_STATIC =
317INST_DYNAMIC =
318INST_BOOT =
319';
320 }
321
322 $tmp = $self->export_list;
323 push @m, "
324EXPORT_LIST = $tmp
325";
326 $tmp = $self->perl_archive;
327 push @m, "
328PERL_ARCHIVE = $tmp
329";
330
331# push @m, q{
332#INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{
333#
334#PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
335#};
336
337 push @m, q{
338TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
339
340PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
341};
342
343 join('',@m);
344}
345
346
68dc0745
PP
347sub path {
348 local $^W = 1;
349 my($self) = @_;
350 my $path = $ENV{'PATH'} || $ENV{'Path'} || $ENV{'path'};
351 my @path = split(';',$path);
352 foreach(@path) { $_ = '.' if $_ eq '' }
353 @path;
354}
355
356=item static_lib (o)
357
358Defines how to produce the *.a (or equivalent) files.
359
360=cut
361
362sub static_lib {
363 my($self) = @_;
364# Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
365# return '' unless $self->needs_linking(); #might be because of a subdir
366
367 return '' unless $self->has_link_code;
368
369 my(@m);
370 push(@m, <<'END');
3e3baf6d 371$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)\.exists
68dc0745
PP
372 $(RM_RF) $@
373END
374 # If this extension has it's own library (eg SDBM_File)
375 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
376 push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
377
378 push @m,
910dfcc8
GS
379q{ $(AR) }.($BORLAND ? '$@ $(OBJECT:^"+")'
380 : ($GCC ? '-ru $@ $(OBJECT)'
381 : '-out:$@ $(OBJECT)')).q{
3e3baf6d 382 }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld
68dc0745
PP
383 $(CHMOD) 755 $@
384};
385
386# Old mechanism - still available:
387
3e3baf6d 388 push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs}."\n\n"
68dc0745
PP
389 if $self->{PERL_SRC};
390
391 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
392 join('', "\n",@m);
393}
394
3e3baf6d
TB
395=item dynamic_bs (o)
396
397Defines targets for bootstrap files.
398
399=cut
68dc0745 400
3e3baf6d
TB
401sub dynamic_bs {
402 my($self, %attribs) = @_;
403 return '
404BOOTSTRAP =
405' unless $self->has_link_code();
406
407 return '
408BOOTSTRAP = '."$self->{BASEEXT}.bs".'
409
410# As Mkbootstrap might not write a file (if none is required)
411# we use touch to prevent make continually trying to remake it.
412# The DynaLoader only reads a non-empty file.
413$(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)\.exists
414 '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
415 '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
416 -MExtUtils::Mkbootstrap \
417 -e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
418 '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP)
419 $(CHMOD) 644 $@
420
421$(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists
422 '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT)
423 -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT)
424 $(CHMOD) 644 $@
425';
426}
68dc0745
PP
427
428=item dynamic_lib (o)
429
430Defines how to produce the *.so (or equivalent) files.
431
432=cut
433
434sub dynamic_lib {
435 my($self, %attribs) = @_;
436 return '' unless $self->needs_linking(); #might be because of a subdir
437
438 return '' unless $self->has_link_code;
439
3e3baf6d 440 my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
68dc0745
PP
441 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
442 my($ldfrom) = '$(LDFROM)';
443 my(@m);
444 push(@m,'
445# This section creates the dynamically loadable $(INST_DYNAMIC)
446# from $(OBJECT) and possibly $(MYEXTLIB).
447OTHERLDFLAGS = '.$otherldflags.'
448INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
449
3e3baf6d 450$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
68dc0745 451');
5b0d9cbe
NIS
452 if ($GCC) {
453 push(@m,
910dfcc8
GS
454 q{ dlltool --def $(EXPORT_LIST) --output-exp dll.exp
455 $(LD) -o $@ -Wl,--base-file -Wl,dll.base $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp
5b0d9cbe
NIS
456 dlltool --def $(EXPORT_LIST) --base-file dll.base --output-exp dll.exp
457 $(LD) -o $@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp });
dc0d354b
GS
458 } elsif ($BORLAND) {
459 push(@m,
460 q{ $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) }.$ldfrom.q{,$@,,}
461 .($DMAKE ? q{$(PERL_ARCHIVE:s,/,\,) $(LDLOADLIBS:s,/,\,) }
462 .q{$(MYEXTLIB:s,/,\,),$(EXPORT_LIST:s,/,\,)}
463 : q{$(subst /,\,$(PERL_ARCHIVE)) $(subst /,\,$(LDLOADLIBS)) }
464 .q{$(subst /,\,$(MYEXTLIB)),$(subst /,\,$(EXPORT_LIST))})
465 .q{,$(RESFILES)});
466 } else { # VC
467 push(@m,
468 q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) }
469 .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)});
5b0d9cbe 470 }
68dc0745
PP
471 push @m, '
472 $(CHMOD) 755 $@
473';
474
475 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
476 join('',@m);
477}
478
479sub perl_archive
480{
e3b8966e 481 my ($self) = @_;
eda5ff31 482 return '$(PERL_INC)\\'.$Config{'libperl'};
68dc0745
PP
483}
484
485sub export_list
486{
487 my ($self) = @_;
488 return "$self->{BASEEXT}.def";
489}
490
491=item canonpath
492
493No physical check on the filesystem, but a logical cleanup of a
494path. On UNIX eliminated successive slashes and successive "/.".
495
496=cut
497
498sub canonpath {
499 my($self,$path) = @_;
96e4d5b1 500 $path =~ s/^([a-z]:)/\u$1/;
68dc0745 501 $path =~ s|/|\\|g;
3e3baf6d 502 $path =~ s|(.)\\+|$1\\|g ; # xx////xx -> xx/xx
68dc0745
PP
503 $path =~ s|(\\\.)+\\|\\|g ; # xx/././xx -> xx/xx
504 $path =~ s|^(\.\\)+|| unless $path eq ".\\"; # ./xx -> xx
505 $path =~ s|\\$||
506 unless $path =~ m#^([a-z]:)?\\#; # xx/ -> xx
507 $path .= '.' if $path =~ m#\\$#;
508 $path;
509}
510
511=item perl_script
512
513Takes one argument, a file name, and returns the file name, if the
514argument is likely to be a perl script. On MM_Unix this is true for
515any ordinary, readable file.
516
517=cut
518
519sub perl_script {
520 my($self,$file) = @_;
cae6c631 521 return $file if -r $file && -f _;
68dc0745 522 return "$file.pl" if -r "$file.pl" && -f _;
cae6c631 523 return "$file.bat" if -r "$file.bat" && -f _;
68dc0745
PP
524 return;
525}
526
527=item pm_to_blib
528
529Defines target that copies all files in the hash PM to their
530destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
531
532=cut
533
534sub pm_to_blib {
535 my $self = shift;
536 my($autodir) = $self->catdir('$(INST_LIB)','auto');
537 return q{
538pm_to_blib: $(TO_INST_PM)
539 }.$self->{NOECHO}.q{$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \
540 "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \
dc0d354b
GS
541 -e "pm_to_blib(}.
542 ($NMAKE ? 'qw[ <<pmfiles.dat ],'
543 : $DMAKE ? 'qw[ $(mktmp,pmfiles.dat $(PM_TO_BLIB:s,\\,\\\\,)\n) ],'
544 : '{ qw[$(PM_TO_BLIB)] },'
545 ).q{'}.$autodir.q{')"
3e3baf6d 546 }. ($NMAKE ? q{
68dc0745
PP
547$(PM_TO_BLIB)
548<<
3e3baf6d 549 } : '') . $self->{NOECHO}.q{$(TOUCH) $@
68dc0745
PP
550};
551}
552
553=item test_via_harness (o)
554
555Helper method to write the test targets
556
557=cut
558
559sub test_via_harness {
560 my($self, $perl, $tests) = @_;
561 "\t$perl".q! -Mblib -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e "use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;" !."$tests\n";
562}
563
3e3baf6d 564
68dc0745
PP
565=item tool_autosplit (override)
566
567Use Win32 quoting on command line.
568
569=cut
570
571sub tool_autosplit{
572 my($self, %attribs) = @_;
573 my($asl) = "";
574 $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
575 q{
576# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
577AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MAutoSplit }.$asl.q{ -e "autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1);"
578};
579}
580
581=item tools_other (o)
582
583Win32 overrides.
584
585Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in
586the Makefile. Also defines the perl programs MKPATH,
587WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL.
588
589=cut
590
591sub tools_other {
592 my($self) = shift;
593 my @m;
594 my $bin_sh = $Config{sh} || 'cmd /c';
595 push @m, qq{
596SHELL = $bin_sh
3e3baf6d 597} unless $DMAKE; # dmake determines its own shell
68dc0745
PP
598
599 for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) {
600 push @m, "$_ = $self->{$_}\n";
601 }
602
603 push @m, q{
604# The following is a portable way to say mkdir -p
605# To see which directories are created, change the if 0 to if 1
606MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath
607
608# This helps us to minimize the effect of the .exists files A yet
609# better solution would be to have a stable file in the perl
610# distribution with a timestamp of zero. But this solution doesn't
611# need any changes to the core distribution and works with older perls
612EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime
613};
614
615
616 return join "", @m if $self->{PARENT};
617
618 push @m, q{
619# Here we warn users that an old packlist file was found somewhere,
620# and that they should call some uninstall routine
621WARN_IF_OLD_PACKLIST = $(PERL) -lwe "exit unless -f $$ARGV[0];" \\
622-e "print 'WARNING: I have found an old package in';" \\
623-e "print ' ', $$ARGV[0], '.';" \\
624-e "print 'Please make sure the two installations are not conflicting';"
625
626UNINST=0
627VERBINST=1
628
629MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \
3e3baf6d 630-e "install({ @ARGV },'$(VERBINST)',0,'$(UNINST)');"
68dc0745
PP
631
632DOC_INSTALL = $(PERL) -e "$$\=\"\n\n\";" \
633-e "print '=head2 ', scalar(localtime), ': C<', shift, '>', ' L<', shift, '>';" \
634-e "print '=over 4';" \
3e3baf6d 635-e "while (defined($$key = shift) and defined($$val = shift)) { print '=item *';print 'C<', \"$$key: $$val\", '>'; }" \
68dc0745
PP
636-e "print '=back';"
637
638UNINSTALL = $(PERL) -MExtUtils::Install \
639-e "uninstall($$ARGV[0],1,1); print \"\nUninstall is deprecated. Please check the";" \
640-e "print \" packlist above carefully.\n There may be errors. Remove the\";" \
641-e "print \" appropriate files manually.\n Sorry for the inconveniences.\n\""
642};
643
644 return join "", @m;
645}
646
3e3baf6d
TB
647=item xs_o (o)
648
649Defines suffix rules to go from XS to object files directly. This is
650only intended for broken make implementations.
651
652=cut
653
654sub xs_o { # many makes are too dumb to use xs_c then c_o
655 my($self) = shift;
656 return ''
657}
658
659=item top_targets (o)
660
661Defines the targets all, subdirs, config, and O_FILES
662
663=cut
664
665sub top_targets {
666# --- Target Sections ---
667
668 my($self) = shift;
669 my(@m);
670 push @m, '
671#all :: config $(INST_PM) subdirs linkext manifypods
672';
673
674 push @m, '
cae6c631 675all :: pure_all htmlifypods manifypods
3e3baf6d
TB
676 '.$self->{NOECHO}.'$(NOOP)
677'
678 unless $self->{SKIPHASH}{'all'};
679
680 push @m, '
681pure_all :: config pm_to_blib subdirs linkext
682 '.$self->{NOECHO}.'$(NOOP)
683
684subdirs :: $(MYEXTLIB)
685 '.$self->{NOECHO}.'$(NOOP)
686
687config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)\.exists
688 '.$self->{NOECHO}.'$(NOOP)
689
690config :: $(INST_ARCHAUTODIR)\.exists
691 '.$self->{NOECHO}.'$(NOOP)
692
693config :: $(INST_AUTODIR)\.exists
694 '.$self->{NOECHO}.'$(NOOP)
695';
696
697 push @m, qq{
698config :: Version_check
699 $self->{NOECHO}\$(NOOP)
700
701} unless $self->{PARENT} or ($self->{PERL_SRC} && $self->{INSTALLDIRS} eq "perl") or $self->{NO_VC};
702
703 push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
704
cae6c631
JD
705 if (%{$self->{HTMLLIBPODS}}) {
706 push @m, qq[
707config :: \$(INST_HTMLLIBDIR)/.exists
708 $self->{NOECHO}\$(NOOP)
709
710];
711 push @m, $self->dir_target(qw[$(INST_HTMLLIBDIR)]);
712 }
713
714 if (%{$self->{HTMLSCRIPTPODS}}) {
715 push @m, qq[
716config :: \$(INST_HTMLSCRIPTDIR)/.exists
717 $self->{NOECHO}\$(NOOP)
718
719];
720 push @m, $self->dir_target(qw[$(INST_HTMLSCRIPTDIR)]);
721 }
722
3e3baf6d
TB
723 if (%{$self->{MAN1PODS}}) {
724 push @m, qq[
725config :: \$(INST_MAN1DIR)\\.exists
726 $self->{NOECHO}\$(NOOP)
727
728];
729 push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
730 }
731 if (%{$self->{MAN3PODS}}) {
732 push @m, qq[
733config :: \$(INST_MAN3DIR)\\.exists
734 $self->{NOECHO}\$(NOOP)
735
736];
737 push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
738 }
739
740 push @m, '
741$(O_FILES): $(H_FILES)
742' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
743
744 push @m, q{
745help:
746 perldoc ExtUtils::MakeMaker
747};
748
749 push @m, q{
750Version_check:
751 }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
752 -MExtUtils::MakeMaker=Version_check \
753 -e "Version_check('$(MM_VERSION)')"
754};
755
756 join('',@m);
757}
758
cae6c631
JD
759=item htmlifypods (o)
760
761Defines targets and routines to translate the pods into HTML manpages
762and put them into the INST_HTMLLIBDIR and INST_HTMLSCRIPTDIR
763directories.
764
765Same as MM_Unix version (changes command-line quoting).
766
767=cut
768
769sub htmlifypods {
770 my($self, %attribs) = @_;
771 return "\nhtmlifypods : pure_all\n\t$self->{NOECHO}\$(NOOP)\n" unless
772 %{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}};
773 my($dist);
774 my($pod2html_exe);
775 if (defined $self->{PERL_SRC}) {
776 $pod2html_exe = $self->catfile($self->{PERL_SRC},'pod','pod2html');
777 } else {
778 $pod2html_exe = $self->catfile($Config{scriptdirexp},'pod2html');
779 }
780 unless ($pod2html_exe = $self->perl_script($pod2html_exe)) {
781 # No pod2html but some HTMLxxxPODS to be installed
782 print <<END;
783
784Warning: I could not locate your pod2html program. Please make sure,
785 your pod2html program is in your PATH before you execute 'make'
786
787END
788 $pod2html_exe = "-S pod2html";
789 }
790 my(@m);
791 push @m,
792qq[POD2HTML_EXE = $pod2html_exe\n],
793qq[POD2HTML = \$(PERL) -we "use File::Basename; use File::Path qw(mkpath); %m=\@ARGV;for (keys %m){" \\\n],
794q[-e "next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M '],
795 $self->{MAKEFILE}, q[';" \\
796-e "print qq(Htmlifying $$m{$$_}\n);" \\
797-e "$$dir = dirname($$m{$$_}); mkpath($$dir) unless -d $$dir;" \\
798-e "system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2HTML_EXE) ].qq[$$_>$$m{$$_}])==0 or warn qq(Couldn\\047t install $$m{$$_}\n);" \\
799-e "chmod(oct($(PERM_RW))), $$m{$$_} or warn qq(chmod $(PERM_RW) $$m{$$_}: $$!\n);}"
800];
801 push @m, "\nhtmlifypods : pure_all ";
802 push @m, join " \\\n\t", keys %{$self->{HTMLLIBPODS}}, keys %{$self->{HTMLSCRIPTPODS}};
803
804 push(@m,"\n");
805 if (%{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}}) {
806 push @m, "\t$self->{NOECHO}\$(POD2HTML) \\\n\t";
807 push @m, join " \\\n\t", %{$self->{HTMLLIBPODS}}, %{$self->{HTMLSCRIPTPODS}};
808 }
809 join('', @m);
810}
811
68dc0745
PP
812=item manifypods (o)
813
cae6c631 814We don't want manpage process.
68dc0745
PP
815
816=cut
817
818sub manifypods {
846f184a 819 my($self) = shift;
68dc0745
PP
820 return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n";
821}
822
823=item dist_ci (o)
824
825Same as MM_Unix version (changes command-line quoting).
826
827=cut
828
829sub dist_ci {
830 my($self) = shift;
831 my @m;
832 push @m, q{
833ci :
834 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=maniread \\
835 -e "@all = keys %{ maniread() };" \\
836 -e "print(\"Executing $(CI) @all\n\"); system(\"$(CI) @all\");" \\
837 -e "print(\"Executing $(RCS_LABEL) ...\n\"); system(\"$(RCS_LABEL) @all\");"
838};
839 join "", @m;
840}
841
842=item dist_core (o)
843
844Same as MM_Unix version (changes command-line quoting).
845
846=cut
847
848sub dist_core {
849 my($self) = shift;
850 my @m;
851 push @m, q{
852dist : $(DIST_DEFAULT)
853 }.$self->{NOECHO}.q{$(PERL) -le "print \"Warning: Makefile possibly out of date with $$vf\" if " \
854 -e "-e ($$vf=\"$(VERSION_FROM)\") and -M $$vf < -M \"}.$self->{MAKEFILE}.q{\";"
855
856tardist : $(DISTVNAME).tar$(SUFFIX)
857
858zipdist : $(DISTVNAME).zip
859
860$(DISTVNAME).tar$(SUFFIX) : distdir
861 $(PREOP)
862 $(TO_UNIX)
863 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
864 $(RM_RF) $(DISTVNAME)
865 $(COMPRESS) $(DISTVNAME).tar
866 $(POSTOP)
867
868$(DISTVNAME).zip : distdir
869 $(PREOP)
870 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
871 $(RM_RF) $(DISTVNAME)
872 $(POSTOP)
873
874uutardist : $(DISTVNAME).tar$(SUFFIX)
875 uuencode $(DISTVNAME).tar$(SUFFIX) \\
876 $(DISTVNAME).tar$(SUFFIX) > \\
877 $(DISTVNAME).tar$(SUFFIX)_uu
878
879shdist : distdir
880 $(PREOP)
881 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
882 $(RM_RF) $(DISTVNAME)
883 $(POSTOP)
884};
885 join "", @m;
886}
887
888=item pasthru (o)
889
890Defines the string that is passed to recursive make calls in
891subdirectories.
892
893=cut
894
895sub pasthru {
896 my($self) = shift;
3e3baf6d 897 return "PASTHRU = " . ($NMAKE ? "-nologo" : "");
68dc0745
PP
898}
899
900
901
9021;
903__END__
904
905=back
906
907=cut
908
5b0d9cbe 909