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