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