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