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