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