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