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