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