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