1 package Module::Build::Platform::VMS;
4 use Module::Build::Base;
7 @ISA = qw(Module::Build::Base);
13 Module::Build::Platform::VMS - Builder class for VMS platforms
17 This module inherits from C<Module::Build::Base> and alters a few
18 minor details of its functionality. Please see L<Module::Build> for
21 =head2 Overridden Methods
27 Change $self->{build_script} to 'Build.com' so @Build works.
33 $self->SUPER::_set_defaults(@_);
35 $self->{properties}{build_script} = 'Build.com';
41 '@Build foo' on VMS will not preserve the case of 'foo'. Rather than forcing
42 people to write '@Build "foo"' we'll dispatch case-insensitively.
48 my($action, $args) = $self->SUPER::cull_args(@_);
49 my @possible_actions = grep { lc $_ eq lc $action } $self->known_actions;
51 die "Ambiguous action '$action'. Could be one of @possible_actions"
52 if @possible_actions > 1;
54 return ($possible_actions[0], $args);
58 =item manpage_separator
60 Use '__' instead of '::'.
64 sub manpage_separator {
71 Prefixify taking into account VMS' filepath syntax.
75 # Translated from ExtUtils::MM_VMS::prefixify()
77 my($self, $path, $sprefix, $type) = @_;
78 my $rprefix = $self->prefix;
80 $self->log_verbose(" prefixify $path from $sprefix to $rprefix\n");
82 # Translate $(PERLPREFIX) to a real path.
83 $rprefix = VMS::Filespec::vmspath($rprefix) if $rprefix;
84 $sprefix = VMS::Filespec::vmspath($sprefix) if $sprefix;
86 $self->log_verbose(" rprefix translated to $rprefix\n".
87 " sprefix translated to $sprefix\n");
89 if( length $path == 0 ) {
90 $self->log_verbose(" no path to prefixify.\n")
92 elsif( !File::Spec->file_name_is_absolute($path) ) {
93 $self->log_verbose(" path is relative, not prefixifying.\n");
95 elsif( $sprefix eq $rprefix ) {
96 $self->log_verbose(" no new prefix.\n");
99 my($path_vol, $path_dirs) = File::Spec->splitpath( $path );
100 my $vms_prefix = $self->config('vms_prefix');
101 if( $path_vol eq $vms_prefix.':' ) {
102 $self->log_verbose(" $vms_prefix: seen\n");
104 $path_dirs =~ s{^\[}{\[.} unless $path_dirs =~ m{^\[\.};
105 $path = $self->_catprefix($rprefix, $path_dirs);
108 $self->log_verbose(" cannot prefixify.\n");
109 return $self->prefix_relpaths($self->installdirs, $type);
113 $self->log_verbose(" now $path\n");
120 Command-line arguments (but not the command itself) must be quoted
121 to ensure case preservation.
126 # Returns a string that can become [part of] a command line with
127 # proper quoting so that the subprocess sees this same list of args,
128 # or if we get a single arg that is an array reference, quote the
129 # elements of it and return the reference.
130 my ($self, @args) = @_;
131 my $got_arrayref = (scalar(@args) == 1
132 && UNIVERSAL::isa($args[0], 'ARRAY'))
136 map { $_ = q(").$_.q(") if !/^\"/ && length($_) > 0 }
137 ($got_arrayref ? @{$args[0]}
141 return $got_arrayref ? $args[0]
147 There is no native fork(), so some constructs depending on it are not
152 sub have_forkpipe { 0 }
156 Override to ensure that we quote the arguments but not the command.
161 # The command must not be quoted but the arguments to it must be.
162 my ($self, @cmd) = @_;
163 my $cmd = shift @cmd;
164 my $args = $self->_quote_args(@cmd);
170 Override to ensure that we quote the arguments but not the command.
175 # The command must not be quoted but the arguments to it must be.
176 my ($self, @cmd) = @_;
177 $self->log_info("@cmd\n");
178 my $cmd = shift @cmd;
179 my $args = $self->_quote_args(@cmd);
180 return !system("$cmd $args");
185 Inherit the standard version but tweak the library file name to be
186 something Dynaloader can find.
194 my $spec = $self->SUPER::_infer_xs_spec($file);
196 # Need to create with the same name as DynaLoader will load with.
197 if (defined &DynaLoader::mod2fname) {
198 my $file = $$spec{module_name} . '.' . $self->{config}->get('dlext');
200 $file = DynaLoader::mod2fname([$file]);
201 $$spec{lib_file} = File::Spec->catfile($$spec{archdir}, $file);
209 Inherit the standard version but remove dots at end of name. This may not be
210 necessary if File::Find has been fixed or DECC$FILENAME_UNIX_REPORT is in effect.
215 my ($self, $dir, $pattern) = @_;
217 my $result = $self->SUPER::rscan_dir( $dir, $pattern );
219 for my $file (@$result) { $file =~ s/\.$//; }
225 Inherit the standard version but replace embedded dots with underscores because
226 a dot is the directory delimiter on VMS.
233 my $dist_dir = $self->SUPER::dist_dir;
234 $dist_dir =~ s/\./_/g;
240 Inherit the standard version but chop the extra manpage delimiter off the front if
241 there is one. The VMS version of splitdir('[.foo]') returns '', 'foo'.
248 my $mpname = $self->SUPER::man3page_name( shift );
249 my $sep = $self->manpage_separator;
250 $mpname =~ s/^$sep//;
254 =item expand_test_dir
256 Inherit the standard version but relativize the paths as the native glob() doesn't
261 sub expand_test_dir {
262 my ($self, $dir) = @_;
264 my @reldirs = $self->SUPER::expand_test_dir( $dir );
266 for my $eachdir (@reldirs) {
267 my ($v,$d,$f) = File::Spec->splitpath( $eachdir );
268 my $reldir = File::Spec->abs2rel( File::Spec->catpath( $v, $d, '' ) );
269 $eachdir = File::Spec->catfile( $reldir, $f );
276 The home-grown glob() does not currently handle tildes, so provide limited support
277 here. Expect only UNIX format file specifications for now.
282 my ($self, $arg) = @_;
284 # Apparently double ~ are not translated.
285 return $arg if ($arg =~ /^~~/);
287 # Apparently ~ followed by whitespace are not translated.
288 return $arg if ($arg =~ /^~ /);
296 # Remove any slash folloing the tilde if present.
299 # break up the paths for the merge
300 my $home = VMS::Filespec::unixify($ENV{HOME});
302 # Trivial case of just ~ by it self
307 my ($hvol, $hdir, $hfile) = File::Spec::Unix->splitpath($home);
309 # Someone has tampered with $ENV{HOME}
310 # So hfile is probably the directory since this should be
315 my ($vol, $dir, $file) = File::Spec::Unix->splitpath($spec);
317 my @hdirs = File::Spec::Unix->splitdir($hdir);
318 my @dirs = File::Spec::Unix->splitdir($dir);
322 # Two cases of tilde handling
323 if ($arg =~ m#^~/#) {
325 # Simple case, just merge together
326 $newdirs = File::Spec::Unix->catdir(@hdirs, @dirs);
330 # Complex case, need to add an updir - No delimiters
331 my @backup = File::Spec::Unix->splitdir(File::Spec::Unix->updir);
333 $newdirs = File::Spec::Unix->catdir(@hdirs, @backup, @dirs);
337 # Now put the two cases back together
338 $arg = File::Spec::Unix->catpath($hvol, $newdirs, $file);
346 =item find_perl_interpreter
348 On VMS, $^X returns the fully qualified absolute path including version number.
349 It's logically impossible to improve on it for getting the perl we're currently
350 running, and attempting to manipulate it is usually lossy.
354 sub find_perl_interpreter { return $^X; }
360 Michael G Schwern <schwern@pobox.com>
361 Ken Williams <kwilliams@cpan.org>
362 Craig A. Berry <craigberry@mac.com>
366 perl(1), Module::Build(3), ExtUtils::MakeMaker(3)