perl 5.003_07: lib/ExtUtils/xsubpp
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_VMS.pm
1 #   MM_VMS.pm
2 #   MakeMaker default methods for VMS
3 #   This package is inserted into @ISA of MakeMaker's MM before the
4 #   built-in ExtUtils::MM_Unix methods if MakeMaker.pm is run under VMS.
5 #
6 #   Author:  Charles Bailey  bailey@genetics.upenn.edu
7
8 package ExtUtils::MM_VMS;
9 $ExtUtils::MM_VMS::Revision=$ExtUtils::MM_VMS::Revision = '5.38 (02-Oct-1996)';
10 unshift @MM::ISA, 'ExtUtils::MM_VMS';
11
12 use Config;
13 require Exporter;
14 use VMS::Filespec;
15 use File::Basename;
16
17 Exporter::import('ExtUtils::MakeMaker', '$Verbose', '&neatvalue');
18
19 =head1 NAME
20
21 ExtUtils::MM_VMS - methods to override UN*X behaviour in ExtUtils::MakeMaker
22
23 =head1 SYNOPSIS
24
25  use ExtUtils::MM_VMS; # Done internally by ExtUtils::MakeMaker if needed
26
27 =head1 DESCRIPTION
28
29 See ExtUtils::MM_Unix for a documentation of the methods provided
30 there. This package overrides the implementation of these methods, not
31 the semantics.
32
33 =head2 Methods always loaded
34
35 =item eliminate_macros
36
37 Expands MM[KS]/Make macros in a text string, using the contents of
38 identically named elements of C<%$self>, and returns the result
39 as a file specification in Unix syntax.
40
41 =cut
42
43 sub eliminate_macros {
44     my($self,$path) = @_;
45     unless ($path) {
46         print "eliminate_macros('') = ||\n" if $Verbose >= 3;
47         return '';
48     }
49     my($npath) = unixify($path);
50     my($head,$macro,$tail);
51
52     # perform m##g in scalar context so it acts as an iterator
53     while ($npath =~ m#(.*?)\$\((\S+?)\)(.*)#g) { 
54         if ($self->{$2}) {
55             ($head,$macro,$tail) = ($1,$2,$3);
56             ($macro = unixify($self->{$macro})) =~ s#/$##;
57             $npath = "$head$macro$tail";
58         }
59     }
60     print "eliminate_macros($path) = |$npath|\n" if $Verbose >= 3;
61     $npath;
62 }
63
64 =item fixpath
65
66 Catchall routine to clean up problem MM[SK]/Make macros.  Expands macros
67 in any directory specification, in order to avoid juxtaposing two
68 VMS-syntax directories when MM[SK] is run.  Also expands expressions which
69 are all macro, so that we can tell how long the expansion is, and avoid
70 overrunning DCL's command buffer when MM[KS] is running.
71
72 If optional second argument has a TRUE value, then the return string is
73 a VMS-syntax directory specification, otherwise it is a VMS-syntax file
74 specification.
75
76 =cut
77
78 sub fixpath {
79     my($self,$path,$force_path) = @_;
80     unless ($path) {
81         print "eliminate_macros('') = ||\n" if $Verbose >= 3;
82         return '';
83     }
84     my($fixedpath,$prefix,$name);
85
86     if ($path =~ m#^\$\(.+\)$# || $path =~ m#[/:>\]]#) { 
87         if ($force_path or $path =~ /(?:DIR\)|\])$/) {
88             $fixedpath = vmspath($self->eliminate_macros($path));
89         }
90         else {
91             $fixedpath = vmsify($self->eliminate_macros($path));
92         }
93     }
94     elsif ((($prefix,$name) = ($path =~ m#^\$\(([^\)]+)\)(.+)#)) && $self->{$prefix}) {
95         my($vmspre) = vmspath($self->eliminate_macros("\$($prefix)")) || ''; # is it a dir or just a name?
96         $fixedpath = ($vmspre ? $vmspre : $self->{$prefix}) . $name;
97         $fixedpath = vmspath($fixedpath) if $force_path;
98     }
99     else {
100         $fixedpath = $path;
101         $fixedpath = vmspath($fixedpath) if $force_path;
102     }
103     # Convert names without directory or type to paths
104     if (!$force_path and $fixedpath !~ /[:>(.\]]/) { $fixedpath = vmspath($fixedpath); }
105     # Trim off root dirname if it's had other dirs inserted in front of it.
106     $fixedpath =~ s/\.000000([\]>])/$1/;
107     print "fixpath($path) = |$fixedpath|\n" if $Verbose >= 3;
108     $fixedpath;
109 }
110
111 =item catdir
112
113 Concatenates a list of file specifications, and returns the result as a
114 VMS-syntax directory specification.
115
116 =cut
117
118 sub catdir {
119     my($self,@dirs) = @_;
120     my($dir) = pop @dirs;
121     @dirs = grep($_,@dirs);
122     my($rslt);
123     if (@dirs) {
124       my($path) = (@dirs == 1 ? $dirs[0] : $self->catdir(@dirs));
125       my($spath,$sdir) = ($path,$dir);
126       $spath =~ s/.dir$//; $sdir =~ s/.dir$//; 
127       $sdir = $self->eliminate_macros($sdir) unless $sdir =~ /^[\w\-]+$/;
128       $rslt = $self->fixpath($self->eliminate_macros($spath)."/$sdir",1);
129     }
130     else { 
131       if ($dir =~ /^\$\([^\)]+\)$/) { $rslt = $dir; }
132       else                          { $rslt = vmspath($dir); }
133     }
134     print "catdir(",join(',',@_[1..$#_]),") = |$rslt|\n" if $Verbose >= 3;
135     $rslt;
136 }
137
138 =item catfile
139
140 Concatenates a list of file specifications, and returns the result as a
141 VMS-syntax directory specification.
142
143 =cut
144
145 sub catfile {
146     my($self,@files) = @_;
147     my($file) = pop @files;
148     @files = grep($_,@files);
149     my($rslt);
150     if (@files) {
151       my($path) = (@files == 1 ? $files[0] : $self->catdir(@files));
152       my($spath) = $path;
153       $spath =~ s/.dir$//;
154       if ( $spath =~ /^[^\)\]\/:>]+\)$/ && basename($file) eq $file) { $rslt = "$spath$file"; }
155       else {
156           $rslt = $self->eliminate_macros($spath);
157           $rslt = vmsify($rslt.($rslt ? '/' : '').unixify($file));
158       }
159     }
160     else { $rslt = vmsify($file); }
161     print "catfile(",join(',',@_[1..$#_]),") = |$rslt|\n" if $Verbose >= 3;
162     $rslt;
163 }
164
165 =item curdir (override)
166
167 Returns a string representing of the current directory.
168
169 =cut
170
171 sub curdir {
172     return '[]';
173 }
174
175 =item rootdir (override)
176
177 Returns a string representing of the root directory.
178
179 =cut
180
181 sub rootdir {
182     return '';
183 }
184
185 =item updir (override)
186
187 Returns a string representing of the parent directory.
188
189 =cut
190
191 sub updir {
192     return '[-]';
193 }
194
195 package ExtUtils::MM_VMS;
196
197 sub ExtUtils::MM_VMS::guess_name;
198 sub ExtUtils::MM_VMS::find_perl;
199 sub ExtUtils::MM_VMS::path;
200 sub ExtUtils::MM_VMS::maybe_command;
201 sub ExtUtils::MM_VMS::maybe_command_in_dirs;
202 sub ExtUtils::MM_VMS::perl_script;
203 sub ExtUtils::MM_VMS::file_name_is_absolute;
204 sub ExtUtils::MM_VMS::replace_manpage_separator;
205 sub ExtUtils::MM_VMS::init_others;
206 sub ExtUtils::MM_VMS::constants;
207 sub ExtUtils::MM_VMS::const_loadlibs;
208 sub ExtUtils::MM_VMS::cflags;
209 sub ExtUtils::MM_VMS::const_cccmd;
210 sub ExtUtils::MM_VMS::pm_to_blib;
211 sub ExtUtils::MM_VMS::tool_autosplit;
212 sub ExtUtils::MM_VMS::tool_xsubpp;
213 sub ExtUtils::MM_VMS::xsubpp_version;
214 sub ExtUtils::MM_VMS::tools_other;
215 sub ExtUtils::MM_VMS::dist;
216 sub ExtUtils::MM_VMS::c_o;
217 sub ExtUtils::MM_VMS::xs_c;
218 sub ExtUtils::MM_VMS::xs_o;
219 sub ExtUtils::MM_VMS::top_targets;
220 sub ExtUtils::MM_VMS::dlsyms;
221 sub ExtUtils::MM_VMS::dynamic_lib;
222 sub ExtUtils::MM_VMS::dynamic_bs;
223 sub ExtUtils::MM_VMS::static_lib;
224 sub ExtUtils::MM_VMS::manifypods;
225 sub ExtUtils::MM_VMS::processPL;
226 sub ExtUtils::MM_VMS::installbin;
227 sub ExtUtils::MM_VMS::subdir_x;
228 sub ExtUtils::MM_VMS::clean;
229 sub ExtUtils::MM_VMS::realclean;
230 sub ExtUtils::MM_VMS::dist_basics;
231 sub ExtUtils::MM_VMS::dist_core;
232 sub ExtUtils::MM_VMS::dist_dir;
233 sub ExtUtils::MM_VMS::dist_test;
234 sub ExtUtils::MM_VMS::install;
235 sub ExtUtils::MM_VMS::perldepend;
236 sub ExtUtils::MM_VMS::makefile;
237 sub ExtUtils::MM_VMS::test;
238 sub ExtUtils::MM_VMS::test_via_harness;
239 sub ExtUtils::MM_VMS::test_via_script;
240 sub ExtUtils::MM_VMS::makeaperl;
241 sub ExtUtils::MM_VMS::ext;
242 sub ExtUtils::MM_VMS::nicetext;
243
244 #use SelfLoader;
245 sub AUTOLOAD {
246     my $code;
247     if (defined fileno(DATA)) {
248         my $fh = select DATA;
249         my $o = $/;                     # For future reads from the file.
250         $/ = "\n__END__\n";
251         $code = <DATA>;
252         $/ = $o;
253         select $fh;
254         close DATA;
255         eval $code;
256         if ($@) {
257             $@ =~ s/ at .*\n//;
258             Carp::croak $@;
259         }
260     } else {
261         warn "AUTOLOAD called unexpectedly for $AUTOLOAD"; 
262     }
263     defined(&$AUTOLOAD) or die "Myloader inconsistency error";
264     goto &$AUTOLOAD;
265 }
266
267 1;
268
269 #__DATA__
270
271 =head2 SelfLoaded methods
272
273 Those methods which override default MM_Unix methods are marked
274 "(override)", while methods unique to MM_VMS are marked "(specific)".
275 For overridden methods, documentation is limited to an explanation
276 of why this method overrides the MM_Unix method; see the ExtUtils::MM_Unix
277 documentation for more details.
278
279 =item guess_name (override)
280
281 Try to determine name of extension being built.  We begin with the name
282 of the current directory.  Since VMS filenames are case-insensitive,
283 however, we look for a F<.pm> file whose name matches that of the current
284 directory (presumably the 'main' F<.pm> file for this extension), and try
285 to find a C<package> statement from which to obtain the Mixed::Case
286 package name.
287
288 =cut
289
290 sub guess_name {
291     my($self) = @_;
292     my($defname,$defpm);
293     local *PM;
294
295     $defname = basename(fileify($ENV{'DEFAULT'}));
296     $defname =~ s![\d\-_]*\.dir.*$!!;  # Clip off .dir;1 suffix, and package version
297     $defpm = $defname;
298     if (open(PM,"${defpm}.pm")){
299         while (<PM>) {
300             if (/^\s*package\s+([^;]+)/i) {
301                 $defname = $1;
302                 last;
303             }
304         }
305         print STDOUT "Warning (non-fatal): Couldn't find package name in ${defpm}.pm;\n\t",
306                      "defaulting package name to $defname\n"
307             if eof(PM);
308         close PM;
309     }
310     else {
311         print STDOUT "Warning (non-fatal): Couldn't find ${defpm}.pm;\n\t",
312                      "defaulting package name to $defname\n";
313     }
314     $defname =~ s#[\d.\-_]+$##;
315     $defname;
316 }
317
318 =item find_perl (override)
319
320 Use VMS file specification syntax and CLI commands to find and
321 invoke Perl images.
322
323 =cut
324
325 sub find_perl {
326     my($self, $ver, $names, $dirs, $trace) = @_;
327     my($name,$dir,$vmsfile,@sdirs,@snames,@cand);
328     my($inabs) = 0;
329     # Check in relative directories first, so we pick up the current
330     # version of Perl if we're running MakeMaker as part of the main build.
331     @sdirs = sort { my($absa) = $self->file_name_is_absolute($a);
332                     my($absb) = $self->file_name_is_absolute($b);
333                     if ($absa && $absb) { return $a cmp $b }
334                     else { return $absa ? 1 : ($absb ? -1 : ($a cmp $b)); }
335                   } @$dirs;
336     # Check miniperl before perl, and check names likely to contain
337     # version numbers before "generic" names, so we pick up an
338     # executable that's less likely to be from an old installation.
339     @snames = sort { my($ba) = $a =~ m!([^:>\]/]+)$!;  # basename
340                      my($bb) = $b =~ m!([^:>\]/]+)$!;
341                      my($ahasdir) = (length($a) - length($ba) > 0);
342                      my($bhasdir) = (length($b) - length($bb) > 0);
343                      if    ($ahasdir and not $bhasdir) { return 1; }
344                      elsif ($bhasdir and not $ahasdir) { return -1; }
345                      else { $bb =~ /\d/ <=> $ba =~ /\d/
346                             or substr($ba,0,1) cmp substr($bb,0,1)
347                             or length($bb) <=> length($ba) } } @$names;
348     # Image names containing Perl version use '_' instead of '.' under VMS
349     foreach $name (@snames) { $name =~ s/\.(\d+)$/_$1/; }
350     if ($trace >= 2){
351         print "Looking for perl $ver by these names:\n";
352         print "\t@snames,\n";
353         print "in these dirs:\n";
354         print "\t@sdirs\n";
355     }
356     foreach $dir (@sdirs){
357         next unless defined $dir; # $self->{PERL_SRC} may be undefined
358         $inabs++ if $self->file_name_is_absolute($dir);
359         if ($inabs == 1) {
360             # We've covered relative dirs; everything else is an absolute
361             # dir (probably an installed location).  First, we'll try potential
362             # command names, to see whether we can avoid a long MCR expression.
363             foreach $name (@snames) { push(@cand,$name) if $name =~ /^[\w\-\$]+$/; }
364             $inabs++; # Should happen above in next $dir, but just in case . . .
365         }
366         foreach $name (@snames){
367             if ($name !~ m![/:>\]]!) { push(@cand,$self->catfile($dir,$name)); }
368             else                     { push(@cand,$self->fixpath($name));      }
369         }
370     }
371     foreach $name (@cand) {
372         print "Checking $name\n" if ($trace >= 2);
373         # If it looks like a potential command, try it without the MCR
374         if ($name =~ /^[\w\-\$]+$/ &&
375             `$name -e "require $ver; print ""VER_OK\n"""` =~ /VER_OK/) {
376             print "Using PERL=$name\n" if $trace;
377             return $name;
378         }
379         next unless $vmsfile = $self->maybe_command($name);
380         $vmsfile =~ s/;[\d\-]*$//;  # Clip off version number; we can use a newer version as well
381         print "Executing $vmsfile\n" if ($trace >= 2);
382         if (`MCR $vmsfile -e "require $ver; print ""VER_OK\n"""` =~ /VER_OK/) {
383             print "Using PERL=MCR $vmsfile\n" if $trace;
384             return "MCR $vmsfile";
385         }
386     }
387     print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
388     0; # false and not empty
389 }
390
391 =item path (override)
392
393 Translate logical name DCL$PATH as a searchlist, rather than trying
394 to C<split> string value of C<$ENV{'PATH'}>.
395
396 =cut
397
398 sub path {
399     my(@dirs,$dir,$i);
400     while ($dir = $ENV{'DCL$PATH;' . $i++}) { push(@dirs,$dir); }
401     @dirs;
402 }
403
404 =item maybe_command (override)
405
406 Follows VMS naming conventions for executable files.
407 If the name passed in doesn't exactly match an executable file,
408 appends F<.Exe> to check for executable image, and F<.Com> to check
409 for DCL procedure.  If this fails, checks F<Sys$Share:> for an
410 executable file having the name specified.  Finally, appends F<.Exe>
411 and checks again.
412
413 =cut
414
415 sub maybe_command {
416     my($self,$file) = @_;
417     return $file if -x $file && ! -d _;
418     return "$file.exe" if -x "$file.exe";
419     return "$file.com" if -x "$file.com";
420     if ($file !~ m![/:>\]]!) {
421         my($shrfile) = 'Sys$Share:' . $file;
422         return $file if -x $shrfile && ! -d _;
423         return "$file.exe" if -x "$shrfile.exe";
424     }
425     return 0;
426 }
427
428 =item maybe_command_in_dirs (override)
429
430 Uses DCL argument quoting on test command line.
431
432 =cut
433
434 sub maybe_command_in_dirs {     # $ver is optional argument if looking for perl
435     my($self, $names, $dirs, $trace, $ver) = @_;
436     my($name, $dir);
437     foreach $dir (@$dirs){
438         next unless defined $dir; # $self->{PERL_SRC} may be undefined
439         foreach $name (@$names){
440             my($abs,$tryabs);
441             if ($self->file_name_is_absolute($name)) {
442                 $abs = $name;
443             } else {
444                 $abs = $self->catfile($dir, $name);
445             }
446             print "Checking $abs for $name\n" if ($trace >= 2);
447             next unless $tryabs = $self->maybe_command($abs);
448             print "Substituting $tryabs instead of $abs\n" 
449                 if ($trace >= 2 and $tryabs ne $abs);
450             $abs = $tryabs;
451             if (defined $ver) {
452                 print "Executing $abs\n" if ($trace >= 2);
453                 if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
454                     print "Using $abs\n" if $trace;
455                     return $abs;
456                 }
457             } else { # Do not look for perl
458                 return $abs;
459             }
460         }
461     }
462 }
463
464 =item perl_script (override)
465
466 If name passed in doesn't specify a readable file, appends F<.pl> and
467 tries again, since it's customary to have file types on all files
468 under VMS.
469
470 =cut
471
472 sub perl_script {
473     my($self,$file) = @_;
474     return $file if -r $file && ! -d _;
475     return "$file.pl" if -r "$file.pl" && ! -d _;
476     return '';
477 }
478
479 =item file_name_is_absolute (override)
480
481 Checks for VMS directory spec as well as Unix separators.
482
483 =cut
484
485 sub file_name_is_absolute {
486     my($self,$file) = @_;
487     $file =~ m!^/! or $file =~ m![<\[][^.\-\]>]! or $file =~ /:[^<\[]/;
488 }
489
490 =item replace_manpage_separator
491
492 Use as separator a character which is legal in a VMS-syntax file name.
493
494 =cut
495
496 sub replace_manpage_separator {
497     my($self,$man) = @_;
498     $man = unixify($man);
499     $man =~ s#/+#__#g;
500     $man;
501 }
502
503 =item init_others (override)
504
505 Provide VMS-specific forms of various utility commands, then hand
506 off to the default MM_Unix method.
507
508 =cut
509
510 sub init_others {
511     my($self) = @_;
512
513     $self->{NOOP} = 'Continue';
514     $self->{FIRST_MAKEFILE} ||= 'Descrip.MMS';
515     $self->{MAKE_APERL_FILE} ||= 'Makeaperl.MMS';
516     $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
517     $self->{NOECHO} ||= '@ ';
518     $self->{RM_F} = '$(PERL) -e "foreach (@ARGV) { 1 while ( -d $_ ? rmdir $_ : unlink $_)}"';
519     $self->{RM_RF} = '$(PERL) "-I$(PERL_LIB)" -e "use File::Path; @dirs = map(VMS::Filespec::unixify($_),@ARGV); rmtree(\@dirs,0,0)"';
520     $self->{TOUCH} = '$(PERL) -e "$t=time; foreach (@ARGV) { -e $_ ? utime($t,$t,@ARGV) : (open(F,qq(>$_)),close F)}"';
521     $self->{CHMOD} = '$(PERL) -e "chmod @ARGV"';  # expect Unix syntax from MakeMaker
522     $self->{CP} = 'Copy/NoConfirm';
523     $self->{MV} = 'Rename/NoConfirm';
524     $self->{UMASK_NULL} = '! ';  
525     &ExtUtils::MM_Unix::init_others;
526 }
527
528 =item constants (override)
529
530 Fixes up numerous file and directory macros to insure VMS syntax
531 regardless of input syntax.  Also adds a few VMS-specific macros
532 and makes lists of files comma-separated.
533
534 =cut
535
536 sub constants {
537     my($self) = @_;
538     my(@m,$def,$macro);
539
540     if ($self->{DEFINE} ne '') {
541         my(@defs) = split(/\s+/,$self->{DEFINE});
542         foreach $def (@defs) {
543             next unless $def;
544             $def =~ s/^-D//;
545             $def = "\"$def\"" if $def =~ /=/;
546         }
547         $self->{DEFINE} = join ',',@defs;
548     }
549
550     if ($self->{OBJECT} =~ /\s/) {
551         $self->{OBJECT} =~ s/(\\)?\n+\s+/ /g;
552         $self->{OBJECT} = map($self->fixpath($_),split(/,?\s+/,$self->{OBJECT}));
553     }
554     $self->{LDFROM} = join(' ',map($self->fixpath($_),split(/,?\s+/,$self->{LDFROM})));
555
556
557     # Fix up directory specs
558     $self->{ROOTEXT} = $self->{ROOTEXT} ? $self->fixpath($self->{ROOTEXT},1)
559                                         : '[]';
560     foreach $macro ( qw [
561             INST_BIN INST_SCRIPT INST_LIB INST_ARCHLIB INST_EXE INSTALLPRIVLIB
562             INSTALLARCHLIB INSTALLSCRIPT INSTALLBIN PERL_LIB PERL_ARCHLIB
563             PERL_INC PERL_SRC FULLEXT INST_MAN1DIR INSTALLMAN1DIR
564             INST_MAN3DIR INSTALLMAN3DIR INSTALLSITELIB INSTALLSITEARCH
565             SITELIBEXP SITEARCHEXP ] ) {
566         next unless defined $self->{$macro};
567         $self->{$macro} = $self->fixpath($self->{$macro},1);
568     }
569     $self->{PERL_VMS} = $self->catdir($self->{PERL_SRC},q(VMS))
570         if ($self->{PERL_SRC});
571                         
572
573
574     # Fix up file specs
575     foreach $macro ( qw[LIBPERL_A FIRST_MAKEFILE MAKE_APERL_FILE MYEXTLIB] ) {
576         next unless defined $self->{$macro};
577         $self->{$macro} = $self->fixpath($self->{$macro});
578     }
579
580     foreach $macro (qw/
581               AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION VERSION_SYM XS_VERSION
582               INST_BIN INST_EXE INST_LIB INST_ARCHLIB INST_SCRIPT PREFIX
583               INSTALLDIRS INSTALLPRIVLIB  INSTALLARCHLIB INSTALLSITELIB
584               INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB
585               PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
586               FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC PERL_VMS
587               PERL_INC PERL FULLPERL
588               / ) {
589         next unless defined $self->{$macro};
590         push @m, "$macro = $self->{$macro}\n";
591     }
592
593
594     push @m, q[
595 VERSION_MACRO = VERSION
596 DEFINE_VERSION = "$(VERSION_MACRO)=""$(VERSION)"""
597 XS_VERSION_MACRO = XS_VERSION
598 XS_DEFINE_VERSION = "$(XS_VERSION_MACRO)=""$(XS_VERSION)"""
599
600 MAKEMAKER = ],$self->catfile($self->{PERL_LIB},'ExtUtils','MakeMaker.pm'),qq[
601 MM_VERSION = $ExtUtils::MakeMaker::VERSION
602 MM_REVISION = $ExtUtils::MakeMaker::Revision
603 MM_VMS_REVISION = $ExtUtils::MM_VMS::Revision
604
605 # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
606 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
607 # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
608 # DLBASE  = Basename part of dynamic library. May be just equal BASEEXT.
609 ];
610
611     for $tmp (qw/
612               FULLEXT VERSION_FROM OBJECT LDFROM
613               / ) {
614         next unless defined $self->{$tmp};
615         push @m, "$tmp = ",$self->fixpath($self->{$tmp}),"\n";
616     }
617
618     for $tmp (qw/
619               BASEEXT PARENT_NAME DLBASE INC DEFINE LINKTYPE
620               / ) {
621         next unless defined $self->{$tmp};
622         push @m, "$tmp = $self->{$tmp}\n";
623     }
624
625     for $tmp (qw/ XS MAN1PODS MAN3PODS PM /) {
626         next unless defined $self->{$tmp};
627         my(%tmp,$key);
628         for $key (keys %{$self->{$tmp}}) {
629             $tmp{$self->fixpath($key)} = $self->fixpath($self->{$tmp}{$key});
630         }
631         $self->{$tmp} = \%tmp;
632     }
633
634     for $tmp (qw/ C O_FILES H /) {
635         next unless defined $self->{$tmp};
636         my(@tmp,$val);
637         for $val (@{$self->{$tmp}}) {
638             push(@tmp,$self->fixpath($val));
639         }
640         $self->{$tmp} = \@tmp;
641     }
642
643     push @m,'
644
645 # Handy lists of source code files:
646 XS_FILES = ',join(', ', sort keys %{$self->{XS}}),'
647 C_FILES  = ',join(', ', @{$self->{C}}),'
648 O_FILES  = ',join(', ', @{$self->{O_FILES}} ),'
649 H_FILES  = ',join(', ', @{$self->{H}}),'
650 MAN1PODS = ',join(', ', sort keys %{$self->{MAN1PODS}}),'
651 MAN3PODS = ',join(', ', sort keys %{$self->{MAN3PODS}}),'
652
653 ';
654
655     for $tmp (qw/
656               INST_MAN1DIR INSTALLMAN1DIR MAN1EXT INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
657               /) {
658         next unless defined $self->{$tmp};
659         push @m, "$tmp = $self->{$tmp}\n";
660     }
661
662 push @m,"
663 .SUFFIXES : \$(OBJ_EXT) .c .cpp .cxx .xs
664
665 # Here is the Config.pm that we are using/depend on
666 CONFIGDEP = \$(PERL_ARCHLIB)Config.pm, \$(PERL_INC)config.h \$(VERSION_FROM)
667
668 # Where to put things:
669 INST_LIBDIR      = $self->{INST_LIBDIR}
670 INST_ARCHLIBDIR  = $self->{INST_ARCHLIBDIR}
671
672 INST_AUTODIR     = $self->{INST_AUTODIR}
673 INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR}
674 ";
675
676     if ($self->has_link_code()) {
677         push @m,'
678 INST_STATIC = $(INST_ARCHAUTODIR)$(BASEEXT)$(LIB_EXT)
679 INST_DYNAMIC = $(INST_ARCHAUTODIR)$(BASEEXT).$(DLEXT)
680 INST_BOOT = $(INST_ARCHAUTODIR)$(BASEEXT).bs
681 ';
682     } else {
683         push @m,'
684 INST_STATIC =
685 INST_DYNAMIC =
686 INST_BOOT =
687 EXPORT_LIST = $(BASEEXT).opt
688 PERL_ARCHIVE = ',($ENV{'PERLSHR'} ? $ENV{'PERLSHR'} : 'Sys$Share:PerlShr.Exe'),'
689 ';
690     }
691
692     $self->{TO_INST_PM} = [ sort keys %{$self->{PM}} ];
693     $self->{PM_TO_BLIB} = [ %{$self->{PM}} ];
694     push @m,'
695 TO_INST_PM = ',join(', ',@{$self->{TO_INST_PM}}),'
696
697 PM_TO_BLIB = ',join(', ',@{$self->{PM_TO_BLIB}}),'
698 ';
699
700     join('',@m);
701 }
702
703 =item const_loadlibs (override)
704
705 Basically a stub which passes through library specfications provided
706 by the caller.  Will be updated or removed when VMS support is added
707 to ExtUtils::Liblist.
708
709 =cut
710
711 sub const_loadlibs {
712     my($self) = @_;
713     my (@m);
714     push @m, "
715 # $self->{NAME} might depend on some other libraries.
716 # (These comments may need revising:)
717 #
718 # Dependent libraries can be linked in one of three ways:
719 #
720 #  1.  (For static extensions) by the ld command when the perl binary
721 #      is linked with the extension library. See EXTRALIBS below.
722 #
723 #  2.  (For dynamic extensions) by the ld command when the shared
724 #      object is built/linked. See LDLOADLIBS below.
725 #
726 #  3.  (For dynamic extensions) by the DynaLoader when the shared
727 #      object is loaded. See BSLOADLIBS below.
728 #
729 # EXTRALIBS =   List of libraries that need to be linked with when
730 #               linking a perl binary which includes this extension
731 #               Only those libraries that actually exist are included.
732 #               These are written to a file and used when linking perl.
733 #
734 # LDLOADLIBS =  List of those libraries which can or must be linked into
735 #               the shared library when created using ld. These may be
736 #               static or dynamic libraries.
737 #               LD_RUN_PATH is a colon separated list of the directories
738 #               in LDLOADLIBS. It is passed as an environment variable to
739 #               the process that links the shared library.
740 #
741 # BSLOADLIBS =  List of those libraries that are needed but can be
742 #               linked in dynamically at run time on this platform.
743 #               SunOS/Solaris does not need this because ld records
744 #               the information (from LDLOADLIBS) into the object file.
745 #               This list is used to create a .bs (bootstrap) file.
746 #
747 EXTRALIBS  = ",map($self->fixpath($_) . ' ',$self->{'EXTRALIBS'}),"
748 BSLOADLIBS = ",map($self->fixpath($_) . ' ',$self->{'BSLOADLIBS'}),"
749 LDLOADLIBS = ",map($self->fixpath($_) . ' ',$self->{'LDLOADLIBS'}),"\n";
750
751     join('',@m);
752 }
753
754 =item cflags (override)
755
756 Bypass shell script and produce qualifiers for CC directly (but warn
757 user if a shell script for this extension exists).  Fold multiple
758 /Defines into one, since some C compilers pay attention to only one
759 instance of this qualifier on the command line.
760
761 =cut
762
763 sub cflags {
764     my($self,$libperl) = @_;
765     my($quals) = $Config{'ccflags'};
766     my($name,$sys,@m);
767     my($optimize) = '/Optimize';
768
769     ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
770     print STDOUT "Unix shell script ".$Config{"$self->{'BASEEXT'}_cflags"}.
771          " required to modify CC command for $self->{'BASEEXT'}\n"
772     if ($Config{$name});
773
774     # Deal with $self->{DEFINE} here since some C compilers pay attention
775     # to only one /Define clause on command line, so we have to
776     # conflate the ones from $Config{'cc'} and $self->{DEFINE}
777     if ($quals =~ m:(.*)/define=\(?([^\(\/\)\s]+)\)?(.*)?:i) {
778         $quals = "$1/Define=($2," . ($self->{DEFINE} ? "$self->{DEFINE}," : '') .
779                  "\$(DEFINE_VERSION),\$(XS_DEFINE_VERSION))$3";
780     }
781     else {
782         $quals .= '/Define=(' . ($self->{DEFINE} ? "$self->{DEFINE}," : '') .
783                   '$(DEFINE_VERSION),$(XS_DEFINE_VERSION))';
784     }
785
786     $libperl or $libperl = $self->{LIBPERL_A} || "libperl.olb";
787     if ($libperl =~ /libperl(\w+)\./i) {
788         my($type) = uc $1;
789         my(%map) = ( 'D'  => 'DEBUGGING', 'E' => 'EMBED', 'M' => 'MULTIPLICITY',
790                      'DE' => 'DEBUGGING,EMBED', 'DM' => 'DEBUGGING,MULTIPLICITY',
791                      'EM' => 'EMBED,MULTIPLICITY', 'DEM' => 'DEBUGGING,EMBED,MULTIPLICITY' );
792         $quals =~ s:/define=\(([^\)]+)\):/Define=($1,$map{$type}):i
793     }
794
795     # Likewise with $self->{INC} and /Include
796     my($incstr) = '/Include=($(PERL_INC)';
797     if ($self->{'INC'}) {
798         my(@includes) = split(/\s+/,$self->{INC});
799         foreach (@includes) {
800             s/^-I//;
801             $incstr .= ', '.$self->fixpath($_,1);
802         }
803     }
804     $quals .= "$incstr)";
805
806     $optimize = '/Debug/NoOptimize'
807         if ($self->{OPTIMIZE} =~ /-g/ or $self->{OPTIMIZE} =~ m!/Debug!i);
808
809     return $self->{CFLAGS} = qq{
810 CCFLAGS = $quals
811 OPTIMIZE = $optimize
812 PERLTYPE =
813 SPLIT =
814 LARGE =
815 };
816 }
817
818 =item const_cccmd (override)
819
820 Adds directives to point C preprocessor to the right place when
821 handling #include E<lt>sys/foo.hE<gt> directives.  Also constructs CC
822 command line a bit differently than MM_Unix method.
823
824 =cut
825
826 sub const_cccmd {
827     my($self,$libperl) = @_;
828     my(@m);
829
830     return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
831     return '' unless $self->needs_linking();
832     if ($Config{'vms_cc_type'} eq 'gcc') {
833         push @m,'
834 .FIRST
835         ',$self->{NOECHO},'If F$TrnLnm("Sys").eqs."" Then Define/NoLog SYS GNU_CC_Include:[VMS]';
836     }
837     elsif ($Config{'vms_cc_type'} eq 'vaxc') {
838         push @m,'
839 .FIRST
840         ',$self->{NOECHO},'If F$TrnLnm("Sys").eqs."" .and. F$TrnLnm("VAXC$Include").eqs."" Then Define/NoLog SYS Sys$Library
841         ',$self->{NOECHO},'If F$TrnLnm("Sys").eqs."" .and. F$TrnLnm("VAXC$Include").nes."" Then Define/NoLog SYS VAXC$Include';
842     }
843     else {
844         push @m,'
845 .FIRST
846         ',$self->{NOECHO},'If F$TrnLnm("Sys").eqs."" .and. F$TrnLnm("DECC$System_Include").eqs."" Then Define/NoLog SYS ',
847                 ($Config{'arch'} eq 'VMS_AXP' ? 'Sys$Library' : 'DECC$Library_Include'),'
848         ',$self->{NOECHO},'If F$TrnLnm("Sys").eqs."" .and. F$TrnLnm("DECC$System_Include").nes."" Then Define/NoLog SYS DECC$System_Include';
849     }
850
851     push(@m, "\n\nCCCMD = $Config{'cc'} \$(CCFLAGS)\$(OPTIMIZE)\n");
852
853     $self->{CONST_CCCMD} = join('',@m);
854 }
855
856 =item pm_to_blib (override)
857
858 DCL I<still> accepts a maximum of 255 characters on a command
859 line, so we write the (potentially) long list of file names
860 to a temp file, then persuade Perl to read it instead of the
861 command line to find args.
862
863 =cut
864
865 sub pm_to_blib {
866     my($self) = @_;
867     my($line,$from,$to,@m);
868     my($autodir) = $self->catdir('$(INST_LIB)','auto');
869     my(@files) = @{$self->{PM_TO_BLIB}};
870
871     push @m, q{
872
873 # Dummy target to match Unix target name; we use pm_to_blib.ts as
874 # timestamp file to avoid repeated invocations under VMS
875 pm_to_blib : pm_to_blib.ts
876         $(NOECHO) $(NOOP)
877
878 # As always, keep under DCL's 255-char limit
879 pm_to_blib.ts : $(TO_INST_PM)
880         $(NOECHO) $(PERL) -e "print '},shift(@files),q{ },shift(@files),q{'" >.MM_tmp
881 };
882
883     $line = '';  # avoid uninitialized var warning
884     while ($from = shift(@files),$to = shift(@files)) {
885         $line .= " $from $to";
886         if (length($line) > 128) {
887             push(@m,"\t\$(NOECHO) \$(PERL) -e \"print '$line'\" >>.MM_tmp\n");
888             $line = '';
889         }
890     }
891     push(@m,"\t\$(NOECHO) \$(PERL) -e \"print '$line'\" >>.MM_tmp\n") if $line;
892
893     push(@m,q[  $(PERL) "-I$(PERL_LIB)" "-MExtUtils::Install" -e "pm_to_blib({split(' ',<STDIN>)},'].$autodir.q[')" <.MM_tmp]);
894     push(@m,qq[
895         \$(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;
896         \$(NOECHO) \$(TOUCH) pm_to_blib.ts
897 ]);
898
899     join('',@m);
900 }
901
902 =item tool_autosplit (override)
903
904 Use VMS-style quoting on command line.
905
906 =cut
907
908 sub tool_autosplit{
909     my($self, %attribs) = @_;
910     my($asl) = "";
911     $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
912     q{
913 # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
914 AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use AutoSplit;}.$asl.q{ AutoSplit::autosplit($ARGV[0], $ARGV[1], 0, 1, 1) ;"
915 };
916 }
917
918 =item tool_sxubpp (override)
919
920 Use VMS-style quoting on xsubpp command line.
921
922 =cut
923
924 sub tool_xsubpp {
925     my($self) = @_;
926     return '' unless $self->needs_linking;
927     my($xsdir) = $self->catdir($self->{PERL_LIB},'ExtUtils');
928     # drop back to old location if xsubpp is not in new location yet
929     $xsdir = $self->catdir($self->{PERL_SRC},'ext') unless (-f $self->catfile($xsdir,'xsubpp'));
930     my(@tmdeps) = '$(XSUBPPDIR)typemap';
931     if( $self->{TYPEMAPS} ){
932         my $typemap;
933         foreach $typemap (@{$self->{TYPEMAPS}}){
934                 if( ! -f  $typemap ){
935                         warn "Typemap $typemap not found.\n";
936                 }
937                 else{
938                         push(@tmdeps, $self->fixpath($typemap));
939                 }
940         }
941     }
942     push(@tmdeps, "typemap") if -f "typemap";
943     my(@tmargs) = map("-typemap $_", @tmdeps);
944     if( exists $self->{XSOPT} ){
945         unshift( @tmargs, $self->{XSOPT} );
946     }
947
948     my $xsubpp_version = $self->xsubpp_version($self->catfile($xsdir,'xsubpp'));
949
950     # What are the correct thresholds for version 1 && 2 Paul?
951     if ( $xsubpp_version > 1.923 ){
952         $self->{XSPROTOARG} = '' unless defined $self->{XSPROTOARG};
953     } else {
954         if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) {
955             print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp.
956         Your version of xsubpp is $xsubpp_version and cannot handle this.
957         Please upgrade to a more recent version of xsubpp.
958 };
959         } else {
960             $self->{XSPROTOARG} = "";
961         }
962     }
963
964     "
965 XSUBPPDIR = $xsdir
966 XSUBPP = \$(PERL) \"-I\$(PERL_ARCHLIB)\" \"-I\$(PERL_LIB)\" \$(XSUBPPDIR)xsubpp
967 XSPROTOARG = $self->{XSPROTOARG}
968 XSUBPPDEPS = @tmdeps
969 XSUBPPARGS = @tmargs
970 ";
971 }
972
973 =item xsubpp_version (override)
974
975 Test xsubpp exit status according to VMS rules ($sts & 1 ==E<gt> good)
976 rather than Unix rules ($sts == 0 ==E<gt> good).
977
978 =cut
979
980 sub xsubpp_version
981 {
982     my($self,$xsubpp) = @_;
983     my ($version) ;
984     return '' unless $self->needs_linking;
985
986     # try to figure out the version number of the xsubpp on the system
987
988     # first try the -v flag, introduced in 1.921 & 2.000a2
989
990     my $command = "$self->{PERL} \"-I$self->{PERL_LIB}\" $xsubpp -v";
991     print "Running: $command\n" if $Verbose;
992     $version = `$command` ;
993     warn "Running '$command' exits with status " . $? unless ($? & 1);
994     chop $version ;
995
996     return $1 if $version =~ /^xsubpp version (.*)/ ;
997
998     # nope, then try something else
999
1000     my $counter = '000';
1001     my ($file) = 'temp' ;
1002     $counter++ while -e "$file$counter"; # don't overwrite anything
1003     $file .= $counter;
1004
1005     local(*F);
1006     open(F, ">$file") or die "Cannot open file '$file': $!\n" ;
1007     print F <<EOM ;
1008 MODULE = fred PACKAGE = fred
1009
1010 int
1011 fred(a)
1012         int     a;
1013 EOM
1014
1015     close F ;
1016
1017     $command = "$self->{PERL} $xsubpp $file";
1018     print "Running: $command\n" if $Verbose;
1019     my $text = `$command` ;
1020     warn "Running '$command' exits with status " . $? unless ($? & 1);
1021     unlink $file ;
1022
1023     # gets 1.2 -> 1.92 and 2.000a1
1024     return $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/  ;
1025
1026     # it is either 1.0 or 1.1
1027     return 1.1 if $text =~ /^Warning: ignored semicolon/ ;
1028
1029     # none of the above, so 1.0
1030     return "1.0" ;
1031 }
1032
1033 =item tools_other (override)
1034
1035 Adds a few MM[SK] macros, and shortens some the installatin commands,
1036 in order to stay under DCL's 255-character limit.  Also changes
1037 EQUALIZE_TIMESTAMP to set revision date of target file to one second
1038 later than source file, since MMK interprets precisely equal revision
1039 dates for a source and target file as a sign that the target needs
1040 to be updated.
1041
1042 =cut
1043
1044 sub tools_other {
1045     my($self) = @_;
1046     qq!
1047 # Assumes \$(MMS) invokes MMS or MMK
1048 # (It is assumed in some cases later that the default makefile name
1049 # (Descrip.MMS for MM[SK]) is used.)
1050 USEMAKEFILE = /Descrip=
1051 USEMACROS = /Macro=(
1052 MACROEND = )
1053 MAKEFILE = Descrip.MMS
1054 SHELL = Posix
1055 TOUCH = $self->{TOUCH}
1056 CHMOD = $self->{CHMOD}
1057 CP = $self->{CP}
1058 MV = $self->{MV}
1059 RM_F  = $self->{RM_F}
1060 RM_RF = $self->{RM_RF}
1061 UMASK_NULL = $self->{UMASK_NULL}
1062 NOOP = $self->{NOOP}
1063 NOECHO = $self->{NOECHO}
1064 MKPATH = Create/Directory
1065 EQUALIZE_TIMESTAMP = \$(PERL) -we "open F,qq{>\$ARGV[1]};close F;utime(0,(stat(\$ARGV[0]))[9]+1,\$ARGV[1])"
1066 !. ($self->{PARENT} ? '' : 
1067 qq!WARN_IF_OLD_PACKLIST = \$(PERL) -e "if (-f \$ARGV[0]){print qq[WARNING: Old package found (\$ARGV[0]); please check for collisions\\n]}"
1068 MOD_INSTALL = \$(PERL) "-I\$(PERL_LIB)" "-MExtUtils::Install" -e "install({split(' ',<STDIN>)},1);"
1069 DOC_INSTALL = \$(PERL) -e "\@ARGV=split(/\\|/,<STDIN>);print '=head2 ',scalar(localtime),': C<',shift,qq[>\\n\\n=over 4\\n\\n];while(\$key=shift && \$val=shift){print qq[=item *\\n\\nC<\$key: \$val>\\n\\n];}print qq[=back\\n\\n]"
1070 UNINSTALL = \$(PERL) "-I\$(PERL_LIB)" "-MExtUtils::Install" -e "uninstall(\$ARGV[0],1);"
1071 !);
1072 }
1073
1074 =item dist (override)
1075
1076 Provide VMSish defaults for some values, then hand off to
1077 default MM_Unix method.
1078
1079 =cut
1080
1081 sub dist {
1082     my($self, %attribs) = @_;
1083     $attribs{VERSION}      ||= $self->{VERSION_SYM};
1084     $attribs{ZIPFLAGS}     ||= '-Vu';
1085     $attribs{COMPRESS}     ||= 'gzip';
1086     $attribs{SUFFIX}       ||= '-gz';
1087     $attribs{SHAR}         ||= 'vms_share';
1088     $attribs{DIST_DEFAULT} ||= 'zipdist';
1089
1090     return ExtUtils::MM_Unix::dist($self,%attribs);
1091 }
1092
1093 =item c_o (override)
1094
1095 Use VMS syntax on command line.  In particular, $(DEFINE) and
1096 $(PERL_INC) have been pulled into $(CCCMD).  Also use MM[SK] macros.
1097
1098 =cut
1099
1100 sub c_o {
1101     my($self) = @_;
1102     return '' unless $self->needs_linking();
1103     '
1104 .c$(OBJ_EXT) :
1105         $(CCCMD) $(CCCDLFLAGS) $(MMS$TARGET_NAME).c
1106
1107 .cpp$(OBJ_EXT) :
1108         $(CCCMD) $(CCCDLFLAGS) $(MMS$TARGET_NAME).cpp
1109
1110 .cxx$(OBJ_EXT) :
1111         $(CCCMD) $(CCCDLFLAGS) $(MMS$TARGET_NAME).cxx
1112
1113 ';
1114 }
1115
1116 =item xs_c (override)
1117
1118 Use MM[SK] macros.
1119
1120 =cut
1121
1122 sub xs_c {
1123     my($self) = @_;
1124     return '' unless $self->needs_linking();
1125     '
1126 .xs.c :
1127         $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $(MMS$TARGET_NAME).xs >$(MMS$TARGET)
1128 ';
1129 }
1130
1131 =item xs_o (override)
1132
1133 Use MM[SK] macros, and VMS command line for C compiler.
1134
1135 =cut
1136
1137 sub xs_o {      # many makes are too dumb to use xs_c then c_o
1138     my($self) = @_;
1139     return '' unless $self->needs_linking();
1140     '
1141 .xs$(OBJ_EXT) :
1142         $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $(MMS$TARGET_NAME).xs >$(MMS$TARGET_NAME).c
1143         $(CCCMD) $(CCCDLFLAGS) $(MMS$TARGET_NAME).c
1144 ';
1145 }
1146
1147 =item top_targets (override)
1148
1149 Use VMS quoting on command line for Version_check.
1150
1151 =cut
1152
1153 sub top_targets {
1154     my($self) = shift;
1155     my(@m);
1156     push @m, '
1157 all :: pure_all manifypods
1158         $(NOECHO) $(NOOP)
1159
1160 pure_all :: config pm_to_blib subdirs linkext
1161         $(NOECHO) $(NOOP)
1162
1163 subdirs :: $(MYEXTLIB)
1164         $(NOECHO) $(NOOP)
1165
1166 config :: $(MAKEFILE) $(INST_LIBDIR).exists
1167         $(NOECHO) $(NOOP)
1168
1169 config :: $(INST_ARCHAUTODIR).exists
1170         $(NOECHO) $(NOOP)
1171
1172 config :: $(INST_AUTODIR).exists
1173         $(NOECHO) $(NOOP)
1174 ';
1175
1176     push @m, q{
1177 config :: Version_check
1178         $(NOECHO) $(NOOP)
1179
1180 } unless $self->{PARENT} or ($self->{PERL_SRC} && $self->{INSTALLDIRS} eq "perl") or $self->{NO_VC};
1181
1182
1183     push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
1184     if (%{$self->{MAN1PODS}}) {
1185         push @m, q[
1186 config :: $(INST_MAN1DIR).exists
1187         $(NOECHO) $(NOOP)
1188 ];
1189         push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
1190     }
1191     if (%{$self->{MAN3PODS}}) {
1192         push @m, q[
1193 config :: $(INST_MAN3DIR).exists
1194         $(NOECHO) $(NOOP)
1195 ];
1196         push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
1197     }
1198
1199     push @m, '
1200 $(O_FILES) : $(H_FILES)
1201 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
1202
1203     push @m, q{
1204 help :
1205         perldoc ExtUtils::MakeMaker
1206 };
1207
1208     push @m, q{
1209 Version_check :
1210         $(NOECHO) $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -
1211         "-MExtUtils::MakeMaker=Version_check" -e "&Version_check('$(MM_VERSION)')"
1212 };
1213
1214     join('',@m);
1215 }
1216
1217 =item dlsyms (override)
1218
1219 Create VMS linker options files specifying universal symbols for this
1220 extension's shareable image, and listing other shareable images or 
1221 libraries to which it should be linked.
1222
1223 =cut
1224
1225 sub dlsyms {
1226     my($self,%attribs) = @_;
1227
1228     return '' unless $self->needs_linking();
1229
1230     my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
1231     my($vars)  = $attribs{DL_VARS}  || $self->{DL_VARS}  || [];
1232     my($srcdir)= $attribs{PERL_SRC} || $self->{PERL_SRC} || '';
1233     my(@m);
1234
1235     unless ($self->{SKIPHASH}{'dynamic'}) {
1236         push(@m,'
1237 dynamic :: rtls.opt $(INST_ARCHAUTODIR)$(BASEEXT).opt
1238         $(NOECHO) $(NOOP)
1239 ');
1240         if ($srcdir) {
1241            my($popt) = $self->catfile($srcdir,'perlshr.opt');
1242            my($lopt) = $self->catfile($srcdir,'crtl.opt');
1243            push(@m,"# Depend on \$(BASEEXT).opt to insure we copy here *after* autogenerating (wrong) rtls.opt in Mksymlists
1244 rtls.opt : $popt $lopt \$(BASEEXT).opt
1245         Copy/Log $popt Sys\$Disk:[]rtls.opt
1246         Append/Log $lopt Sys\$Disk:[]rtls.opt
1247 ");
1248         }
1249         else {
1250             push(@m,'
1251 # rtls.opt is built in the same step as $(BASEEXT).opt
1252 rtls.opt : $(BASEEXT).opt
1253         $(TOUCH) $(MMS$TARGET)
1254 ');
1255         }
1256     }
1257
1258     push(@m,'
1259 static :: $(INST_ARCHAUTODIR)$(BASEEXT).opt
1260         $(NOECHO) $(NOOP)
1261 ') unless $self->{SKIPHASH}{'static'};
1262
1263     push(@m,'
1264 $(INST_ARCHAUTODIR)$(BASEEXT).opt : $(BASEEXT).opt
1265         $(CP) $(MMS$SOURCE) $(MMS$TARGET)
1266
1267 $(BASEEXT).opt : Makefile.PL
1268         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Mksymlists;" -
1269         ',qq[-e "Mksymlists('NAME' => '$self->{NAME}', 'DL_FUNCS' => ],
1270         neatvalue($funcs),q[, 'DL_VARS' => ],neatvalue($vars),')"
1271         $(PERL) -e "print ""$(INST_STATIC)/Include=$(BASEEXT)\n$(INST_STATIC)/Library\n"";" >>$(MMS$TARGET)
1272 ');
1273
1274     join('',@m);
1275 }
1276
1277 =item dynamic_lib (override)
1278
1279 Use VMS Link command.
1280
1281 =cut
1282
1283 sub dynamic_lib {
1284     my($self, %attribs) = @_;
1285     return '' unless $self->needs_linking(); #might be because of a subdir
1286
1287     return '' unless $self->has_link_code();
1288
1289     my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
1290     my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
1291     my(@m);
1292     push @m,"
1293
1294 OTHERLDFLAGS = $otherldflags
1295 INST_DYNAMIC_DEP = $inst_dynamic_dep
1296
1297 ";
1298     push @m, '
1299 $(INST_DYNAMIC) : $(INST_STATIC) $(PERL_INC)perlshr_attr.opt rtls.opt $(INST_ARCHAUTODIR).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
1300         $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR)
1301         $(NOECHO) If F$TrnLNm("PerlShr").eqs."" Then Define/NoLog/User PerlShr Sys$Share:PerlShr.Exe
1302         Link $(LDFLAGS) /Shareable=$(MMS$TARGET)$(OTHERLDFLAGS) $(BASEEXT).opt/Option,rtls.opt/Option,$(PERL_INC)perlshr_attr.opt/Option
1303 ';
1304
1305     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
1306     join('',@m);
1307 }
1308
1309 =item dynamic_bs (override)
1310
1311 Use VMS-style quoting on Mkbootstrap command line.
1312
1313 =cut
1314
1315 sub dynamic_bs {
1316     my($self, %attribs) = @_;
1317     return '
1318 BOOTSTRAP =
1319 ' unless $self->has_link_code();
1320     '
1321 BOOTSTRAP = '."$self->{BASEEXT}.bs".'
1322
1323 # As MakeMaker mkbootstrap might not write a file (if none is required)
1324 # we use touch to prevent make continually trying to remake it.
1325 # The DynaLoader only reads a non-empty file.
1326 $(BOOTSTRAP) : $(MAKEFILE) '."$self->{BOOTDEP}".' $(INST_ARCHAUTODIR).exists
1327         $(NOECHO) Write Sys$Output "Running mkbootstrap for $(NAME) ($(BSLOADLIBS))"
1328         $(NOECHO) $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -
1329         -e "use ExtUtils::Mkbootstrap; Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
1330         $(NOECHO) $(TOUCH) $(MMS$TARGET)
1331
1332 $(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR).exists
1333         $(NOECHO) $(RM_RF) $(INST_BOOT)
1334         - $(CP) $(BOOTSTRAP) $(INST_BOOT)
1335 ';
1336 }
1337
1338 =item static_lib (override)
1339
1340 Use VMS commands to manipulate object library.
1341
1342 =cut
1343
1344 sub static_lib {
1345     my($self) = @_;
1346     return '' unless $self->needs_linking();
1347
1348     return '
1349 $(INST_STATIC) :
1350         $(NOECHO) $(NOOP)
1351 ' unless ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB});
1352
1353     my(@m);
1354     push @m,'
1355 # Rely on suffix rule for update action
1356 $(OBJECT) : $(INST_ARCHAUTODIR).exists
1357
1358 $(INST_STATIC) : $(OBJECT) $(MYEXTLIB)
1359 ';
1360     # If this extension has it's own library (eg SDBM_File)
1361     # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
1362     push(@m, '  $(CP) $(MYEXTLIB) $(MMS$TARGET)',"\n") if $self->{MYEXTLIB};
1363
1364     push(@m,'
1365         If F$Search("$(MMS$TARGET)").eqs."" Then Library/Object/Create $(MMS$TARGET)
1366         Library/Object/Replace $(MMS$TARGET) $(MMS$SOURCE_LIST)
1367         $(NOECHO) $(PERL) -e "open F,\'>>$(INST_ARCHAUTODIR)extralibs.ld\';print F qq[$(EXTRALIBS)\n];close F;"
1368 ');
1369     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
1370     join('',@m);
1371 }
1372
1373
1374 # sub installpm_x { # called by installpm perl file
1375 #     my($self, $dist, $inst, $splitlib) = @_;
1376 #     if ($inst =~ m!#!) {
1377 #       warn "Warning: MM[SK] would have problems processing this file: $inst, SKIPPED\n";
1378 #       return '';
1379 #     }
1380 #     $inst = $self->fixpath($inst);
1381 #     $dist = $self->fixpath($dist);
1382 #     my($instdir) = $inst =~ /([^\)]+\))[^\)]*$/ ? $1 : dirname($inst);
1383 #     my(@m);
1384
1385 #     push(@m, "
1386 # $inst : $dist \$(MAKEFILE) ${instdir}.exists \$(INST_ARCHAUTODIR).exists
1387 # ",'   $(NOECHO) $(RM_F) $(MMS$TARGET)
1388 #       $(NOECHO) $(CP) ',"$dist $inst",'
1389 #       $(CHMOD) 644 $(MMS$TARGET)
1390 # ');
1391 #     push(@m, '        $(AUTOSPLITFILE) $(MMS$TARGET) ',
1392 #               $self->catdir($splitlib,'auto')."\n\n")
1393 #         if ($splitlib and $inst =~ /\.pm$/);
1394 #     push(@m,$self->dir_target($instdir));
1395
1396 #     join('',@m);
1397 # }
1398
1399 =item manifypods (override)
1400
1401 Use VMS-style quoting on command line, and VMS logical name
1402 to specify fallback location at build time if we can't find pod2man.
1403
1404 =cut
1405
1406
1407 sub manifypods {
1408     my($self, %attribs) = @_;
1409     return "\nmanifypods :\n\t\$(NOECHO) \$(NOOP)\n" unless %{$self->{MAN3PODS}} or %{$self->{MAN1PODS}};
1410     my($dist);
1411     my($pod2man_exe);
1412     if (defined $self->{PERL_SRC}) {
1413         $pod2man_exe = $self->catfile($self->{PERL_SRC},'pod','pod2man');
1414     } else {
1415         $pod2man_exe = $self->catfile($Config{scriptdirexp},'pod2man');
1416     }
1417     if ($pod2man_exe = $self->perl_script($pod2man_exe)) { $found_pod2man = 1; }
1418     else {
1419         # No pod2man but some MAN3PODS to be installed
1420         print <<END;
1421
1422 Warning: I could not locate your pod2man program.  As a last choice,
1423          I will look for the file to which the logical name POD2MAN
1424          points when MMK is invoked.
1425
1426 END
1427         $pod2man_exe = "pod2man";
1428     }
1429     my(@m);
1430     push @m,
1431 qq[POD2MAN_EXE = $pod2man_exe\n],
1432 q[POD2MAN = $(PERL) -we "%m=@ARGV;for (keys %m){" -
1433 -e "system(""MCR $^X $(POD2MAN_EXE) $_ >$m{$_}"");}"
1434 ];
1435     push @m, "\nmanifypods : ";
1436     push @m, join " ", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}};
1437     push(@m,"\n");
1438     if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) {
1439         my($pod);
1440         foreach $pod (sort keys %{$self->{MAN1PODS}}) {
1441             push @m, qq[\t\@- If F\$Search("\$(POD2MAN_EXE)").nes."" Then \$(POD2MAN) ];
1442             push @m, "$pod $self->{MAN1PODS}{$pod}\n";
1443         }
1444         foreach $pod (sort keys %{$self->{MAN3PODS}}) {
1445             push @m, qq[\t\@- If F\$Search("\$(POD2MAN_EXE)").nes."" Then \$(POD2MAN) ];
1446             push @m, "$pod $self->{MAN3PODS}{$pod}\n";
1447         }
1448     }
1449     join('', @m);
1450 }
1451
1452 =item processPL (override)
1453
1454 Use VMS-style quoting on command line.
1455
1456 =cut
1457
1458 sub processPL {
1459     my($self) = @_;
1460     return "" unless $self->{PL_FILES};
1461     my(@m, $plfile);
1462     foreach $plfile (sort keys %{$self->{PL_FILES}}) {
1463         push @m, "
1464 all :: $self->{PL_FILES}->{$plfile}
1465         \$(NOECHO) \$(NOOP)
1466
1467 $self->{PL_FILES}->{$plfile} :: $plfile
1468 ",'     $(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" '," $plfile
1469 ";
1470     }
1471     join "", @m;
1472 }
1473
1474 =item installbin (override)
1475
1476 Stay under DCL's 255 character command line limit once again by
1477 splitting potentially long list of files across multiple lines
1478 in C<realclean> target.
1479
1480 =cut
1481
1482 sub installbin {
1483     my($self) = @_;
1484     return '' unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
1485     return '' unless @{$self->{EXE_FILES}};
1486     my(@m, $from, $to, %fromto, @to, $line);
1487     for $from (@{$self->{EXE_FILES}}) {
1488         my($path) = '$(INST_SCRIPT)' . basename($from);
1489         local($_) = $path;  # backward compatibility
1490         $to = $self->libscan($path);
1491         print "libscan($from) => '$to'\n" if ($Verbose >=2);
1492         $fromto{$from}=$to;
1493     }
1494     @to   = values %fromto;
1495     push @m, "
1496 EXE_FILES = @{$self->{EXE_FILES}}
1497
1498 all :: @to
1499         \$(NOECHO) \$(NOOP)
1500
1501 realclean ::
1502 ";
1503     $line = '';  #avoid unitialized var warning
1504     foreach $to (@to) {
1505         if (length($line) + length($to) > 80) {
1506             push @m, "\t\$(RM_F) $line\n";
1507             $line = $to;
1508         }
1509         else { $line .= " $to"; }
1510     }
1511     push @m, "\t\$(RM_F) $line\n\n" if $line;
1512
1513     while (($from,$to) = each %fromto) {
1514         last unless defined $from;
1515         my $todir;
1516         if ($to =~ m#[/>:\]]#) { $todir = dirname($to); }
1517         else                   { ($todir = $to) =~ s/[^\)]+$//; }
1518         $todir = $self->fixpath($todir,1);
1519         push @m, "
1520 $to : $from \$(MAKEFILE) ${todir}.exists
1521         \$(CP) $from $to
1522
1523 ", $self->dir_target($todir);
1524     }
1525     join "", @m;
1526 }
1527
1528 =item subdir_x (override)
1529
1530 Use VMS commands to change default directory.
1531
1532 =cut
1533
1534 sub subdir_x {
1535     my($self, $subdir) = @_;
1536     my(@m,$key);
1537     $subdir = $self->fixpath($subdir,1);
1538     push @m, '
1539
1540 subdirs ::
1541         olddef = F$Environment("Default")
1542         Set Default ',$subdir,'
1543         - $(MMS) all $(USEMACROS)$(PASTHRU)$(MACROEND)
1544         Set Default \'olddef\'
1545 ';
1546     join('',@m);
1547 }
1548
1549 =item clean (override)
1550
1551 Split potentially long list of files across multiple commands (in
1552 order to stay under the magic command line limit).  Also use MM[SK]
1553 commands for handling subdirectories.
1554
1555 =cut
1556
1557 sub clean {
1558     my($self, %attribs) = @_;
1559     my(@m,$dir);
1560     push @m, '
1561 # Delete temporary files but do not touch installed files. We don\'t delete
1562 # the Descrip.MMS here so that a later make realclean still has it to use.
1563 clean ::
1564 ';
1565     foreach $dir (@{$self->{DIR}}) { # clean subdirectories first
1566         my($vmsdir) = $self->fixpath($dir,1);
1567         push( @m, '     If F$Search("'.$vmsdir.'$(MAKEFILE)") Then \\',"\n\t",
1568               '$(PERL) -e "chdir ',"'$vmsdir'",'; print `$(MMS) clean`;"',"\n");
1569     }
1570     push @m, '  $(RM_F) *.Map *.Dmp *.Lis *.cpp *.$(DLEXT) *$(OBJ_EXT) *$(LIB_EXT) *.Opt $(BOOTSTRAP) $(BASEEXT).bso .MM_Tmp
1571 ';
1572
1573     my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
1574     push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
1575     push(@otherfiles, qw[ blib $(MAKE_APERL_FILE) extralibs.ld perlmain.c pm_to_blib.ts ]);
1576     push(@otherfiles,$self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'));
1577     my($file,$line);
1578     $line = '';  #avoid unitialized var warning
1579     foreach $file (@otherfiles) {
1580         $file = $self->fixpath($file);
1581         if (length($line) + length($file) > 80) {
1582             push @m, "\t\$(RM_RF) $line\n";
1583             $line = "$file";
1584         }
1585         else { $line .= " $file"; }
1586     }
1587     push @m, "\t\$(RM_RF) $line\n" if $line;
1588     push(@m, "  $attribs{POSTOP}\n") if $attribs{POSTOP};
1589     join('', @m);
1590 }
1591
1592 =item realclean (override)
1593
1594 Guess what we're working around?  Also, use MM[SK] for subdirectories.
1595
1596 =cut
1597
1598 sub realclean {
1599     my($self, %attribs) = @_;
1600     my(@m);
1601     push(@m,'
1602 # Delete temporary files (via clean) and also delete installed files
1603 realclean :: clean
1604 ');
1605     foreach(@{$self->{DIR}}){
1606         my($vmsdir) = $self->fixpath($_,1);
1607         push(@m, '      If F$Search("'."$vmsdir".'$(MAKEFILE)").nes."" Then \\',"\n\t",
1608               '$(PERL) -e "chdir ',"'$vmsdir'",'; print `$(MMS) realclean`;"',"\n");
1609     }
1610     push @m,'   $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR)
1611 ';
1612     # We can't expand several of the MMS macros here, since they don't have
1613     # corresponding %$self keys (i.e. they're defined in Descrip.MMS as a
1614     # combination of macros).  In order to stay below DCL's 255 char limit,
1615     # we put only 2 on a line.
1616     my($file,$line,$fcnt);
1617     my(@files) = qw{ $(MAKEFILE) $(MAKEFILE)_old };
1618     if ($self->has_link_code) {
1619         push(@files,qw{ $(INST_DYNAMIC) $(INST_STATIC) $(INST_BOOT) $(OBJECT) });
1620     }
1621     push(@files, values %{$self->{PM}});
1622     $line = '';  #avoid unitialized var warning
1623     foreach $file (@files) {
1624         $file = $self->fixpath($file);
1625         if (length($line) + length($file) > 80 || ++$fcnt >= 2) {
1626             push @m, "\t\$(RM_F) $line\n";
1627             $line = "$file";
1628             $fcnt = 0;
1629         }
1630         else { $line .= " $file"; }
1631     }
1632     push @m, "\t\$(RM_F) $line\n" if $line;
1633     if ($attribs{FILES} && ref $attribs{FILES} eq 'ARRAY') {
1634         $line = '';
1635         foreach $file (@{$attribs{'FILES'}}) {
1636             $file = $self->fixpath($file);
1637             if (length($line) + length($file) > 80) {
1638                 push @m, "\t\$(RM_RF) $line\n";
1639                 $line = "$file";
1640             }
1641             else { $line .= " $file"; }
1642         }
1643         push @m, "\t\$(RM_RF) $line\n" if $line;
1644     }
1645     push(@m, "  $attribs{POSTOP}\n")                     if $attribs{POSTOP};
1646     join('', @m);
1647 }
1648
1649 =item dist_basics (override)
1650
1651 Use VMS-style quoting on command line.
1652
1653 =cut
1654
1655 sub dist_basics {
1656     my($self) = @_;
1657 '
1658 distclean :: realclean distcheck
1659         $(NOECHO) $(NOOP)
1660
1661 distcheck :
1662         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest \'&fullcheck\'; fullcheck()"
1663
1664 skipcheck :
1665         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest \'&fullcheck\'; skipcheck()"
1666
1667 manifest :
1668         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest \'&mkmanifest\'; mkmanifest()"
1669 ';
1670 }
1671
1672 =item dist_core (override)
1673
1674 Syntax for invoking F<VMS_Share> differs from that for Unix F<shar>,
1675 so C<shdist> target actions are VMS-specific.
1676
1677 =cut
1678
1679 sub dist_core {
1680     my($self) = @_;
1681 q[
1682 dist : $(DIST_DEFAULT)
1683         $(NOECHO) $(PERL) -le "print 'Warning: $m older than $vf' if -e ($vf = '$(VERSION_FROM)') && -M $vf < -M ($m = '$(MAKEFILE)'"
1684
1685 zipdist : $(DISTVNAME).zip
1686         $(NOECHO) $(NOOP)
1687
1688 $(DISTVNAME).zip : distdir
1689         $(PREOP)
1690         $(ZIP) "$(ZIPFLAGS)" $(MMS$TARGET) $(SRC)
1691         $(RM_RF) $(DISTVNAME)
1692         $(POSTOP)
1693
1694 $(DISTVNAME).tar$(SUFFIX) : distdir
1695         $(PREOP)
1696         $(TO_UNIX)
1697         $(TAR) "$(TARFLAGS)" $(DISTVNAME).tar $(SRC)
1698         $(RM_RF) $(DISTVNAME)
1699         $(COMPRESS) $(DISTVNAME).tar
1700         $(POSTOP)
1701
1702 shdist : distdir
1703         $(PREOP)
1704         $(SHARE) $(SRC) $(DISTVNAME).share
1705         $(RM_RF) $(DISTVNAME)
1706         $(POSTOP)
1707 ];
1708 }
1709
1710 =item dist_dir (override)
1711
1712 Use VMS-style quoting on command line.
1713
1714 =cut
1715
1716 sub dist_dir {
1717     my($self) = @_;
1718 q{
1719 distdir :
1720         $(RM_RF) $(DISTVNAME)
1721         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest '/mani/';" \\
1722         -e "manicopy(maniread(),'$(DISTVNAME)','$(DIST_CP)');"
1723 };
1724 }
1725
1726 =item dist_test (override)
1727
1728 Use VMS commands to change default directory, and use VMS-style
1729 quoting on command line.
1730
1731 =cut
1732
1733 sub dist_test {
1734     my($self) = @_;
1735 q{
1736 disttest : distdir
1737         startdir = F$Environment("Default")
1738         Set Default [.$(DISTVNAME)]
1739         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL
1740         $(MMS)
1741         $(MMS) test
1742         Set Default 'startdir'
1743 };
1744 }
1745
1746 # --- Test and Installation Sections ---
1747
1748 =item install (override)
1749
1750 Work around DCL's 255 character limit several times,and use
1751 VMS-style command line quoting in a few cases.
1752
1753 =cut
1754
1755 sub install {
1756     my($self, %attribs) = @_;
1757     my(@m,@docfiles);
1758
1759     if ($self->{EXE_FILES}) {
1760         my($line,$file) = ('','');
1761         foreach $file (@{$self->{EXE_FILES}}) {
1762             $line .= "$file ";
1763             if (length($line) > 128) {
1764                 push(@docfiles,qq[\t\$(PERL) -e "print $line" >>.MM_tmp\n]);
1765                 $line = '';
1766             }
1767         }
1768         push(@docfiles,qq[\t\$(PERL) -e "print $line" >>.MM_tmp\n]) if $line;
1769     }
1770
1771     push @m, q[
1772 install :: all pure_install doc_install
1773         $(NOECHO) $(NOOP)
1774
1775 install_perl :: all pure_perl_install doc_perl_install
1776         $(NOECHO) $(NOOP)
1777
1778 install_site :: all pure_site_install doc_site_install
1779         $(NOECHO) $(NOOP)
1780
1781 install_ :: install_site
1782         $(NOECHO) Write Sys$Output "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site"
1783
1784 pure_install :: pure_$(INSTALLDIRS)_install
1785         $(NOECHO) $(NOOP)
1786
1787 doc_install :: doc_$(INSTALLDIRS)_install
1788         $(NOECHO) Write Sys$Output "Appending installation info to $(INSTALLARCHLIB)perllocal.pod"
1789
1790 pure__install : pure_site_install
1791         $(NOECHO) Write Sys$Output "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site"
1792
1793 doc__install : doc_site_install
1794         $(NOECHO} Write Sys$Output "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site"
1795
1796 # This hack brought to you by DCL's 255-character command line limit
1797 pure_perl_install ::
1798         $(NOECHO) $(PERL) -e "print 'read ].$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q[ '" >.MM_tmp
1799         $(NOECHO) $(PERL) -e "print 'write ].$self->catfile('$(INSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q[ '" >>.MM_tmp
1800         $(NOECHO) $(PERL) -e "print '$(INST_LIB) $(INSTALLPRIVLIB) '" >>.MM_tmp
1801         $(NOECHO) $(PERL) -e "print '$(INST_ARCHLIB) $(INSTALLARCHLIB) '" >>.MM_tmp
1802         $(NOECHO) $(PERL) -e "print '$(INST_BIN) $(INSTALLBIN) '" >>.MM_tmp
1803         $(NOECHO) $(PERL) -e "print '$(INST_SCRIPT) $(INSTALLSCRIPT) '" >>.MM_tmp
1804         $(NOECHO) $(PERL) -e "print '$(INST_MAN1DIR) $(INSTALLMAN1DIR) '" >>.MM_tmp
1805         $(NOECHO) $(PERL) -e "print '$(INST_MAN3DIR) $(INSTALLMAN3DIR) '" >>.MM_tmp
1806         $(MOD_INSTALL) <.MM_tmp
1807         $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;
1808         $(NOECHO) $(WARN_IF_OLD_PACKLIST) ].$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q[
1809
1810 # Likewise
1811 pure_site_install ::
1812         $(NOECHO) $(PERL) -e "print 'read ].$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q[ '" >.MM_tmp
1813         $(NOECHO) $(PERL) -e "print 'write ].$self->catfile('$(INSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q[ '" >>.MM_tmp
1814         $(NOECHO) $(PERL) -e "print '$(INST_LIB) $(INSTALLSITELIB) '" >>.MM_tmp
1815         $(NOECHO) $(PERL) -e "print '$(INST_ARCHLIB) $(INSTALLSITEARCH) '" >>.MM_tmp
1816         $(NOECHO) $(PERL) -e "print '$(INST_BIN) $(INSTALLBIN) '" >>.MM_tmp
1817         $(NOECHO) $(PERL) -e "print '$(INST_SCRIPT) $(INSTALLSCRIPT) '" >>.MM_tmp
1818         $(NOECHO) $(PERL) -e "print '$(INST_MAN1DIR) $(INSTALLMAN1DIR) '" >>.MM_tmp
1819         $(NOECHO) $(PERL) -e "print '$(INST_MAN3DIR) $(INSTALLMAN3DIR) '" >>.MM_tmp
1820         $(MOD_INSTALL) <.MM_tmp
1821         $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;
1822         $(NOECHO) $(WARN_IF_OLD_PACKLIST) ].$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q[
1823
1824 # Ditto
1825 doc_perl_install ::
1826         $(NOECHO) $(PERL) -e "print 'Module $(NAME)|installed into|$(INSTALLPRIVLIB)|'" >.MM_tmp
1827         $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|'" >>.MM_tmp
1828         $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|'" >>.MM_tmp
1829 ],@docfiles,
1830 q%      $(NOECHO) $(PERL) -e "print q[@ARGV=split(/\\|/,<STDIN>);]" >.MM2_tmp
1831         $(NOECHO) $(PERL) -e "print q[print '=head3 ',scalar(localtime),': C<',shift,qq[>\\n\\n=over 4\\n\\n];]" >>.MM2_tmp
1832         $(NOECHO) $(PERL) -e "print q[while(($key=shift) && ($val=shift)) ]" >>.MM2_tmp
1833         $(NOECHO) $(PERL) -e "print q[{print qq[=item *\\n\\nC<$key: $val>\\n\\n];}print qq[=back\\n\\n];]" >>.MM2_tmp
1834         $(NOECHO) $(PERL) .MM2_tmp <.MM_tmp >>%.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q[
1835         $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;,.MM2_tmp;
1836
1837 # And again
1838 doc_site_install ::
1839         $(NOECHO) $(PERL) -e "print 'Module $(NAME)|installed into|$(INSTALLSITELIB)|'" >.MM_tmp
1840         $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|'" >>.MM_tmp
1841         $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|'" >>.MM_tmp
1842 ],@docfiles,
1843 q%      $(NOECHO) $(PERL) -e "print q[@ARGV=split(/\\|/,<STDIN>);]" >.MM2_tmp
1844         $(NOECHO) $(PERL) -e "print q[print '=head3 ',scalar(localtime),': C<',shift,qq[>\\n\\n=over 4\\n\\n];]" >>.MM2_tmp
1845         $(NOECHO) $(PERL) -e "print q[while(($key=shift) && ($val=shift)) ]" >>.MM2_tmp
1846         $(NOECHO) $(PERL) -e "print q[{print qq[=item *\\n\\nC<$key: $val>\\n\\n];}print qq[=back\\n\\n];]" >>.MM2_tmp
1847         $(NOECHO) $(PERL) .MM2_tmp <.MM_tmp >>%.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q[
1848         $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;,.MM2_tmp;
1849
1850 ];
1851
1852     push @m, q[
1853 uninstall :: uninstall_from_$(INSTALLDIRS)dirs
1854         $(NOECHO) $(NOOP)
1855
1856 uninstall_from_perldirs ::
1857         $(NOECHO) $(UNINSTALL) ].$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q[
1858
1859 uninstall_from_sitedirs ::
1860         $(NOECHO) $(UNINSTALL) ].$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist')."\n";
1861
1862     join('',@m);
1863 }
1864
1865 =item perldepend (override)
1866
1867 Use VMS-style syntax for files; it's cheaper to just do it directly here
1868 than to have the MM_Unix method call C<catfile> repeatedly.  Also use
1869 config.vms as source of original config data if the Perl distribution
1870 is available; config.sh is an ancillary file under VMS.  Finally, if
1871 we have to rebuild Config.pm, use MM[SK] to do it.
1872
1873 =cut
1874
1875 sub perldepend {
1876     my($self) = @_;
1877     my(@m);
1878
1879     push @m, '
1880 $(OBJECT) : $(PERL_INC)EXTERN.h, $(PERL_INC)INTERN.h, $(PERL_INC)XSUB.h, $(PERL_INC)av.h
1881 $(OBJECT) : $(PERL_INC)cop.h, $(PERL_INC)cv.h, $(PERL_INC)embed.h, $(PERL_INC)form.h
1882 $(OBJECT) : $(PERL_INC)gv.h, $(PERL_INC)handy.h, $(PERL_INC)hv.h, $(PERL_INC)keywords.h
1883 $(OBJECT) : $(PERL_INC)mg.h, $(PERL_INC)op.h, $(PERL_INC)opcode.h, $(PERL_INC)patchlevel.h
1884 $(OBJECT) : $(PERL_INC)perl.h, $(PERL_INC)perly.h, $(PERL_INC)pp.h, $(PERL_INC)proto.h
1885 $(OBJECT) : $(PERL_INC)regcomp.h, $(PERL_INC)regexp.h, $(PERL_INC)scope.h, $(PERL_INC)sv.h
1886 $(OBJECT) : $(PERL_INC)vmsish.h, $(PERL_INC)util.h, $(PERL_INC)config.h
1887
1888 ' if $self->{OBJECT}; 
1889
1890     if ($self->{PERL_SRC}) {
1891         my(@macros);
1892         my($mmsquals) = '$(USEMAKEFILE)[.vms]$(MAKEFILE)';
1893         push(@macros,'__AXP__=1') if $Config{'arch'} eq 'VMS_AXP';
1894         push(@macros,'DECC=1')    if $Config{'vms_cc_type'} eq 'decc';
1895         push(@macros,'GNUC=1')    if $Config{'vms_cc_type'} eq 'gcc';
1896         push(@macros,'SOCKET=1')  if $Config{'d_has_sockets'};
1897         push(@macros,qq["CC=$Config{'cc'}"])  if $Config{'cc'} =~ m!/!;
1898         $mmsquals .= '$(USEMACROS)' . join(',',@macros) . '$(MACROEND)' if @macros;
1899         push(@m,q[
1900 # Check for unpropagated config.sh changes. Should never happen.
1901 # We do NOT just update config.h because that is not sufficient.
1902 # An out of date config.h is not fatal but complains loudly!
1903 #$(PERL_INC)config.h : $(PERL_SRC)config.sh
1904 $(PERL_INC)config.h : $(PERL_VMS)config.vms
1905         $(NOECHO) Write Sys$Error "Warning: $(PERL_INC)config.h out of date with $(PERL_VMS)config.vms"
1906
1907 #$(PERL_ARCHLIB)Config.pm : $(PERL_SRC)config.sh
1908 $(PERL_ARCHLIB)Config.pm : $(PERL_VMS)config.vms $(PERL_VMS)genconfig.pl
1909         $(NOECHO) Write Sys$Error "$(PERL_ARCHLIB)Config.pm may be out of date with config.vms or genconfig.pl"
1910         olddef = F$Environment("Default")
1911         Set Default $(PERL_SRC)
1912         $(MMS)],$mmsquals,q[ $(MMS$TARGET)
1913         Set Default 'olddef'
1914 ]);
1915     }
1916
1917     push(@m, join(" ", map($self->fixpath($_),values %{$self->{XS}}))." : \$(XSUBPPDEPS)\n")
1918       if %{$self->{XS}};
1919
1920     join('',@m);
1921 }
1922
1923 =item makefile (override)
1924
1925 Use VMS commands and quoting.
1926
1927 =cut
1928
1929 sub makefile {
1930     my($self) = @_;
1931     my(@m,@cmd);
1932     # We do not know what target was originally specified so we
1933     # must force a manual rerun to be sure. But as it should only
1934     # happen very rarely it is not a significant problem.
1935     push @m, q[
1936 $(OBJECT) : $(FIRST_MAKEFILE)
1937 ] if $self->{OBJECT};
1938
1939     push @m,q[
1940 # We take a very conservative approach here, but it\'s worth it.
1941 # We move $(MAKEFILE) to $(MAKEFILE)_old here to avoid gnu make looping.
1942 $(MAKEFILE) : Makefile.PL $(CONFIGDEP)
1943         $(NOECHO) Write Sys$Output "$(MAKEFILE) out-of-date with respect to $(MMS$SOURCE_LIST)"
1944         $(NOECHO) Write Sys$Output "Cleaning current config before rebuilding $(MAKEFILE) ..."
1945         - $(MV) $(MAKEFILE) $(MAKEFILE)_old
1946         - $(MMS) $(USEMAKEFILE)$(MAKEFILE)_old clean
1947         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL ],join(' ',map(qq["$_"],@ARGV)),q[
1948         $(NOECHO) Write Sys$Output "$(MAKEFILE) has been rebuilt."
1949         $(NOECHO) Write Sys$Output "Please run $(MMS) to build the extension."
1950 ];
1951
1952     join('',@m);
1953 }
1954
1955 =item test (override)
1956
1957 Use VMS commands for handling subdirectories.
1958
1959 =cut
1960
1961 sub test {
1962     my($self, %attribs) = @_;
1963     my($tests) = $attribs{TESTS} || ( -d 't' ? 't/*.t' : '');
1964     my(@m);
1965     push @m,"
1966 TEST_VERBOSE = 0
1967 TEST_TYPE = test_\$(LINKTYPE)
1968 TEST_FILE = test.pl
1969 TESTDB_SW = -d
1970
1971 test :: \$(TEST_TYPE)
1972         \$(NOECHO) \$(NOOP)
1973
1974 testdb :: testdb_\$(LINKTYPE)
1975         \$(NOECHO) \$(NOOP)
1976
1977 ";
1978     foreach(@{$self->{DIR}}){
1979       my($vmsdir) = $self->fixpath($_,1);
1980       push(@m, '        If F$Search("',$vmsdir,'$(MAKEFILE)").nes."" Then $(PERL) -e "chdir ',"'$vmsdir'",
1981            '; print `$(MMS) $(PASTHRU2) test`'."\n");
1982     }
1983     push(@m, "\t\$(NOECHO) Write Sys\$Output \"No tests defined for \$(NAME) extension.\"\n")
1984         unless $tests or -f "test.pl" or @{$self->{DIR}};
1985     push(@m, "\n");
1986
1987     push(@m, "test_dynamic :: pure_all\n");
1988     push(@m, $self->test_via_harness('$(FULLPERL)', $tests)) if $tests;
1989     push(@m, $self->test_via_script('$(FULLPERL)', 'test.pl')) if -f "test.pl";
1990     push(@m, "\t\$(NOECHO) \$(NOOP)\n") if (!$tests && ! -f "test.pl");
1991     push(@m, "\n");
1992
1993     push(@m, "testdb_dynamic :: pure_all\n");
1994     push(@m, $self->test_via_script('$(FULLPERL) "$(TESTDB_SW)"', '$(TEST_FILE)'));
1995     push(@m, "\n");
1996
1997     # Occasionally we may face this degenerate target:
1998     push @m, "test_ : test_dynamic\n\n";
1999  
2000     if ($self->needs_linking()) {
2001         push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
2002         push(@m, $self->test_via_harness('$(MAP_TARGET)', $tests)) if $tests;
2003         push(@m, $self->test_via_script('$(MAP_TARGET)', 'test.pl')) if -f 'test.pl';
2004         push(@m, "\n");
2005         push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
2006         push(@m, $self->test_via_script('$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
2007         push(@m, "\n");
2008     }
2009     else {
2010         push @m, "test_static :: test_dynamic\n\t\$(NOECHO) \$(NOOP)\n\n";
2011         push @m, "testdb_static :: testdb_dynamic\n\t\$(NOECHO) \$(NOOP)\n";
2012     }
2013
2014     join('',@m);
2015 }
2016
2017 =item test_via_harness (override)
2018
2019 Use VMS-style quoting on command line.
2020
2021 =cut
2022
2023 sub test_via_harness {
2024     my($self,$perl,$tests) = @_;
2025     "   $perl".' "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)" \\'."\n\t".
2026     '-e "use Test::Harness qw(&runtests $verbose); $verbose=$(TEST_VERBOSE); runtests @ARGV;" \\'."\n\t$tests\n";
2027 }
2028
2029 =item test_via_script (override)
2030
2031 Use VMS-style quoting on command line.
2032
2033 =cut
2034
2035 sub test_via_script {
2036     my($self,$perl,$script) = @_;
2037     "   $perl".' "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" '.$script.'
2038 ';
2039 }
2040
2041 =item makeaperl (override)
2042
2043 Undertake to build a new set of Perl images using VMS commands.  Since
2044 VMS does dynamic loading, it's not necessary to statically link each
2045 extension into the Perl image, so this isn't the normal build path.
2046 Consequently, it hasn't really been tested, and may well be incomplete.
2047
2048 =cut
2049
2050 sub makeaperl {
2051     my($self, %attribs) = @_;
2052     my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) = 
2053       @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2054     my(@m);
2055     push @m, "
2056 # --- MakeMaker makeaperl section ---
2057 MAP_TARGET    = $target
2058 ";
2059     return join '', @m if $self->{PARENT};
2060
2061     my($dir) = join ":", @{$self->{DIR}};
2062
2063     unless ($self->{MAKEAPERL}) {
2064         push @m, q{
2065 $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
2066         $(NOECHO) Write Sys$Output "Writing ""$(MMS$TARGET)"" for this $(MAP_TARGET)"
2067         $(NOECHO) $(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
2068                 Makefile.PL DIR=}, $dir, q{ \
2069                 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2070                 MAKEAPERL=1 NORECURS=1
2071
2072 $(MAP_TARGET) :: $(MAKE_APERL_FILE)
2073         $(MMS)$(USEMAKEFILE)$(MAKE_APERL_FILE) static $(MMS$TARGET)
2074 };
2075         push @m, map( " \\\n\t\t$_", @ARGV );
2076         push @m, "\n";
2077
2078         return join '', @m;
2079     }
2080
2081
2082     my($linkcmd,@staticopts,@staticpkgs,$extralist,$targdir,$libperldir);
2083
2084     # The front matter of the linkcommand...
2085     $linkcmd = join ' ', $Config{'ld'},
2086             grep($_, @Config{qw(large split ldflags ccdlflags)});
2087     $linkcmd =~ s/\s+/ /g;
2088
2089     # Which *.olb files could we make use of...
2090     local(%olbs);
2091     $olbs{$self->{INST_ARCHAUTODIR}} = "$self->{BASEEXT}\$(LIB_EXT)";
2092     require File::Find;
2093     File::Find::find(sub {
2094         return unless m/\Q$self->{LIB_EXT}\E$/;
2095         return if m/^libperl/;
2096
2097         if( exists $self->{INCLUDE_EXT} ){
2098                 my $found = 0;
2099                 my $incl;
2100                 my $xx;
2101
2102                 ($xx = $File::Find::name) =~ s,.*?/auto/,,;
2103                 $xx =~ s,/?$_,,;
2104                 $xx =~ s,/,::,g;
2105
2106                 # Throw away anything not explicitly marked for inclusion.
2107                 # DynaLoader is implied.
2108                 foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
2109                         if( $xx eq $incl ){
2110                                 $found++;
2111                                 last;
2112                         }
2113                 }
2114                 return unless $found;
2115         }
2116         elsif( exists $self->{EXCLUDE_EXT} ){
2117                 my $excl;
2118                 my $xx;
2119
2120                 ($xx = $File::Find::name) =~ s,.*?/auto/,,;
2121                 $xx =~ s,/?$_,,;
2122                 $xx =~ s,/,::,g;
2123
2124                 # Throw away anything explicitly marked for exclusion
2125                 foreach $excl (@{$self->{EXCLUDE_EXT}}){
2126                         return if( $xx eq $excl );
2127                 }
2128         }
2129
2130         $olbs{$ENV{DEFAULT}} = $_;
2131     }, grep( -d $_, @{$searchdirs || []}));
2132
2133     # We trust that what has been handed in as argument will be buildable
2134     $static = [] unless $static;
2135     @olbs{@{$static}} = (1) x @{$static};
2136  
2137     $extra = [] unless $extra && ref $extra eq 'ARRAY';
2138     # Sort the object libraries in inverse order of
2139     # filespec length to try to insure that dependent extensions
2140     # will appear before their parents, so the linker will
2141     # search the parent library to resolve references.
2142     # (e.g. Intuit::DWIM will precede Intuit, so unresolved
2143     # references from [.intuit.dwim]dwim.obj can be found
2144     # in [.intuit]intuit.olb).
2145     for (sort keys %olbs) {
2146         next unless $olbs{$_} =~ /\Q$self->{LIB_EXT}\E$/;
2147         my($dir) = $self->fixpath($_,1);
2148         my($extralibs) = $dir . "extralibs.ld";
2149         my($extopt) = $dir . $olbs{$_};
2150         $extopt =~ s/$self->{LIB_EXT}$/.opt/;
2151         if (-f $extralibs ) {
2152             open LIST,$extralibs or warn $!,next;
2153             push @$extra, <LIST>;
2154             close LIST;
2155         }
2156         if (-f $extopt) {
2157             open OPT,$extopt or die $!;
2158             while (<OPT>) {
2159                 next unless /(?:UNIVERSAL|VECTOR)=boot_([\w_]+)/;
2160                 # ExtUtils::Miniperl expects Unix paths
2161                 (my($pkg) = "$1_$1$self->{LIB_EXT}") =~ s#_*#/#g;
2162                 push @staticpkgs,$pkg;
2163             }
2164             push @staticopts, $extopt;
2165         }
2166     }
2167
2168     $target = "Perl.Exe" unless $target;
2169     ($shrtarget,$targdir) = fileparse($target);
2170     $shrtarget =~ s/^([^.]*)/$1Shr/;
2171     $shrtarget = $targdir . $shrtarget;
2172     $target = "Perlshr.$Config{'dlext'}" unless $target;
2173     $tmp = "[]" unless $tmp;
2174     $tmp = $self->fixpath($tmp,1);
2175     if (@$extra) {
2176         $extralist = join(' ',@$extra);
2177         $extralist =~ s/[,\s\n]+/, /g;
2178     }
2179     else { $extralist = ''; }
2180     if ($libperl) {
2181         unless (-f $libperl || -f ($libperl = $self->catfile($Config{'installarchlib'},'CORE',$libperl))) {
2182             print STDOUT "Warning: $libperl not found\n";
2183             undef $libperl;
2184         }
2185     }
2186     unless ($libperl) {
2187         if (defined $self->{PERL_SRC}) {
2188             $libperl = $self->catfile($self->{PERL_SRC},"libperl$self->{LIB_EXT}");
2189         } elsif (-f ($libperl = $self->catfile($Config{'installarchlib'},'CORE',"libperl$self->{LIB_EXT}")) ) {
2190         } else {
2191             print STDOUT "Warning: $libperl not found
2192     If you're going to build a static perl binary, make sure perl is installed
2193     otherwise ignore this warning\n";
2194         }
2195     }
2196     $libperldir = $self->fixpath((fileparse($libperl))[1],1);
2197
2198     push @m, '
2199 # Fill in the target you want to produce if it\'s not perl
2200 MAP_TARGET    = ',$self->fixpath($target),'
2201 MAP_SHRTARGET = ',$self->fixpath($shrtarget),"
2202 MAP_LINKCMD   = $linkcmd
2203 MAP_PERLINC   = ", $perlinc ? map('"$_" ',@{$perlinc}) : '','
2204 # We use the linker options files created with each extension, rather than
2205 #specifying the object files directly on the command line.
2206 MAP_STATIC    = ',@staticopts ? join(' ', @staticopts) : '','
2207 MAP_OPTS    = ',@staticopts ? ','.join(',', map($_.'/Option', @staticopts)) : '',"
2208 MAP_EXTRA     = $extralist
2209 MAP_LIBPERL = ",$self->fixpath($libperl),'
2210 ';
2211
2212
2213     push @m,'
2214 $(MAP_SHRTARGET) : $(MAP_LIBPERL) $(MAP_STATIC) ',"${libperldir}Perlshr_Attr.Opt",'
2215         $(MAP_LINKCMD)/Shareable=$(MMS$TARGET) $(MAP_OPTS), $(MAP_EXTRA), $(MAP_LIBPERL) ',"${libperldir}Perlshr_Attr.Opt",'
2216 $(MAP_TARGET) : $(MAP_SHRTARGET) ',"${tmp}perlmain\$(OBJ_EXT) ${tmp}PerlShr.Opt",'
2217         $(MAP_LINKCMD) ',"${tmp}perlmain\$(OBJ_EXT)",', PerlShr.Opt/Option
2218         $(NOECHO) Write Sys$Output "To install the new ""$(MAP_TARGET)"" binary, say"
2219         $(NOECHO) Write Sys$Output "    $(MMS)$(USEMAKEFILE)$(MAKEFILE) inst_perl $(USEMACROS)MAP_TARGET=$(MAP_TARGET)$(ENDMACRO)"
2220         $(NOECHO) Write Sys$Output "To remove the intermediate files, say
2221         $(NOECHO) Write Sys$Output "    $(MMS)$(USEMAKEFILE)$(MAKEFILE) map_clean"
2222 ';
2223     push @m,'
2224 ',"${tmp}perlmain.c",' : $(MAKEFILE)
2225         $(NOECHO) $(PERL) $(MAP_PERLINC) -e "use ExtUtils::Miniperl; writemain(qw|',@staticpkgs,'|)" >$(MMS$TARGET)
2226 ';
2227
2228     push @m, q[
2229 # More from the 255-char line length limit
2230 doc_inst_perl :
2231         $(NOECHO) $(PERL) -e "print 'Perl binary $(MAP_TARGET)|'" >.MM_tmp
2232         $(NOECHO) $(PERL) -e "print 'MAP_STATIC|$(MAP_STATIC)|'" >>.MM_tmp
2233         $(NOECHO) $(PERL) -pl040 -e " " ].$self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'),q[ >>.MM_tmp
2234         $(NOECHO) $(PERL) -e "print 'MAP_LIBPERL|$(MAP_LIBPERL)|'" >>.MM_tmp
2235         $(DOC_INSTALL) <.MM_tmp >>].$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q[
2236         $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;
2237 ];
2238
2239     push @m, "
2240 inst_perl : pure_inst_perl doc_inst_perl
2241         \$(NOECHO) \$(NOOP)
2242
2243 pure_inst_perl : \$(MAP_TARGET)
2244         $self->{CP} \$(MAP_SHRTARGET) ",$self->fixpath($Config{'installbin'},1),"
2245         $self->{CP} \$(MAP_TARGET) ",$self->fixpath($Config{'installbin'},1),"
2246
2247 clean :: map_clean
2248         \$(NOECHO) \$(NOOP)
2249
2250 map_clean :
2251         \$(RM_F) ${tmp}perlmain\$(OBJ_EXT) ${tmp}perlmain.c \$(MAKEFILE)
2252         \$(RM_F) ${tmp}PerlShr.Opt \$(MAP_TARGET)
2253 ";
2254
2255     join '', @m;
2256 }
2257   
2258 =item ext (specific)
2259
2260 Stub routine standing in for C<ExtUtils::LibList::ext> until VMS
2261 support is added to that package.
2262
2263 =cut
2264
2265 sub ext {
2266     my($self) = @_;
2267     '','','';
2268 }
2269
2270 # --- Output postprocessing section ---
2271
2272 =item nicetext (override)
2273
2274 Insure that colons marking targets are preceded by space, in order
2275 to distinguish the target delimiter from a colon appearing as
2276 part of a filespec.
2277
2278 =cut
2279
2280 sub nicetext {
2281
2282     my($self,$text) = @_;
2283     $text =~ s/([^\s:])(:+\s)/$1 $2/gs;
2284     $text;
2285 }
2286
2287 1;
2288
2289 __END__
2290