perl 5.002
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_VMS.pm
1 #   MM_VMS.pm
2 #   MakeMaker default methods for VMS
3 #   This package is inserted into @ISA of MakeMaker's MM before the
4 #   built-in ExtUtils::MM_Unix methods if MakeMaker.pm is run under VMS.
5 #
6 #   Author:  Charles Bailey  bailey@genetics.upenn.edu
7
8 package ExtUtils::MM_VMS;
9 $ExtUtils::MM_VMS::Revision=$ExtUtils::MM_VMS::Revision = '5.21 (15-Feb-1996)';
10 unshift @MM::ISA, 'ExtUtils::MM_VMS';
11
12 use Config;
13 require Exporter;
14 use VMS::Filespec;
15 use File::Basename;
16
17 Exporter::import('ExtUtils::MakeMaker', '$Verbose', '&neatvalue');
18
19
20 sub eliminate_macros {
21     my($self,$path) = @_;
22     unless (ref $self){
23         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
24         $self = $ExtUtils::MakeMaker::Parent[-1];
25     }
26     unless ($path) {
27         print "eliminate_macros('') = ||\n" if $Verbose >= 3;
28         return '';
29     }
30     my($npath) = unixify($path);
31     my($head,$macro,$tail);
32
33     # perform m##g in scalar context so it acts as an iterator
34     while ($npath =~ m#(.*?)\$\((\S+?)\)(.*)#g) { 
35         if ($self->{$2}) {
36             ($head,$macro,$tail) = ($1,$2,$3);
37             ($macro = unixify($self->{$macro})) =~ s#/$##;
38             $npath = "$head$macro$tail";
39         }
40     }
41     print "eliminate_macros($path) = |$npath|\n" if $Verbose >= 3;
42     $npath;
43 }
44
45 # Catchall routine to clean up problem macros.  Expands macros in any directory
46 # specification, and expands expressions which are all macro, so that we can
47 # tell how long the expansion is, and avoid overrunning DCL's command buffer
48 # when MM[KS] is running.
49 sub fixpath {
50     my($self,$path,$force_path) = @_;
51     unless (ref $self){
52         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
53         $self = $ExtUtils::MakeMaker::Parent[-1];
54     }
55     unless ($path) {
56         print "eliminate_macros('') = ||\n" if $Verbose >= 3;
57         return '';
58     }
59     my($fixedpath,$prefix,$name);
60
61     if ($path =~ m#^\$\(.+\)$# || $path =~ m#[/:>\]]#) { 
62         if ($force_path or $path =~ /(?:DIR\)|\])$/) {
63             $fixedpath = vmspath($self->eliminate_macros($path));
64         }
65         else {
66             $fixedpath = vmsify($self->eliminate_macros($path));
67         }
68     }
69     elsif ((($prefix,$name) = ($path =~ m#^\$\(([^\)]+)\)(.+)#)) && $self->{$prefix}) {
70         my($vmspre) = vmspath($self->{$prefix}) || ''; # is it a dir or just a name?
71         $fixedpath = ($vmspre ? $vmspre : $self->{$prefix}) . $name;
72         $fixedpath = vmspath($fixedpath) if $force_path;
73     }
74     else {
75         $fixedpath = $path;
76         $fixedpath = vmspath($fixedpath) if $force_path;
77     }
78     # Convert names without directory or type to paths
79     if (!$force_path and $fixedpath !~ /[:>(.\]]/) { $fixedpath = vmspath($fixedpath); }
80     print "fixpath($path) = |$fixedpath|\n" if $Verbose >= 3;
81     $fixedpath;
82 }
83
84 sub catdir {
85     my($self,@dirs) = @_;
86     unless (ref $self){
87         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
88         $self = $ExtUtils::MakeMaker::Parent[-1];
89     }
90     my($dir) = pop @dirs;
91     @dirs = grep($_,@dirs);
92     my($rslt);
93     if (@dirs) {
94       my($path) = (@dirs == 1 ? $dirs[0] : $self->catdir(@dirs));
95       my($spath,$sdir) = ($path,$dir);
96       $spath =~ s/.dir$//; $sdir =~ s/.dir$//; 
97       $sdir = $self->eliminate_macros($sdir) unless $sdir =~ /^[\w\-]+$/;
98       $rslt = vmspath($self->eliminate_macros($spath)."/$sdir");
99     }
100     else { $rslt = vmspath($dir); }
101     print "catdir(",join(',',@_[1..$#_]),") = |$rslt|\n" if $Verbose >= 3;
102     $rslt;
103 }
104
105 sub catfile {
106     my($self,@files) = @_;
107     unless (ref $self){
108         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
109         $self = $ExtUtils::MakeMaker::Parent[-1];
110     }
111     my($file) = pop @files;
112     @files = grep($_,@files);
113     my($rslt);
114     if (@files) {
115       my($path) = (@files == 1 ? $files[0] : $self->catdir(@files));
116       my($spath) = $path;
117       $spath =~ s/.dir$//;
118       if ( $spath =~ /^[^\)\]\/:>]+\)$/ && basename($file) eq $file) { $rslt = "$spath$file"; }
119       else {
120           $rslt = $self->eliminate_macros($spath);
121           $rslt = vmsify($rslt.($rslt ? '/' : '').unixify($file));
122       }
123     }
124     else { $rslt = vmsify($file); }
125     print "catfile(",join(',',@_[1..$#_]),") = |$rslt|\n" if $Verbose >= 3;
126     $rslt;
127 }
128
129
130 # Default name is taken from the directory name if it's not passed in.
131 # Since VMS filenames are case-insensitive, we actually look in the
132 # extension files to find the Mixed-case name
133 sub guess_name {
134     my($self) = @_;
135     unless (ref $self){
136         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
137         $self = $ExtUtils::MakeMaker::Parent[-1];
138     }
139     my($defname,$defpm);
140     local *PM;
141
142     $defname = $ENV{'DEFAULT'};
143     $defname =~ s:.*?([^.\]]+)\]:$1:
144         unless ($defname =~ s:.*[.\[]ext\.(.*)\]:$1:i);
145     $defname =~ s#[.\]]#::#g;
146     ($defpm = $defname) =~ s/.*:://;
147     if (open(PM,"${defpm}.pm")){
148         while (<PM>) {
149             if (/^\s*package\s+([^;]+)/i) {
150                 $defname = $1;
151                 last;
152             }
153         }
154         print STDOUT "Warning (non-fatal): Couldn't find package name in ${defpm}.pm;\n\t",
155                      "defaulting package name to $defname\n"
156             if eof(PM);
157         close PM;
158     }
159     else {
160         print STDOUT "Warning (non-fatal): Couldn't find ${defpm}.pm;\n\t",
161                      "defaulting package name to $defname\n";
162     }
163     $defname =~ s#[\-_][\d.\-]+$##;
164     $defname;
165 }
166
167
168 sub find_perl{
169     my($self, $ver, $names, $dirs, $trace) = @_;
170     unless (ref $self){
171         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
172         $self = $ExtUtils::MakeMaker::Parent[-1];
173     }
174     my($name, $dir,$vmsfile,@cand);
175     if ($trace){
176         print "Looking for perl $ver by these names:\n";
177         print "\t@$names,\n";
178         print "in these dirs:\n";
179         print "\t@$dirs\n";
180     }
181     foreach $dir (@$dirs){
182         next unless defined $dir; # $self->{PERL_SRC} may be undefined
183         foreach $name (@$names){
184             if ($name !~ m![/:>\]]!) { push(@cand,$self->catfile($dir,$name)); }
185             else                     { push(@cand,$self->fixpath($name));      }
186         }
187     }
188     foreach $name (sort { length($a) <=> length($b) } @cand) {
189         print "Checking $name\n" if ($trace >= 2);
190         next unless $vmsfile = $self->maybe_command($name);
191         print "Executing $vmsfile\n" if ($trace >= 2);
192         if (`MCR $vmsfile -e "require $ver; print ""VER_OK\n"""` =~ /VER_OK/) {
193             print "Using PERL=MCR $vmsfile\n" if $trace;
194             return "MCR $vmsfile"
195         }
196     }
197     print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
198     0; # false and not empty
199 }
200
201
202 sub path {
203     my(@dirs,$dir,$i);
204     while ($dir = $ENV{'DCL$PATH;' . $i++}) { push(@dirs,$dir); }
205     @dirs;
206 }
207
208
209 sub maybe_command {
210     my($self,$file) = @_;
211     return $file if -x $file && ! -d _;
212     return "$file.exe" if -x "$file.exe";
213     if ($file !~ m![/:>\]]!) {
214         my($shrfile) = 'Sys$Share:' . $file;
215         return $file if -x $shrfile && ! -d _;
216         return "$file.exe" if -x "$shrfile.exe";
217     }
218     return 0;
219 }
220
221
222 sub maybe_command_in_dirs {     # $ver is optional argument if looking for perl
223     my($self, $names, $dirs, $trace, $ver) = @_;
224     my($name, $dir);
225     foreach $dir (@$dirs){
226         next unless defined $dir; # $self->{PERL_SRC} may be undefined
227         foreach $name (@$names){
228             my($abs,$tryabs);
229             if ($self->file_name_is_absolute($name)) {
230                 $abs = $name;
231             } else {
232                 $abs = $self->catfile($dir, $name);
233             }
234             print "Checking $abs for $name\n" if ($trace >= 2);
235             next unless $tryabs = $self->maybe_command($abs);
236             print "Substituting $tryabs instead of $abs\n" 
237                 if ($trace >= 2 and $tryabs ne $abs);
238             $abs = $tryabs;
239             if (defined $ver) {
240                 print "Executing $abs\n" if ($trace >= 2);
241                 if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
242                     print "Using PERL=$abs\n" if $trace;
243                     return $abs;
244                 }
245             } else { # Do not look for perl
246                 return $abs;
247             }
248         }
249     }
250 }
251
252
253 sub perl_script {
254     my($self,$file) = @_;
255     return $file if -r $file && ! -d _;
256     return "$file.pl" if -r "$file.pl" && ! -d _;
257     return '';
258 }
259
260 sub file_name_is_absolute {
261     my($sefl,$file);
262     $file =~ m!^/! or $file =~ m![:<\[][^.]!;
263 }
264
265
266 sub replace_manpage_separator {
267     my($self,$man) = @_;
268     $man = unixify($man);
269     $man =~ s#/+#__#g;
270     $man;
271 }
272
273
274 sub init_others {
275     my($self) = @_;
276     unless (ref $self){
277         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
278         $self = $ExtUtils::MakeMaker::Parent[-1];
279     }
280
281     $self->{NOOP} = "\t@ Continue";
282     $self->{FIRST_MAKEFILE} ||= 'Descrip.MMS';
283     $self->{MAKE_APERL_FILE} ||= 'Makeaperl.MMS';
284     $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
285     $self->{NOECHO} ||= '@ ';
286     $self->{RM_F} = '$(PERL) -e "foreach (@ARGV) { 1 while ( -d $_ ? rmdir $_ : unlink $_)}"';
287     $self->{RM_RF} = '$(PERL) "-I$(PERL_LIB)" -e "use File::Path; @dirs = map(VMS::Filespec::unixify($_),@ARGV); rmtree(\@dirs,0,0)"';
288     $self->{TOUCH} = '$(PERL) -e "$t=time; foreach (@ARGV) { -e $_ ? utime($t,$t,@ARGV) : (open(F,qq(>$_)),close F)}"';
289     $self->{CHMOD} = '$(PERL) -e "chmod @ARGV"';  # expect Unix syntax from MakeMaker
290     $self->{CP} = 'Copy/NoConfirm';
291     $self->{MV} = 'Rename/NoConfirm';
292     $self->{UMASK_NULL} = "\t!";  
293     &ExtUtils::MM_Unix::init_others;
294 }
295
296
297 sub constants {
298     my($self) = @_;
299     unless (ref $self){
300         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
301         $self = $ExtUtils::MakeMaker::Parent[-1];
302     }
303     my(@m,$def,$macro);
304
305     if ($self->{DEFINE} ne '') {
306         my(@defs) = split(/\s+/,$self->{DEFINE});
307         foreach $def (@defs) {
308             next unless $def;
309             $def =~ s/^-D//;
310             $def = "\"$def\"" if $def =~ /=/;
311         }
312         $self->{DEFINE} = join ',',@defs;
313     }
314
315     if ($self->{OBJECT} =~ /\s/) {
316         $self->{OBJECT} =~ s/(\\)?\n+\s+/ /g;
317         $self->{OBJECT} = map($self->fixpath($_),split(/,?\s+/,$self->{OBJECT}));
318     }
319     $self->{LDFROM} = join(' ',map($self->fixpath($_),split(/,?\s+/,$self->{LDFROM})));
320
321     if ($self->{'INC'} && $self->{INC} !~ m!/Include=!i) {
322         my(@val) = ( '/Include=(' );
323         my(@includes) = split(/\s+/,$self->{INC});
324         my($plural);
325         foreach (@includes) {
326             s/^-I//;
327             push @val,', ' if $plural++;
328             push @val,$self->fixpath($_,1);
329         }
330         $self->{INC} = join('',@val,')');
331     }
332
333     # Fix up directory specs
334     $self->{ROOTEXT} = $self->{ROOTEXT} ? $self->fixpath($self->{ROOTEXT},1)
335                                         : '[]';
336     foreach $macro ( qw [
337             INST_LIB INST_ARCHLIB INST_EXE INSTALLPRIVLIB INSTALLARCHLIB
338             INSTALLBIN PERL_LIB PERL_ARCHLIB PERL_INC PERL_SRC FULLEXT
339             INST_MAN1DIR INSTALLMAN1DIR INST_MAN3DIR INSTALLMAN3DIR
340             INSTALLSITELIB INSTALLSITEARCH SITELIBEXP SITEARCHEXP ] ) {
341         next unless defined $self->{$macro};
342         $self->{$macro} = $self->fixpath($self->{$macro},1);
343     }
344     $self->{PERL_VMS} = $self->catdir($self->{PERL_SRC},q(VMS))
345         if ($self->{PERL_SRC});
346                         
347
348
349     # Fix up file specs
350     foreach $macro ( qw[LIBPERL_A FIRST_MAKEFILE MAKE_APERL_FILE MYEXTLIB] ) {
351         next unless defined $self->{$macro};
352         $self->{$macro} = $self->fixpath($self->{$macro});
353     }
354
355     for $tmp (qw/
356               AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION VERSION_SYM XS_VERSION
357               INST_LIB INST_ARCHLIB INST_EXE PREFIX INSTALLDIRS INSTALLPRIVLIB
358               INSTALLARCHLIB INSTALLSITELIB INSTALLSITEARCH INSTALLBIN PERL_LIB
359               PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
360               FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC PERL_VMS
361               PERL_INC PERL FULLPERL
362               / ) {
363         next unless defined $self->{$tmp};
364         push @m, "$tmp = $self->{$tmp}\n";
365     }
366
367
368     push @m, q[
369 VERSION_MACRO = VERSION
370 DEFINE_VERSION = "$(VERSION_MACRO)=""$(VERSION)"""
371 XS_VERSION_MACRO = XS_VERSION
372 XS_DEFINE_VERSION = "$(XS_VERSION_MACRO)=""$(XS_VERSION)"""
373
374 MAKEMAKER = ],$self->catfile($self->{PERL_LIB},'ExtUtils','MakeMaker.pm'),qq[
375 MM_VERSION = $ExtUtils::MakeMaker::VERSION
376 MM_REVISION = $ExtUtils::MakeMaker::Revision
377 MM_VMS_REVISION = $ExtUtils::MM_VMS::Revision
378
379 # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
380 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
381 # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
382 # DLBASE  = Basename part of dynamic library. May be just equal BASEEXT.
383 ];
384
385     for $tmp (qw/
386               FULLEXT BASEEXT ROOTEXT DLBASE VERSION_FROM INC DEFINE OBJECT
387               LDFROM LINKTYPE
388               / ) {
389         next unless defined $self->{$tmp};
390         push @m, "$tmp = $self->{$tmp}\n";
391     }
392
393     push @m,'
394
395 # Handy lists of source code files:
396 XS_FILES = ',join(', ', sort keys %{$self->{XS}}),'
397 C_FILES  = ',join(', ', @{$self->{C}}),'
398 O_FILES  = ',join(', ', @{$self->{O_FILES}} ),'
399 H_FILES  = ',join(', ', @{$self->{H}}),'
400 MAN1PODS = ',join(', ', sort keys %{$self->{MAN1PODS}}),'
401 MAN3PODS = ',join(', ', sort keys %{$self->{MAN3PODS}}),'
402
403 ';
404
405     for $tmp (qw/
406               INST_MAN1DIR INSTALLMAN1DIR MAN1EXT INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
407               /) {
408         next unless defined $self->{$tmp};
409         push @m, "$tmp = $self->{$tmp}\n";
410     }
411
412 push @m,"
413 .SUFFIXES : .xs .c .cpp .cxx \$(OBJ_EXT)
414
415 # Here is the Config.pm that we are using/depend on
416 CONFIGDEP = \$(PERL_ARCHLIB)Config.pm, \$(PERL_INC)config.h \$(VERSION_FROM)
417
418 # Where to put things:
419 INST_LIBDIR = ",($self->{'INST_LIBDIR'} = $self->catdir($self->{INST_LIB},$self->{ROOTEXT})),"
420 INST_ARCHLIBDIR = ",($self->{'INST_ARCHLIBDIR'} = $self->catdir($self->{INST_ARCHLIB},$self->{ROOTEXT})),"
421
422 INST_AUTODIR = ",($self->{'INST_AUTODIR'} = $self->catdir($self->{INST_LIB},'auto',$self->{FULLEXT})),'
423 INST_ARCHAUTODIR = ',($self->{'INST_ARCHAUTODIR'} = $self->catdir($self->{INST_ARCHLIB},'auto',$self->{FULLEXT})),'
424 ';
425
426     if ($self->has_link_code()) {
427         push @m,'
428 INST_STATIC = $(INST_ARCHAUTODIR)$(BASEEXT)$(LIB_EXT)
429 INST_DYNAMIC = $(INST_ARCHAUTODIR)$(BASEEXT).$(DLEXT)
430 INST_BOOT = $(INST_ARCHAUTODIR)$(BASEEXT).bs
431 ';
432     } else {
433         push @m,'
434 INST_STATIC =
435 INST_DYNAMIC =
436 INST_BOOT =
437 EXPORT_LIST = $(BASEEXT).opt
438 PERL_ARCHIVE = ',($ENV{'PERLSHR'} ? $ENV{'PERLSHR'} : 'Sys$Share:PerlShr.Exe'),'
439 ';
440     }
441
442     push @m,'
443 INST_PM = ',join(', ',map($self->fixpath($_),sort values %{$self->{PM}})),'
444 ';
445
446     join('',@m);
447 }
448
449
450 sub const_loadlibs{
451     my($self) = @_;
452     unless (ref $self){
453         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
454         $self = $ExtUtils::MakeMaker::Parent[-1];
455     }
456     my (@m);
457     push @m, "
458 # $self->{NAME} might depend on some other libraries.
459 # (These comments may need revising:)
460 #
461 # Dependent libraries can be linked in one of three ways:
462 #
463 #  1.  (For static extensions) by the ld command when the perl binary
464 #      is linked with the extension library. See EXTRALIBS below.
465 #
466 #  2.  (For dynamic extensions) by the ld command when the shared
467 #      object is built/linked. See LDLOADLIBS below.
468 #
469 #  3.  (For dynamic extensions) by the DynaLoader when the shared
470 #      object is loaded. See BSLOADLIBS below.
471 #
472 # EXTRALIBS =   List of libraries that need to be linked with when
473 #               linking a perl binary which includes this extension
474 #               Only those libraries that actually exist are included.
475 #               These are written to a file and used when linking perl.
476 #
477 # LDLOADLIBS =  List of those libraries which can or must be linked into
478 #               the shared library when created using ld. These may be
479 #               static or dynamic libraries.
480 #               LD_RUN_PATH is a colon separated list of the directories
481 #               in LDLOADLIBS. It is passed as an environment variable to
482 #               the process that links the shared library.
483 #
484 # BSLOADLIBS =  List of those libraries that are needed but can be
485 #               linked in dynamically at run time on this platform.
486 #               SunOS/Solaris does not need this because ld records
487 #               the information (from LDLOADLIBS) into the object file.
488 #               This list is used to create a .bs (bootstrap) file.
489 #
490 EXTRALIBS  = ",map($self->fixpath($_) . ' ',$self->{'EXTRALIBS'}),"
491 BSLOADLIBS = ",map($self->fixpath($_) . ' ',$self->{'BSLOADLIBS'}),"
492 LDLOADLIBS = ",map($self->fixpath($_) . ' ',$self->{'LDLOADLIBS'}),"\n";
493
494     join('',@m);
495 }
496
497
498 sub const_cccmd {
499     my($self,$libperl) = @_;
500     unless (ref $self){
501         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
502         $self = $ExtUtils::MakeMaker::Parent[-1];
503     }
504     my($cmd,$quals) = ($Config{'cc'},$Config{'ccflags'});
505     my($name,$sys,@m);
506
507     ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
508     print STDOUT "Unix shell script ".$Config{"$self->{'BASEEXT'}_cflags"}.
509          " required to modify CC command for $self->{'BASEEXT'}\n"
510     if ($Config{$name});
511
512     # Deal with $self->{DEFINE} here since some C compilers pay attention
513     # to only one /Define clause on command line, so we have to
514     # conflate the ones from $Config{'cc'} and $self->{DEFINE}
515     if ($quals =~ m:(.*)/define=\(?([^\(\/\)\s]+)\)?(.*)?:i) {
516         $quals = "$1/Define=($2," . ($self->{DEFINE} ? "$self->{DEFINE}," : '') .
517                  "\$(DEFINE_VERSION),\$(XS_DEFINE_VERSION))$3";
518     }
519     else {
520         $quals .= '/Define=(' . ($self->{DEFINE} ? "$self->{DEFINE}," : '') .
521                   '$(DEFINE_VERSION),$(XS_DEFINE_VERSION))';
522     }
523
524     $libperl or $libperl = $self->{LIBPERL_A} || "libperl.olb";
525     if ($libperl =~ /libperl(\w+)\./i) {
526         my($type) = uc $1;
527         my(%map) = ( 'D'  => 'DEBUGGING', 'E' => 'EMBED', 'M' => 'MULTIPLICITY',
528                      'DE' => 'DEBUGGING,EMBED', 'DM' => 'DEBUGGING,MULTIPLICITY',
529                      'EM' => 'EMBED,MULTIPLICITY', 'DEM' => 'DEBUGGING,EMBED,MULTIPLICITY' );
530         $quals =~ s:/define=\(([^\)]+)\):/Define=($1,$map{$type}):i
531     }
532
533     # Likewise with $self->{INC} and /Include
534     my($incstr) = '/Include=($(PERL_INC)';
535     if ($self->{'INC'}) {
536         my(@includes) = split(/\s+/,$self->{INC});
537         foreach (@includes) {
538             s/^-I//;
539             $incstr .= ', '.$self->fixpath($_,1);
540         }
541     }
542     if ($quals =~ m:(.*)/include=\(?([^\(\/\)\s]+)\)?(.*):i) {
543         $quals = "$1$incstr,$2)$3";
544     }
545     else { $quals .= "$incstr)"; }
546
547
548    if ($Config{'vms_cc_type'} ne 'decc') {
549         push @m,'
550 .FIRST
551         ',$self->{NOECHO},'If F$TrnLnm("Sys").eqs."" Then Define/NoLog SYS ',
552         ($Config{'vms_cc_type'} eq 'gcc' ? 'GNU_CC_Include:[VMS]'
553                                          : 'Sys$Library'),'
554
555 ';
556    }
557    push(@m, "CCCMD = $cmd$quals\n");
558
559    $self->{CONST_CCCMD} = join('',@m);
560 }
561
562
563 # --- Tool Sections ---
564
565 sub tool_autosplit{
566     my($self, %attribs) = @_;
567     unless (ref $self){
568         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
569         $self = $ExtUtils::MakeMaker::Parent[-1];
570     }
571     my($asl) = "";
572     $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
573     q{
574 # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
575 AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use AutoSplit;}.$asl.q{ AutoSplit::autosplit($ARGV[0], $ARGV[1], 0, 1, 1) ;"
576 };
577 }
578
579 sub tool_xsubpp{
580     my($self) = @_;
581     unless (ref $self){
582         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
583         $self = $ExtUtils::MakeMaker::Parent[-1];
584     }
585     my($xsdir) = $self->catdir($self->{PERL_LIB},'ExtUtils');
586     # drop back to old location if xsubpp is not in new location yet
587     $xsdir = $self->catdir($self->{PERL_SRC},'ext') unless (-f $self->catfile($xsdir,'xsubpp'));
588     my(@tmdeps) = '$(XSUBPPDIR)typemap';
589     if( $self->{TYPEMAPS} ){
590         my $typemap;
591         foreach $typemap (@{$self->{TYPEMAPS}}){
592                 if( ! -f  $typemap ){
593                         warn "Typemap $typemap not found.\n";
594                 }
595                 else{
596                         push(@tmdeps, $self->fixpath($typemap));
597                 }
598         }
599     }
600     push(@tmdeps, "typemap") if -f "typemap";
601     my(@tmargs) = map("-typemap $_", @tmdeps);
602     if( exists $self->{XSOPT} ){
603         unshift( @tmargs, $self->{XSOPT} );
604     }
605
606     my $xsubpp_version = $self->xsubpp_version($self->catfile($xsdir,'xsubpp'));
607
608     # What are the correct thresholds for version 1 && 2 Paul?
609     if ( $xsubpp_version > 1.923 ){
610         $self->{XSPROTOARG} = '' unless defined $self->{XSPROTOARG};
611     } else {
612         if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) {
613             print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp.
614         Your version of xsubpp is $xsubpp_version and cannot handle this.
615         Please upgrade to a more recent version of xsubpp.
616 };
617         } else {
618             $self->{XSPROTOARG} = "";
619         }
620     }
621
622     "
623 XSUBPPDIR = ".$self->fixpath($xsdir,1)."
624 XSUBPP = \$(PERL) \"-I\$(PERL_ARCHLIB)\" \"-I\$(PERL_LIB)\" \$(XSUBPPDIR)xsubpp
625 XSPROTOARG = $self->{XSPROTOARG}
626 XSUBPPDEPS = @tmdeps
627 XSUBPPARGS = @tmargs
628 ";
629 }
630
631
632 sub xsubpp_version
633 {
634     my($self,$xsubpp) = @_;
635     my ($version) ;
636
637     # try to figure out the version number of the xsubpp on the system
638
639     # first try the -v flag, introduced in 1.921 & 2.000a2
640
641     my $command = "$self->{PERL} $xsubpp -v";
642     print "Running: $command\n" if $Verbose;
643     $version = `$command` ;
644     warn "Running '$command' exits with status " . $? unless ($? & 1);
645     chop $version ;
646
647     return $1 if $version =~ /^xsubpp version (.*)/ ;
648
649     # nope, then try something else
650
651     my $counter = '000';
652     my ($file) = 'temp' ;
653     $counter++ while -e "$file$counter"; # don't overwrite anything
654     $file .= $counter;
655
656     local(*F);
657     open(F, ">$file") or die "Cannot open file '$file': $!\n" ;
658     print F <<EOM ;
659 MODULE = fred PACKAGE = fred
660
661 int
662 fred(a)
663         int     a;
664 EOM
665
666     close F ;
667
668     $command = "$self->{PERL} $xsubpp $file";
669     print "Running: $command\n" if $Verbose;
670     my $text = `$command` ;
671     warn "Running '$command' exits with status " . $? unless ($? & 1);
672     unlink $file ;
673
674     # gets 1.2 -> 1.92 and 2.000a1
675     return $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/  ;
676
677     # it is either 1.0 or 1.1
678     return 1.1 if $text =~ /^Warning: ignored semicolon/ ;
679
680     # none of the above, so 1.0
681     return "1.0" ;
682 }
683
684
685 sub tools_other {
686     my($self) = @_;
687     unless (ref $self){
688         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
689         $self = $ExtUtils::MakeMaker::Parent[-1];
690     }
691     qq!
692 # Assumes \$(MMS) invokes MMS or MMK
693 # (It is assumed in some cases later that the default makefile name
694 # (Descrip.MMS for MM[SK]) is used.)
695 USEMAKEFILE = /Descrip=
696 USEMACROS = /Macro=(
697 MACROEND = )
698 MAKEFILE = Descrip.MMS
699 SHELL = Posix
700 TOUCH = $self->{TOUCH}
701 CHMOD = $self->{CHMOD}
702 CP = $self->{CP}
703 MV = $self->{MV}
704 RM_F  = $self->{RM_F}
705 RM_RF = $self->{RM_RF}
706 UMASK_NULL = $self->{UMASK_NULL}
707 MKPATH = Create/Directory
708 EQUALIZE_TIMESTAMP = \$(PERL) -we "open F,qq{>\$ARGV[1]};close F;utime(0,(stat(\$ARGV[0]))[9]+1,\$ARGV[1])"
709 WARN_IF_OLD_PACKLIST = \$(PERL) -e "if (-f \$ARGV[0]){print qq[WARNING: Old package found (\$ARGV[0]); please check for collisions\\n]}"
710 MOD_INSTALL = \$(PERL) "-I\$(PERL_LIB)" "-MExtUtils::Install" -e "install({split(' ',<STDIN>)},1);"
711 DOC_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]"
712 UNINSTALL = \$(PERL) "-I\$(PERL_LIB)" "-MExtUtils::Install" -e "uninstall(\$ARGV[0],1);"
713 !;
714 }
715
716
717 sub dist {
718     my($self, %attribs) = @_;
719     unless (ref $self){
720         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
721         $self = $ExtUtils::MakeMaker::Parent[-1];
722     }
723     # VERSION should be sanitised before use as a file name
724     my($name)         = $attribs{NAME}          || '$(DISTVNAME)';
725     my($zip)          = $attribs{ZIP}           || 'zip';
726     my($zipflags)     = $attribs{ZIPFLAGS}      || '-Vu';
727     my($suffix)       = $attribs{SUFFIX}        || '';
728     my($shar)         = $attribs{SHAR}          || 'vms_share';
729     my($preop)        = $attribs{PREOP}         || '!'; # e.g., update MANIFEST
730     my($postop)       = $attribs{POSTOP}        || '!';
731     my($dist_cp)  = $attribs{DIST_CP}  || 'best';
732     my($dist_default) = $attribs{DIST_DEFAULT}  || 'zipdist';
733
734     my($src) = $name;
735     $src = "[.$src]" unless $src =~ /\[/;
736     $src =~ s#\]#...]#;
737     $src .= '*.*' if $src =~ /\]$/;
738     $suffix =~ s#\.#_#g;
739 "
740 DISTVNAME = \$(DISTNAME)-\$(VERSION_SYM)
741 SRC = $src
742 ZIP = $zip
743 ZIPFLAGS = $zipflags
744 SUFFIX = $suffix
745 SHARE = $shar
746 PREOP = $preop
747 POSTOP = $postop
748 DIST_CP = $dist_cp
749 DIST_DEFAULT = $dist_default
750 ";
751 }
752
753
754 # --- Translation Sections ---
755
756 sub c_o {
757     my($self) = @_;
758     unless (ref $self){
759         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
760         $self = $ExtUtils::MakeMaker::Parent[-1];
761     }
762     return '' unless $self->needs_linking();
763     '
764 .c$(OBJ_EXT) :
765         $(CCCMD) $(CCCDLFLAGS) $(MMS$TARGET_NAME).c
766 ';
767 }
768
769 sub xs_c {
770     my($self) = @_;
771     unless (ref $self){
772         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
773         $self = $ExtUtils::MakeMaker::Parent[-1];
774     }
775     return '' unless $self->needs_linking();
776     '
777 .xs.c :
778         $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $(MMS$TARGET_NAME).xs >$(MMS$TARGET)
779 ';
780 }
781
782 sub xs_o {      # many makes are too dumb to use xs_c then c_o
783     my($self) = @_;
784     unless (ref $self){
785         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
786         $self = $ExtUtils::MakeMaker::Parent[-1];
787     }
788     return '' unless $self->needs_linking();
789     '
790 .xs$(OBJ_EXT) :
791         $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $(MMS$TARGET_NAME).xs >$(MMS$TARGET_NAME).c
792         $(CCCMD) $(CCCDLFLAGS) $(MMS$TARGET_NAME).c
793 ';
794 }
795
796
797 # --- Target Sections ---
798
799
800 sub top_targets {
801     my($self) = shift;
802     unless (ref $self){
803         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
804         $self = $ExtUtils::MakeMaker::Parent[-1];
805     }
806     my(@m);
807     push @m, '
808 all ::  config $(INST_PM) subdirs linkext manifypods
809         $(NOOP)
810
811 subdirs :: $(MYEXTLIB)
812         $(NOOP)
813
814 config :: $(MAKEFILE) $(INST_LIBDIR).exists
815         $(NOOP)
816
817 config :: $(INST_ARCHAUTODIR).exists
818         $(NOOP)
819
820 config :: $(INST_AUTODIR).exists
821         $(NOOP)
822 ';
823
824     push @m, q{
825 config :: Version_check
826
827 } unless $self->{PARENT} or ($self->{PERL_SRC} && $self->{INSTALLDIRS} eq "perl");
828
829
830     push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
831     if (%{$self->{MAN1PODS}}) {
832         push @m, q[
833 config :: $(INST_MAN1DIR).exists
834         $(NOOP)
835 ];
836         push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
837     }
838     if (%{$self->{MAN3PODS}}) {
839         push @m, q[
840 config :: $(INST_MAN3DIR).exists
841         $(NOOP)
842 ];
843         push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
844     }
845
846     push @m, '
847 $(O_FILES) : $(H_FILES)
848 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
849
850     push @m, q{
851 help :
852         perldoc ExtUtils::MakeMaker
853 };
854
855     push @m, q{
856 Version_check :
857         },$self->{NOECHO},q{$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -
858         "-MExtUtils::MakeMaker=Version_check" -e "&Version_check('$(MM_VERSION)')"
859 };
860
861     join('',@m);
862 }
863
864
865 sub dlsyms {
866     my($self,%attribs) = @_;
867     unless (ref $self){
868         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
869         $self = $ExtUtils::MakeMaker::Parent[-1];
870     }
871
872     return '' unless $self->needs_linking();
873
874     my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
875     my($vars)  = $attribs{DL_VARS}  || $self->{DL_VARS}  || [];
876     my($srcdir)= $attribs{PERL_SRC} || $self->{PERL_SRC} || '';
877     my(@m);
878
879     unless ($self->{SKIPHASH}{'dynamic'}) {
880         push(@m,'
881 dynamic :: rtls.opt $(INST_ARCHAUTODIR)$(BASEEXT).opt
882         $(NOOP)
883 ');
884         if ($srcdir) {
885            my($opt) = $self->catfile($srcdir,'perlshr.opt');
886            push(@m,"# Depend on $(BASEEXT).opt to insure we copy here *after* autogenerating (wrong) rtls.opt in Mksymlists
887 rtls.opt : $opt \$(BASEEXT).opt
888         Copy/Log $opt Sys\$Disk:[]rtls.opt
889 ");
890         }
891         else {
892             push(@m,'
893 # rtls.opt is built in the same step as $(BASEEXT).opt
894 rtls.opt : $(BASEEXT).opt
895         $(TOUCH) $(MMS$TARGET)
896 ');
897         }
898     }
899
900     push(@m,'
901 static :: $(INST_ARCHAUTODIR)$(BASEEXT).opt
902         $(NOOP)
903 ') unless $self->{SKIPHASH}{'static'};
904
905     push(@m,'
906 $(INST_ARCHAUTODIR)$(BASEEXT).opt : $(BASEEXT).opt
907         $(CP) $(MMS$SOURCE) $(MMS$TARGET)
908
909 $(BASEEXT).opt : Makefile.PL
910         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Mksymlists;" -
911         ',qq[-e "Mksymlists('NAME' => '$self->{NAME}', 'DL_FUNCS' => ],
912         neatvalue($funcs),q[, 'DL_VARS' => ],neatvalue($vars),')"
913         $(PERL) -e "print ""$(INST_STATIC)/Include=$(BASEEXT)\n$(INST_STATIC)/Library\n"";" >>$(MMS$TARGET)
914 ');
915
916     join('',@m);
917 }
918
919
920 # --- Dynamic Loading Sections ---
921
922 sub dynamic_lib {
923     my($self, %attribs) = @_;
924     unless (ref $self){
925         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
926         $self = $ExtUtils::MakeMaker::Parent[-1];
927     }
928     return '' unless $self->needs_linking(); #might be because of a subdir
929
930     return '' unless $self->has_link_code();
931
932     my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
933     my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
934     my(@m);
935     push @m,"
936
937 OTHERLDFLAGS = $otherldflags
938 INST_DYNAMIC_DEP = $inst_dynamic_dep
939
940 ";
941     push @m, '
942 $(INST_DYNAMIC) : $(INST_STATIC) $(PERL_INC)perlshr_attr.opt rtls.opt $(INST_ARCHAUTODIR).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
943         ',$self->{NOECHO},'$(MKPATH) $(INST_ARCHAUTODIR)
944         Link $(LDFLAGS) /Shareable=$(MMS$TARGET)$(OTHERLDFLAGS) $(BASEEXT).opt/Option,rtls.opt/Option,$(PERL_INC)perlshr_attr.opt/Option
945 ';
946
947     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
948     join('',@m);
949 }
950
951 sub dynamic_bs {
952     my($self, %attribs) = @_;
953     unless (ref $self){
954         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
955         $self = $ExtUtils::MakeMaker::Parent[-1];
956     }
957     return '
958 BOOTSTRAP =
959 ' unless $self->has_link_code();
960     '
961 BOOTSTRAP = '."$self->{BASEEXT}.bs".'
962
963 # As MakeMaker mkbootstrap might not write a file (if none is required)
964 # we use touch to prevent make continually trying to remake it.
965 # The DynaLoader only reads a non-empty file.
966 $(BOOTSTRAP) : $(MAKEFILE) '."$self->{BOOTDEP}".' $(INST_ARCHAUTODIR).exists
967         '.$self->{NOECHO}.'Write Sys$Output "Running mkbootstrap for $(NAME) ($(BSLOADLIBS))"
968         '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -
969         -e "use ExtUtils::Mkbootstrap; Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
970         '.$self->{NOECHO}.' $(TOUCH) $(MMS$TARGET)
971
972 $(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR).exists
973         '.$self->{NOECHO}.'$(RM_RF) $(INST_BOOT)
974         - $(CP) $(BOOTSTRAP) $(INST_BOOT)
975 ';
976 }
977 # --- Static Loading Sections ---
978
979 sub static_lib {
980     my($self) = @_;
981     unless (ref $self){
982         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
983         $self = $ExtUtils::MakeMaker::Parent[-1];
984     }
985     return '' unless $self->needs_linking();
986
987     return '
988 $(INST_STATIC) :
989         $(NOOP)
990 ' unless ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB});
991
992     my(@m);
993     push @m,'
994 # Rely on suffix rule for update action
995 $(OBJECT) : $(INST_ARCHAUTODIR).exists
996
997 $(INST_STATIC) : $(OBJECT) $(MYEXTLIB)
998 ';
999     # If this extension has it's own library (eg SDBM_File)
1000     # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
1001     push(@m, '  $(CP) $(MYEXTLIB) $(MMS$TARGET)',"\n") if $self->{MYEXTLIB};
1002
1003     push(@m,'
1004         If F$Search("$(MMS$TARGET)").eqs."" Then Library/Object/Create $(MMS$TARGET)
1005         Library/Object/Replace $(MMS$TARGET) $(MMS$SOURCE_LIST)
1006         ',$self->{NOECHO},'$(PERL) -e "open F,\'>>$(INST_ARCHAUTODIR)extralibs.ld\';print F qq[$(EXTRALIBS)\n];close F;"
1007 ');
1008     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
1009     join('',@m);
1010 }
1011
1012
1013 sub installpm_x { # called by installpm perl file
1014     my($self, $dist, $inst, $splitlib) = @_;
1015     unless (ref $self){
1016         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1017         $self = $ExtUtils::MakeMaker::Parent[-1];
1018     }
1019     if ($inst =~ m!#!) {
1020         warn "Warning: MM[SK] would have problems processing this file: $inst, SKIPPED\n";
1021         return '';
1022     }
1023     $inst = $self->fixpath($inst);
1024     $dist = $self->fixpath($dist);
1025     my($instdir) = $inst =~ /([^\)]+\))[^\)]*$/ ? $1 : dirname($inst);
1026     my(@m);
1027
1028     push(@m, "
1029 $inst : $dist \$(MAKEFILE) ${instdir}.exists \$(INST_ARCHAUTODIR).exists
1030 ",'     ',$self->{NOECHO},'$(RM_F) $(MMS$TARGET)
1031         ',$self->{NOECHO},'$(CP) ',"$dist $inst",'
1032         $(CHMOD) 644 $(MMS$TARGET)
1033 ');
1034     push(@m, '  $(AUTOSPLITFILE) $(MMS$TARGET) ',
1035               $self->catdir($splitlib,'auto')."\n\n")
1036         if ($splitlib and $inst =~ /\.pm$/);
1037     push(@m,$self->dir_target($instdir));
1038
1039     join('',@m);
1040 }
1041
1042
1043 sub manifypods {
1044     my($self, %attribs) = @_;
1045     unless (ref $self){
1046         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1047         $self = $ExtUtils::MakeMaker::Parent[-1];
1048     }
1049     return "\nmanifypods :\n\t\$(NOOP)\n" unless %{$self->{MAN3PODS}};
1050     my($dist);
1051     my($pod2man_exe,$found_pod2man);
1052     if (defined $self->{PERL_SRC}) {
1053         $pod2man_exe = $self->catfile($self->{PERL_SRC},'pod','pod2man');
1054     } else {
1055         $pod2man_exe = $self->catfile($Config{bin},'pod2man');
1056     }
1057     if ($pod2man_exe = $self->perl_script($pod2man_exe)) { $found_pod2man = 1; }
1058     else {
1059         # No pod2man but some MAN3PODS to be installed
1060         print <<END;
1061
1062 Warning: I could not locate your pod2man program.  As a last choice,
1063          I will look for the file to which the logical name POD2MAN
1064          points when MMK is invoked.
1065
1066 END
1067         $pod2man_exe = "pod2man";
1068     }
1069     my(@m);
1070     push @m,
1071 qq[POD2MAN_EXE = $pod2man_exe\n],
1072 q[POD2MAN = $(PERL) -we "%m=@ARGV;for (keys %m){" -
1073 -e "system(""MCR $^X $(POD2MAN_EXE) $_ >$m{$_}"");}"
1074 ];
1075     push @m, "\nmanifypods : ";
1076     push @m, join " ", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}};
1077     push(@m,"\n");
1078     if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) {
1079         my($pod);
1080         foreach $pod (sort keys %{$self->{MAN1PODS}}) {
1081             push @m, qq[\t\@- If F\$Search("\$(POD2MAN_EXE)").nes."" Then \$(POD2MAN) ];
1082             push @m, "$pod $self->{MAN1PODS}{$pod}\n";
1083         }
1084         foreach $pod (sort keys %{$self->{MAN3PODS}}) {
1085             push @m, qq[\t\@- If F\$Search("\$(POD2MAN_EXE)").nes."" Then \$(POD2MAN) ];
1086             push @m, "$pod $self->{MAN3PODS}{$pod}\n";
1087         }
1088     }
1089     join('', @m);
1090 }
1091
1092
1093 sub processPL {
1094     my($self) = @_;
1095     unless (ref $self){
1096         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1097         $self = $ExtUtils::MakeMaker::Parent[-1];
1098     }
1099     return "" unless $self->{PL_FILES};
1100     my(@m, $plfile);
1101     foreach $plfile (sort keys %{$self->{PL_FILES}}) {
1102         push @m, "
1103 all :: $self->{PL_FILES}->{$plfile}
1104         \$(NOOP)
1105
1106 $self->{PL_FILES}->{$plfile} :: $plfile
1107 ",'     $(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" '," $plfile
1108 ";
1109     }
1110     join "", @m;
1111 }
1112
1113
1114 sub installbin {
1115     my($self) = @_;
1116     unless (ref $self){
1117         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1118         $self = $ExtUtils::MakeMaker::Parent[-1];
1119     }
1120     return '' unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
1121     return '' unless @{$self->{EXE_FILES}};
1122     my(@m, $from, $to, %fromto, @to, $line);
1123     for $from (@{$self->{EXE_FILES}}) {
1124         my($path) = '$(INST_EXE)' . basename($from);
1125         local($_) = $path;  # backward compatibility
1126         $to = $self->libscan($path);
1127         print "libscan($from) => '$to'\n" if ($Verbose >=2);
1128         $fromto{$from}=$to;
1129     }
1130     @to   = values %fromto;
1131     push @m, "
1132 EXE_FILES = @{$self->{EXE_FILES}}
1133
1134 all :: @to
1135         \$(NOOP)
1136
1137 realclean ::
1138 ";
1139     $line = '';  #avoid unitialized var warning
1140     foreach $to (@to) {
1141         if (length($line) + length($to) > 80) {
1142             push @m, "\t\$(RM_F) $line\n";
1143             $line = $to;
1144         }
1145         else { $line .= " $to"; }
1146     }
1147     push @m, "\t\$(RM_F) $line\n\n";
1148
1149     while (($from,$to) = each %fromto) {
1150         my $todir;
1151         if ($to =~ m#[/>:\]]#) { $todir = dirname($to); }
1152         else                   { ($todir = $to) =~ s/[^\)]+$//; }
1153         $todir = $self->fixpath($todir,1);
1154         push @m, "
1155 $to : $from \$(MAKEFILE) ${todir}.exists
1156         \$(CP) $from $to
1157
1158 ", $self->dir_target($todir);
1159     }
1160     join "", @m;
1161 }
1162
1163
1164 # --- Sub-directory Sections ---
1165
1166 sub subdir_x {
1167     my($self, $subdir) = @_;
1168     unless (ref $self){
1169         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1170         $self = $ExtUtils::MakeMaker::Parent[-1];
1171     }
1172     my(@m,$key);
1173     $subdir = $self->fixpath($subdir,1);
1174     push @m, '
1175
1176 subdirs ::
1177         olddef = F$Environment("Default")
1178         Set Default ',$subdir,'
1179         - $(MMS) all $(USEMACROS)$(PASTHRU)$(MACROEND)
1180         Set Default \'olddef\'
1181 ';
1182     join('',@m);
1183 }
1184
1185
1186 # --- Cleanup and Distribution Sections ---
1187
1188 sub clean {
1189     my($self, %attribs) = @_;
1190     unless (ref $self){
1191         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1192         $self = $ExtUtils::MakeMaker::Parent[-1];
1193     }
1194     my(@m,$dir);
1195     push @m, '
1196 # Delete temporary files but do not touch installed files. We don\'t delete
1197 # the Descrip.MMS here so that a later make realclean still has it to use.
1198 clean ::
1199 ';
1200     foreach $dir (@{$self->{DIR}}) { # clean subdirectories first
1201         my($vmsdir) = $self->fixpath($dir,1);
1202         push( @m, '     If F$Search("'.$vmsdir.'$(MAKEFILE)") Then \\',"\n\t",
1203               '$(PERL) -e "chdir ',"'$vmsdir'",'; print `$(MMS) clean`;"',"\n");
1204     }
1205     push @m, '  $(RM_F) *.Map *.lis *.cpp *$(OBJ_EXT) *$(LIB_EXT) *.Opt $(BOOTSTRAP) $(BASEEXT).bso
1206 ';
1207
1208     my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
1209     push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
1210     push(@otherfiles, 'blib.dir', '$(MAKE_APERL_FILE)', 'extralibs.ld', 'perlmain.c');
1211     push(@otherfiles,$self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'));
1212     my($file,$line);
1213     $line = '';  #avoid unitialized var warning
1214     foreach $file (@otherfiles) {
1215         $file = $self->fixpath($file);
1216         if (length($line) + length($file) > 80) {
1217             push @m, "\t\$(RM_RF) $line\n";
1218             $line = "$file";
1219         }
1220         else { $line .= " $file"; }
1221     }
1222     push @m, "\t\$(RM_RF) $line\n\n";
1223     push(@m, "  $attribs{POSTOP}\n") if $attribs{POSTOP};
1224     join('', @m);
1225 }
1226
1227
1228 sub realclean {
1229     my($self, %attribs) = @_;
1230     unless (ref $self){
1231         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1232         $self = $ExtUtils::MakeMaker::Parent[-1];
1233     }
1234     my(@m);
1235     push(@m,'
1236 # Delete temporary files (via clean) and also delete installed files
1237 realclean :: clean
1238 ');
1239     foreach(@{$self->{DIR}}){
1240         my($vmsdir) = $self->fixpath($_,1);
1241         push(@m, '      If F$Search("'."$vmsdir".'$(MAKEFILE)").nes."" Then \\',"\n\t",
1242               '$(PERL) -e "chdir ',"'$vmsdir'",'; print `$(MMS) realclean`;"',"\n");
1243     }
1244     push @m,'   $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR)
1245 ';
1246     # We can't expand several of the MMS macros here, since they don't have
1247     # corresponding %$self keys (i.e. they're defined in Descrip.MMS as a
1248     # combination of macros).  In order to stay below DCL's 255 char limit,
1249     # we put only 2 on a line.
1250     my($file,$line,$fcnt);
1251     my(@files) = qw{ *.Opt $(INST_DYNAMIC) $(INST_STATIC) $(INST_BOOT) $(INST_PM) $(OBJECT) $(MAKEFILE) $(MAKEFILE)_old };
1252     $line = '';  #avoid unitialized var warning
1253     foreach $file (@files) {
1254         $file = $self->fixpath($file);
1255         if (length($line) + length($file) > 80 || ++$fcnt >= 2) {
1256             push @m, "\t\$(RM_F) $line\n";
1257             $line = "$file";
1258             $fcnt = 0;
1259         }
1260         else { $line .= " $file"; }
1261     }
1262     push @m, "\t\$(RM_F) $line\n";
1263     if ($attribs{FILES} && ref $attribs{FILES} eq 'ARRAY') {
1264         $line = '';
1265         foreach $file (@{$attribs{'FILES'}}) {
1266             $file = $self->fixpath($file);
1267             if (length($line) + length($file) > 80) {
1268                 push @m, "\t\$(RM_RF) $line\n";
1269                 $line = "$file";
1270             }
1271             else { $line .= " $file"; }
1272         }
1273         push @m, "\t\$(RM_RF) $line\n";
1274     }
1275     push(@m, "  $attribs{POSTOP}\n")                     if $attribs{POSTOP};
1276     join('', @m);
1277 }
1278
1279
1280 sub dist_basics {
1281     my($self) = @_;
1282     unless (ref $self){
1283         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1284         $self = $ExtUtils::MakeMaker::Parent[-1];
1285     }
1286 '
1287 distclean :: realclean distcheck
1288         $(NOOP)
1289
1290 distcheck :
1291         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest \'&fullcheck\'; fullcheck()"
1292
1293 skipcheck :
1294         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest \'&fullcheck\'; skipcheck()"
1295
1296 manifest :
1297         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest \'&mkmanifest\'; mkmanifest()"
1298 ';
1299 }
1300
1301
1302 sub dist_core {
1303     my($self) = @_;
1304     unless (ref $self){
1305         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1306         $self = $ExtUtils::MakeMaker::Parent[-1];
1307     }
1308 '
1309 dist : $(DIST_DEFAULT)
1310         $(NOOP)
1311
1312 zipdist : $(DISTVNAME).zip$(SUFFIX)
1313         $(NOOP)
1314
1315 $(DISTVNAME).zip$(SUFFIX) : distdir
1316         $(PREOP)
1317         $(ZIP) "$(ZIPFLAGS)" $(MMS$TARGET) $(SRC)
1318         $(RM_RF) $(DISTVNAME)
1319         $(POSTOP)
1320
1321 shdist : distdir
1322         $(PREOP)
1323         $(SHARE) $(SRC) $(DISTVNAME).share$(SUFFIX)
1324         $(RM_RF) $(DISTVNAME)
1325         $(POSTOP)
1326 ';
1327 }
1328
1329
1330 sub dist_dir {
1331     my($self) = @_;
1332     unless (ref $self){
1333         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1334         $self = $ExtUtils::MakeMaker::Parent[-1];
1335     }
1336 q{
1337 distdir :
1338         $(RM_RF) $(DISTVNAME)
1339         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest '/mani/';" \\
1340         -e "manicopy(maniread(),'$(DISTVNAME)','$(DIST_CP)');"
1341 };
1342 }
1343
1344
1345 sub dist_test {
1346     my($self) = @_;
1347     unless (ref $self){
1348         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1349         $self = $ExtUtils::MakeMaker::Parent[-1];
1350     }
1351 q{
1352 disttest : distdir
1353         startdir = F$Environment("Default")
1354         Set Default [.$(DISTVNAME)]
1355         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL
1356         $(MMS)
1357         $(MMS) test
1358         Set Default 'startdir'
1359 };
1360 }
1361
1362 sub dist_ci {
1363     my($self) = @_;
1364     unless (ref $self){
1365         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1366         $self = $ExtUtils::MakeMaker::Parent[-1];
1367     }
1368 '';
1369 }
1370
1371
1372 # --- Test and Installation Sections ---
1373
1374
1375
1376 sub install {
1377     my($self, %attribs) = @_;
1378     unless (ref $self){
1379         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1380         $self = $ExtUtils::MakeMaker::Parent[-1];
1381     }
1382     my(@m,@docfiles);
1383
1384     if ($self->{EXE_FILES}) {
1385         my($line,$file) = ('','');
1386         foreach $file (@{$self->{EXE_FILES}}) {
1387             $line .= "$file ";
1388             if (length($line) > 128) {
1389                 push(@docfiles,qq[\t\$(PERL) -e "print $line" >>.MM_tmp\n]);
1390                 $line = '';
1391             }
1392         }
1393         push(@docfiles,qq[\t\$(PERL) -e "print $line" >>.MM_tmp\n]) if $line;
1394     }
1395
1396     push @m, q[
1397 install :: all pure_install doc_install
1398         $(NOOP)
1399
1400 install_perl :: all pure_perl_install doc_perl_install
1401         $(NOOP)
1402
1403 install_site :: all pure_site_install doc_site_install
1404         $(NOOP)
1405
1406 install_ :: install_site
1407         ],$self->{NOECHO},q[Write Sys$Output "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site"
1408
1409 pure_install :: pure_$(INSTALLDIRS)_install
1410         $(NOOP)
1411
1412 doc_install :: doc_$(INSTALLDIRS)_install
1413         ],$self->{NOECHO},q[Write Sys$Output "Appending installation info to $(INST_ARCHLIB)perllocal.pod"
1414
1415 pure__install : pure_site_install
1416         ],$self->{NOECHO},q[Write Sys$Output "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site"
1417
1418 doc__install : doc_site_install
1419         ],$self->{NOECHO},q[Write Sys$Output "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site"
1420
1421 # This hack brought to you by DCL's 255-character command line limit
1422 pure_perl_install ::
1423         ].$self->{NOECHO}.q[$(PERL) -e "print 'read ].$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q[ '" >.MM_tmp
1424         ].$self->{NOECHO}.q[$(PERL) -e "print 'write ].$self->catfile('$(INSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q[ '" >>.MM_tmp
1425         ].$self->{NOECHO}.q[$(PERL) -e "print '$(INST_LIB) $(INSTALLPRIVLIB) '" >>.MM_tmp
1426         ].$self->{NOECHO}.q[$(PERL) -e "print '$(INST_ARCHLIB) $(INSTALLARCHLIB) '" >>.MM_tmp
1427         ].$self->{NOECHO}.q[$(PERL) -e "print '$(INST_EXE) $(INSTALLBIN) '" >>.MM_tmp
1428         ].$self->{NOECHO}.q[$(PERL) -e "print '$(INST_MAN1DIR) $(INSTALLMAN1DIR) '" >>.MM_tmp
1429         ].$self->{NOECHO}.q[$(PERL) -e "print '$(INST_MAN3DIR) $(INSTALLMAN3DIR) '" >>.MM_tmp
1430         $(MOD_INSTALL) <.MM_tmp
1431         ].$self->{NOECHO}.q[Delete/NoLog/NoConfirm .MM_tmp;
1432         ].$self->{NOECHO}.q[$(WARN_IF_OLD_PACKLIST) ].$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q[
1433
1434 # Likewise
1435 pure_site_install ::
1436         ].$self->{NOECHO}.q[$(PERL) -e "print 'read ].$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q[ '" >.MM_tmp
1437         ].$self->{NOECHO}.q[$(PERL) -e "print 'write ].$self->catfile('$(INSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q[ '" >>.MM_tmp
1438         ].$self->{NOECHO}.q[$(PERL) -e "print '$(INST_LIB) $(INSTALLSITELIB) '" >>.MM_tmp
1439         ].$self->{NOECHO}.q[$(PERL) -e "print '$(INST_ARCHLIB) $(INSTALLSITEARCH) '" >>.MM_tmp
1440         ].$self->{NOECHO}.q[$(PERL) -e "print '$(INST_EXE) $(INSTALLBIN) '" >>.MM_tmp
1441         ].$self->{NOECHO}.q[$(PERL) -e "print '$(INST_MAN1DIR) $(INSTALLMAN1DIR) '" >>.MM_tmp
1442         ].$self->{NOECHO}.q[$(PERL) -e "print '$(INST_MAN3DIR) $(INSTALLMAN3DIR) '" >>.MM_tmp
1443         $(MOD_INSTALL) <.MM_tmp
1444         ].$self->{NOECHO}.q[Delete/NoLog/NoConfirm .MM_tmp;
1445         ].$self->{NOECHO}.q[$(WARN_IF_OLD_PACKLIST) ].$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q[
1446
1447 # Ditto
1448 doc_perl_install ::
1449         ].$self->{NOECHO}.q[$(PERL) -e "print 'Module $(NAME)|installed into|$(INSTALLPRIVLIB)|'" >.MM_tmp
1450         ].$self->{NOECHO}.q[$(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|'" >>.MM_tmp
1451         ].$self->{NOECHO}.q[$(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|'" >>.MM_tmp
1452 ],@docfiles,q[  $(DOC_INSTALL) <.MM_tmp >>].$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q[
1453         ].$self->{NOECHO}.q[Delete/NoLog/NoConfirm .MM_tmp;
1454
1455 # And again
1456 doc_site_install ::
1457         ].$self->{NOECHO}.q[$(PERL) -e "print 'Module $(NAME)|installed into|$(INSTALLSITELIB)|'" >.MM_tmp
1458         ].$self->{NOECHO}.q[$(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|'" >>.MM_tmp
1459         ].$self->{NOECHO}.q[$(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|'" >>.MM_tmp
1460 ],@docfiles,q[  $(DOC_INSTALL) <.MM_tmp >>].$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q[
1461         ].$self->{NOECHO}.q[Delete/NoLog/NoConfirm .MM_tmp;
1462
1463 ];
1464
1465     push @m, q[
1466 uninstall :: uninstall_from_$(INSTALLDIRS)dirs
1467         $(NOOP)
1468
1469 uninstall_from_perldirs ::
1470         ].$self->{NOECHO}.q[$(UNINSTALL) ].$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q[
1471
1472 uninstall_from_sitedirs ::
1473         ].$self->{NOECHO}.q[$(UNINSTALL) ].$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist')."\n";
1474
1475     join('',@m);
1476 }
1477
1478
1479 sub perldepend {
1480     my($self) = @_;
1481     unless (ref $self){
1482         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1483         $self = $ExtUtils::MakeMaker::Parent[-1];
1484     }
1485     my(@m);
1486
1487     push @m, '
1488 $(OBJECT) : $(PERL_INC)EXTERN.h, $(PERL_INC)INTERN.h, $(PERL_INC)XSUB.h, $(PERL_INC)av.h
1489 $(OBJECT) : $(PERL_INC)cop.h, $(PERL_INC)cv.h, $(PERL_INC)embed.h, $(PERL_INC)form.h
1490 $(OBJECT) : $(PERL_INC)gv.h, $(PERL_INC)handy.h, $(PERL_INC)hv.h, $(PERL_INC)keywords.h
1491 $(OBJECT) : $(PERL_INC)mg.h, $(PERL_INC)op.h, $(PERL_INC)opcode.h, $(PERL_INC)patchlevel.h
1492 $(OBJECT) : $(PERL_INC)perl.h, $(PERL_INC)perly.h, $(PERL_INC)pp.h, $(PERL_INC)proto.h
1493 $(OBJECT) : $(PERL_INC)regcomp.h, $(PERL_INC)regexp.h, $(PERL_INC)scope.h, $(PERL_INC)sv.h
1494 $(OBJECT) : $(PERL_INC)vmsish.h, $(PERL_INC)util.h, $(PERL_INC)config.h
1495
1496 ' if $self->{OBJECT}; 
1497
1498     push(@m,'
1499 # Check for unpropagated config.sh changes. Should never happen.
1500 # We do NOT just update config.h because that is not sufficient.
1501 # An out of date config.h is not fatal but complains loudly!
1502 #$(PERL_INC)config.h : $(PERL_SRC)config.sh
1503 $(PERL_INC)config.h : $(PERL_VMS)config.vms
1504         ',$self->{NOECHO},'Write Sys$Error "Warning: $(PERL_INC)config.h out of date with $(PERL_VMS)config.vms"
1505
1506 #$(PERL_ARCHLIB)Config.pm : $(PERL_SRC)config.sh
1507 $(PERL_ARCHLIB)Config.pm : $(PERL_VMS)config.vms $(PERL_VMS)genconfig.pl
1508         ',$self->{NOECHO},'Write Sys$Error "$(PERL_ARCHLIB)Config.pm may be out of date with config.vms or genconfig.pl"
1509         olddef = F$Environment("Default")
1510         Set Default $(PERL_SRC)
1511         $(MMS) $(USEMAKEFILE)[.VMS]$(MAKEFILE) [.lib.',$Config{'arch'},']config.pm
1512         Set Default \'olddef\'
1513 ') if $self->{PERL_SRC};
1514
1515     push(@m, join(" ", map($self->fixpath($_),values %{$self->{XS}}))." : \$(XSUBPPDEPS)\n")
1516       if %{$self->{XS}};
1517
1518     join('',@m);
1519 }
1520
1521 sub makefile {
1522     my($self) = @_;
1523     unless (ref $self){
1524         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1525         $self = $ExtUtils::MakeMaker::Parent[-1];
1526     }
1527     my(@m,@cmd);
1528     # We do not know what target was originally specified so we
1529     # must force a manual rerun to be sure. But as it should only
1530     # happen very rarely it is not a significant problem.
1531     push @m, '
1532 $(OBJECT) : $(FIRST_MAKEFILE)
1533 ' if $self->{OBJECT};
1534
1535     push @m,'
1536 # We take a very conservative approach here, but it\'s worth it.
1537 # We move $(MAKEFILE) to $(MAKEFILE)_old here to avoid gnu make looping.
1538 $(MAKEFILE) : Makefile.PL $(CONFIGDEP)
1539         ',$self->{NOECHO},'Write Sys$Output "$(MAKEFILE) out-of-date with respect to $(MMS$SOURCE_LIST)"
1540         ',$self->{NOECHO},'Write Sys$Output "Cleaning current config before rebuilding $(MAKEFILE) ..."
1541         - $(MV) $(MAKEFILE) $(MAKEFILE)_old
1542         - $(MMS) $(USEMAKEFILE)$(MAKEFILE)_old clean
1543         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL ',join(' ',map(qq["$_"],@ARGV)),'
1544         ',$self->{NOECHO},'Write Sys$Output "$(MAKEFILE) has been rebuilt."
1545         ',$self->{NOECHO},'Write Sys$Output "Please run $(MMS) to build the extension."
1546 ';
1547
1548     join('',@m);
1549 }
1550
1551
1552 sub test {
1553     my($self, %attribs) = @_;
1554     unless (ref $self){
1555         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1556         $self = $ExtUtils::MakeMaker::Parent[-1];
1557     }
1558     my($tests) = $attribs{TESTS} || ( -d 't' ? 't/*.t' : '');
1559     my(@m);
1560     push @m,"
1561 TEST_VERBOSE = 0
1562 TEST_TYPE=test_\$(LINKTYPE)
1563
1564 test : \$(TEST_TYPE)
1565         \$(NOOP)
1566 ";
1567     foreach(@{$self->{DIR}}){
1568       my($vmsdir) = $self->fixpath($_,1);
1569       push(@m, '        If F$Search("',$vmsdir,'$(MAKEFILE)").nes."" Then $(PERL) -e "chdir ',"'$vmsdir'",
1570            '; print `$(MMS) $(PASTHRU2) test`'."\n");
1571     }
1572     push(@m, "\t$self->{NOECHO}Write Sys\$Output \"No tests defined for \$(NAME) extension.\"\n")
1573         unless $tests or -f "test.pl" or @{$self->{DIR}};
1574     push(@m, "\n");
1575
1576     push(@m, "test_dynamic :: all\n");
1577     push(@m, $self->test_via_harness('$(FULLPERL)', $tests)) if $tests;
1578     push(@m, $self->test_via_script('$(FULLPERL)', 'test.pl')) if -f "test.pl";
1579     push(@m, "    \$(NOOP)\n") if (!$tests && ! -f "test.pl");
1580     push(@m, "\n");
1581
1582     # Occasionally we may face this degenerate target:
1583     push @m, "test_ : test_dynamic\n\n";
1584  
1585         if ($self->needs_linking()) {
1586         push(@m, "test_static :: all \$(MAP_TARGET)\n");
1587         push(@m, $self->test_via_harness('$(MAP_TARGET)', $tests)) if $tests;
1588         push(@m, $self->test_via_script('$(MAP_TARGET)', 'test.pl')) if -f "test.pl";
1589         push(@m, "\t$self->{NOECHO}\$(NOOP)\n") if (!$tests && ! -f "test.pl");
1590         push(@m, "\n");
1591     }
1592     else {
1593         push @m, "test_static :: test_dynamic\n\t$self->{NOECHO}\$(NOOP)\n";
1594     }
1595
1596     join('',@m);
1597 }
1598
1599
1600 sub test_via_harness {
1601     my($self,$perl,$tests) = @_;
1602     unless (ref $self){
1603         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1604         $self = $ExtUtils::MakeMaker::Parent[-1];
1605     }
1606     "   $perl".' "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)" \\'."\n\t".
1607     '-e "use Test::Harness qw(&runtests $verbose); $verbose=$(TEST_VERBOSE); runtests @ARGV;" \\'."\n\t$tests\n";
1608 }
1609
1610
1611 sub test_via_script {
1612     my($self,$perl,$script) = @_;
1613     unless (ref $self){
1614         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1615         $self = $ExtUtils::MakeMaker::Parent[-1];
1616     }
1617     "   $perl".' "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" '.$script.'
1618 ';
1619 }
1620
1621
1622 sub makeaperl {
1623     my($self, %attribs) = @_;
1624     unless (ref $self){
1625         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1626         $self = $ExtUtils::MakeMaker::Parent[-1];
1627     }
1628     my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) = 
1629       @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
1630     my(@m);
1631     push @m, "
1632 # --- MakeMaker makeaperl section ---
1633 MAP_TARGET    = $target
1634 ";
1635     return join '', @m if $self->{PARENT};
1636
1637     my($dir) = join ":", @{$self->{DIR}};
1638
1639     unless ($self->{MAKEAPERL}) {
1640         push @m, q{
1641 $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
1642         },$self->{NOECHO},q{Write Sys$Output "Writing ""$(MMS$TARGET)"" for this $(MAP_TARGET)"
1643         },$self->{NOECHO},q{$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
1644                 Makefile.PL DIR=}, $dir, q{ \
1645                 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
1646                 MAKEAPERL=1 NORECURS=1
1647
1648 $(MAP_TARGET) :: $(MAKE_APERL_FILE)
1649         $(MMS)$(USEMAKEFILE)$(MAKE_APERL_FILE) static $(MMS$TARGET)
1650 };
1651         push @m, map( " \\\n\t\t$_", @ARGV );
1652         push @m, "\n";
1653
1654         return join '', @m;
1655     }
1656
1657
1658     my($linkcmd,@staticopts,@staticpkgs,$extralist,$target,$targdir,$libperldir);
1659
1660     # The front matter of the linkcommand...
1661     $linkcmd = join ' ', $Config{'ld'},
1662             grep($_, @Config{qw(large split ldflags ccdlflags)});
1663     $linkcmd =~ s/\s+/ /g;
1664
1665     # Which *.olb files could we make use of...
1666     local(%olbs);
1667     $olbs{$self->{INST_ARCHAUTODIR}} = "$self->{BASEEXT}\$(LIB_EXT)";
1668     File::Find::find(sub {
1669         return unless m/\Q$self->{LIB_EXT}\E$/;
1670         return if m/^libperl/;
1671         $olbs{$ENV{DEFAULT}} = $_;
1672     }, grep( -d $_, @{$searchdirs || []}));
1673
1674     # We trust that what has been handed in as argument will be buildable
1675     $static = [] unless $static;
1676     @olbs{@{$static}} = (1) x @{$static};
1677  
1678     $extra = [] unless $extra && ref $extra eq 'ARRAY';
1679     # Sort the object libraries in inverse order of
1680     # filespec length to try to insure that dependent extensions
1681     # will appear before their parents, so the linker will
1682     # search the parent library to resolve references.
1683     # (e.g. Intuit::DWIM will precede Intuit, so unresolved
1684     # references from [.intuit.dwim]dwim.obj can be found
1685     # in [.intuit]intuit.olb).
1686     for (sort keys %olbs) {
1687         next unless $olbs{$_} =~ /\Q$self->{LIB_EXT}\E$/;
1688         my($dir) = $self->fixpath($_,1);
1689         my($extralibs) = $dir . "extralibs.ld";
1690         my($extopt) = $dir . $olbs{$_};
1691         $extopt =~ s/$self->{LIB_EXT}$/.opt/;
1692         if (-f $extralibs ) {
1693             open LIST,$extralibs or warn $!,next;
1694             push @$extra, <LIST>;
1695             close LIST;
1696         }
1697         if (-f $extopt) {
1698             open OPT,$extopt or die $!;
1699             while (<OPT>) {
1700                 next unless /(?:UNIVERSAL|VECTOR)=boot_([\w_]+)/;
1701                 # ExtUtils::Miniperl expects Unix paths
1702                 (my($pkg) = "$1_$1$self->{LIB_EXT}") =~ s#_*#/#g;
1703                 push @staticpkgs,$pkg;
1704             }
1705             push @staticopts, $extopt;
1706         }
1707     }
1708
1709     $target = "Perl.Exe" unless $target;
1710     ($shrtarget,$targdir) = fileparse($target);
1711     $shrtarget =~ s/^([^.]*)/$1Shr/;
1712     $shrtarget = $targdir . $shrtarget;
1713     $target = "Perlshr.$Config{'dlext'}" unless $target;
1714     $tmp = "[]" unless $tmp;
1715     $tmp = $self->fixpath($tmp,1);
1716     if (@$extra) {
1717         $extralist = join(' ',@$extra);
1718         $extralist =~ s/[,\s\n]+/, /g;
1719     }
1720     else { $extralist = ''; }
1721     if ($libperl) {
1722         unless (-f $libperl || -f ($libperl = $self->catfile($Config{'installarchlib'},'CORE',$libperl))) {
1723             print STDOUT "Warning: $libperl not found\n";
1724             undef $libperl;
1725         }
1726     }
1727     unless ($libperl) {
1728         if (defined $self->{PERL_SRC}) {
1729             $libperl = $self->catfile($self->{PERL_SRC},"libperl$self->{LIB_EXT}");
1730         } elsif (-f ($libperl = $self->catfile($Config{'installarchlib'},'CORE',"libperl$self->{LIB_EXT}")) ) {
1731         } else {
1732             print STDOUT "Warning: $libperl not found
1733     If you're going to build a static perl binary, make sure perl is installed
1734     otherwise ignore this warning\n";
1735         }
1736     }
1737     $libperldir = $self->fixpath((fileparse($libperl))[1],1);
1738
1739     push @m, '
1740 # Fill in the target you want to produce if it\'s not perl
1741 MAP_TARGET    = ',$self->fixpath($target),'
1742 MAP_SHRTARGET = ',$self->fixpath($shrtarget),"
1743 MAP_LINKCMD   = $linkcmd
1744 MAP_PERLINC   = ", $perlinc ? map('"$_" ',@{$perlinc}) : '','
1745 # We use the linker options files created with each extension, rather than
1746 #specifying the object files directly on the command line.
1747 MAP_STATIC    = ',@staticopts ? join(' ', @staticopts) : '','
1748 MAP_OPTS    = ',@staticopts ? ','.join(',', map($_.'/Option', @staticopts)) : '',"
1749 MAP_EXTRA     = $extralist
1750 MAP_LIBPERL = ",$self->fixpath($libperl),'
1751 ';
1752
1753
1754     push @m,'
1755 $(MAP_SHRTARGET) : $(MAP_LIBPERL) $(MAP_STATIC) ',"${libperldir}Perlshr_Attr.Opt",'
1756         $(MAP_LINKCMD)/Shareable=$(MMS$TARGET) $(MAP_OPTS), $(MAP_EXTRA), $(MAP_LIBPERL) ',"${libperldir}Perlshr_Attr.Opt",'
1757 $(MAP_TARGET) : $(MAP_SHRTARGET) ',"${tmp}perlmain\$(OBJ_EXT) ${tmp}PerlShr.Opt",'
1758         $(MAP_LINKCMD) ',"${tmp}perlmain\$(OBJ_EXT)",', PerlShr.Opt/Option
1759         ',$self->{NOECHO},'Write Sys$Output "To install the new ""$(MAP_TARGET)"" binary, say"
1760         ',$self->{NOECHO},'Write Sys$Output "    $(MMS)$(USEMAKEFILE)$(MAKEFILE) inst_perl $(USEMACROS)MAP_TARGET=$(MAP_TARGET)$(ENDMACRO)"
1761         ',$self->{NOECHO},'Write Sys$Output "To remove the intermediate files, say
1762         ',$self->{NOECHO},'Write Sys$Output "    $(MMS)$(USEMAKEFILE)$(MAKEFILE) map_clean"
1763 ';
1764     push @m,'
1765 ',"${tmp}perlmain.c",' : $(MAKEFILE)
1766         ',$self->{NOECHO},'$(PERL) $(MAP_PERLINC) -e "use ExtUtils::Miniperl; writemain(qw|',@staticpkgs,'|)" >$(MMS$TARGET)
1767 ';
1768
1769     push @m, q[
1770 # More from the 255-char line length limit
1771 doc_inst_perl :
1772         ].$self->{NOECHO}.q[$(PERL) -e "print 'Perl binary $(MAP_TARGET)|'" >.MM_tmp
1773         ].$self->{NOECHO}.q[$(PERL) -e "print 'MAP_STATIC|$(MAP_STATIC)|'" >>.MM_tmp
1774         ].$self->{NOECHO}.q[$(PERL) -pl040 -e " " ].$self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'),q[ >>.MM_tmp
1775         ].$self->{NOECHO}.q[$(PERL) -e "print 'MAP_LIBPERL|$(MAP_LIBPERL)|'" >>.MM_tmp
1776         $(DOC_INSTALL) <.MM_tmp >>].$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q[
1777         ].$self->{NOECHO}.q[Delete/NoLog/NoConfirm .MM_tmp;
1778 ];
1779
1780     push @m, "
1781 inst_perl : pure_inst_perl doc_inst_perl
1782         \$(NOOP)
1783
1784 pure_inst_perl : \$(MAP_TARGET)
1785         $self->{CP} \$(MAP_SHRTARGET) ",$self->fixpath($Config{'installbin'},1),"
1786         $self->{CP} \$(MAP_TARGET) ",$self->fixpath($Config{'installbin'},1),"
1787
1788 clean :: map_clean
1789         \$(NOOP)
1790
1791 map_clean :
1792         \$(RM_F) ${tmp}perlmain\$(OBJ_EXT) ${tmp}perlmain.c \$(MAKEFILE)
1793         \$(RM_F) ${tmp}PerlShr.Opt \$(MAP_TARGET)
1794 ";
1795
1796     join '', @m;
1797 }
1798   
1799 sub ext {
1800     my($self) = @_;
1801     unless (ref $self){
1802         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1803         $self = $ExtUtils::MakeMaker::Parent[-1];
1804     }
1805     '','','';
1806 }
1807
1808
1809 # --- Make-Directories section (internal method) ---
1810 # dir_target(@array) returns a Makefile entry for the file .exists in each
1811 # named directory. Returns nothing, if the entry has already been processed.
1812 # We're helpless though, if the same directory comes as $(FOO) _and_ as "bar".
1813 # Both of them get an entry, that's why we use "::". I chose
1814 # '$(PERL_INC)perl.h' as the prerequisite, because there has to be one,
1815 # something that doesn't change too often :)
1816
1817 sub dir_target {
1818     my($self,@dirs) = @_;
1819     unless (ref $self){
1820         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1821         $self = $ExtUtils::MakeMaker::Parent[-1];
1822     }
1823     my(@m,$dir);
1824     foreach $dir (@dirs) {
1825         next if $self->{DIR_TARGET}{$self}{$dir}++;
1826         my($vmsdir) = $self->fixpath($dir,1);
1827         push @m, "
1828 ${vmsdir}.exists :: \$(PERL_INC)perl.h
1829         $self->{NOECHO}\$(MKPATH) $vmsdir
1830         $self->{NOECHO}\$(EQUALIZE_TIMESTAMP) \$(MMS\$SOURCE) \$(MMS\$TARGET)
1831 ";
1832     }
1833     join "", @m;
1834 }
1835
1836
1837 # --- Output postprocessing section ---
1838
1839 sub nicetext {
1840     # Insure that colons marking targets are preceded by space -
1841     # most Unix Makes don't need this, but it's necessary under VMS
1842     # to distinguish the target delimiter from a colon appearing as
1843     # part of a filespec.
1844
1845     my($self,$text) = @_;
1846     unless (ref $self){
1847         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1848         $self = $ExtUtils::MakeMaker::Parent[-1];
1849     }
1850     $text =~ s/([^\s:])(:+\s)/$1 $2/gs;
1851     $text;
1852 }
1853
1854 1;
1855
1856 __END__
1857
1858 =head1 NAME
1859
1860 ExtUtils::MM_VMS - methods to override UN*X behaviour in ExtUtils::MakeMaker
1861
1862 =head1 SYNOPSIS
1863
1864  use ExtUtils::MM_VMS; # Done internally by ExtUtils::MakeMaker if needed
1865
1866 =head1 DESCRIPTION
1867
1868 See ExtUtils::MM_Unix for a documentation of the methods provided
1869 there. This package overrides the implementation of these methods, not
1870 the semantics.