1 package Module::Build::Platform::VMS;
6 $VERSION = eval $VERSION;
7 use Module::Build::Base;
10 @ISA = qw(Module::Build::Base);
16 Module::Build::Platform::VMS - Builder class for VMS platforms
20 This module inherits from C<Module::Build::Base> and alters a few
21 minor details of its functionality. Please see L<Module::Build> for
24 =head2 Overridden Methods
30 Change $self->{build_script} to 'Build.com' so @Build works.
36 $self->SUPER::_set_defaults(@_);
38 $self->{properties}{build_script} = 'Build.com';
44 '@Build foo' on VMS will not preserve the case of 'foo'. Rather than forcing
45 people to write '@Build "foo"' we'll dispatch case-insensitively.
51 my($action, $args) = $self->SUPER::cull_args(@_);
52 my @possible_actions = grep { lc $_ eq lc $action } $self->known_actions;
54 die "Ambiguous action '$action'. Could be one of @possible_actions"
55 if @possible_actions > 1;
57 return ($possible_actions[0], $args);
61 =item manpage_separator
63 Use '__' instead of '::'.
67 sub manpage_separator {
74 Prefixify taking into account VMS' filepath syntax.
78 # Translated from ExtUtils::MM_VMS::prefixify()
80 my($self, $path, $sprefix, $type) = @_;
81 my $rprefix = $self->prefix;
83 $self->log_verbose(" prefixify $path from $sprefix to $rprefix\n");
85 # Translate $(PERLPREFIX) to a real path.
86 $rprefix = VMS::Filespec::vmspath($rprefix) if $rprefix;
87 $sprefix = VMS::Filespec::vmspath($sprefix) if $sprefix;
89 $self->log_verbose(" rprefix translated to $rprefix\n".
90 " sprefix translated to $sprefix\n");
92 if( length $path == 0 ) {
93 $self->log_verbose(" no path to prefixify.\n")
95 elsif( !File::Spec->file_name_is_absolute($path) ) {
96 $self->log_verbose(" path is relative, not prefixifying.\n");
98 elsif( $sprefix eq $rprefix ) {
99 $self->log_verbose(" no new prefix.\n");
102 my($path_vol, $path_dirs) = File::Spec->splitpath( $path );
103 my $vms_prefix = $self->config('vms_prefix');
104 if( $path_vol eq $vms_prefix.':' ) {
105 $self->log_verbose(" $vms_prefix: seen\n");
107 $path_dirs =~ s{^\[}{\[.} unless $path_dirs =~ m{^\[\.};
108 $path = $self->_catprefix($rprefix, $path_dirs);
111 $self->log_verbose(" cannot prefixify.\n");
112 return $self->prefix_relpaths($self->installdirs, $type);
116 $self->log_verbose(" now $path\n");
123 Command-line arguments (but not the command itself) must be quoted
124 to ensure case preservation.
129 # Returns a string that can become [part of] a command line with
130 # proper quoting so that the subprocess sees this same list of args,
131 # or if we get a single arg that is an array reference, quote the
132 # elements of it and return the reference.
133 my ($self, @args) = @_;
134 my $got_arrayref = (scalar(@args) == 1
135 && UNIVERSAL::isa($args[0], 'ARRAY'))
139 # Do not quote qualifiers that begin with '/'.
141 $_ =~ s/\"/""/g; # escape C<"> by doubling
145 ($got_arrayref ? @{$args[0]}
149 return $got_arrayref ? $args[0]
155 There is no native fork(), so some constructs depending on it are not
160 sub have_forkpipe { 0 }
164 Override to ensure that we quote the arguments but not the command.
169 # The command must not be quoted but the arguments to it must be.
170 my ($self, @cmd) = @_;
171 my $cmd = shift @cmd;
172 my $args = $self->_quote_args(@cmd);
178 Override to ensure that we quote the arguments but not the command.
183 # The command must not be quoted but the arguments to it must be.
184 my ($self, @cmd) = @_;
185 $self->log_info("@cmd\n");
186 my $cmd = shift @cmd;
187 my $args = $self->_quote_args(@cmd);
188 return !system("$cmd $args");
193 Inherit the standard version but tweak the library file name to be
194 something Dynaloader can find.
202 my $spec = $self->SUPER::_infer_xs_spec($file);
204 # Need to create with the same name as DynaLoader will load with.
205 if (defined &DynaLoader::mod2fname) {
206 my $file = $$spec{module_name} . '.' . $self->{config}->get('dlext');
208 $file = DynaLoader::mod2fname([$file]);
209 $$spec{lib_file} = File::Spec->catfile($$spec{archdir}, $file);
217 Inherit the standard version but remove dots at end of name. This may not be
218 necessary if File::Find has been fixed or DECC$FILENAME_UNIX_REPORT is in effect.
223 my ($self, $dir, $pattern) = @_;
225 my $result = $self->SUPER::rscan_dir( $dir, $pattern );
227 for my $file (@$result) { $file =~ s/\.$//; }
233 Inherit the standard version but replace embedded dots with underscores because
234 a dot is the directory delimiter on VMS.
241 my $dist_dir = $self->SUPER::dist_dir;
242 $dist_dir =~ s/\./_/g;
248 Inherit the standard version but chop the extra manpage delimiter off the front if
249 there is one. The VMS version of splitdir('[.foo]') returns '', 'foo'.
256 my $mpname = $self->SUPER::man3page_name( shift );
257 my $sep = $self->manpage_separator;
258 $mpname =~ s/^$sep//;
262 =item expand_test_dir
264 Inherit the standard version but relativize the paths as the native glob() doesn't
269 sub expand_test_dir {
270 my ($self, $dir) = @_;
272 my @reldirs = $self->SUPER::expand_test_dir( $dir );
274 for my $eachdir (@reldirs) {
275 my ($v,$d,$f) = File::Spec->splitpath( $eachdir );
276 my $reldir = File::Spec->abs2rel( File::Spec->catpath( $v, $d, '' ) );
277 $eachdir = File::Spec->catfile( $reldir, $f );
284 The home-grown glob() does not currently handle tildes, so provide limited support
285 here. Expect only UNIX format file specifications for now.
290 my ($self, $arg) = @_;
292 # Apparently double ~ are not translated.
293 return $arg if ($arg =~ /^~~/);
295 # Apparently ~ followed by whitespace are not translated.
296 return $arg if ($arg =~ /^~ /);
304 # Remove any slash folloing the tilde if present.
307 # break up the paths for the merge
308 my $home = VMS::Filespec::unixify($ENV{HOME});
310 # Trivial case of just ~ by it self
315 my ($hvol, $hdir, $hfile) = File::Spec::Unix->splitpath($home);
317 # Someone has tampered with $ENV{HOME}
318 # So hfile is probably the directory since this should be
323 my ($vol, $dir, $file) = File::Spec::Unix->splitpath($spec);
325 my @hdirs = File::Spec::Unix->splitdir($hdir);
326 my @dirs = File::Spec::Unix->splitdir($dir);
330 # Two cases of tilde handling
331 if ($arg =~ m#^~/#) {
333 # Simple case, just merge together
334 $newdirs = File::Spec::Unix->catdir(@hdirs, @dirs);
338 # Complex case, need to add an updir - No delimiters
339 my @backup = File::Spec::Unix->splitdir(File::Spec::Unix->updir);
341 $newdirs = File::Spec::Unix->catdir(@hdirs, @backup, @dirs);
345 # Now put the two cases back together
346 $arg = File::Spec::Unix->catpath($hvol, $newdirs, $file);
354 =item find_perl_interpreter
356 On VMS, $^X returns the fully qualified absolute path including version
357 number. It's logically impossible to improve on it for getting the perl
358 we're currently running, and attempting to manipulate it is usually
363 sub find_perl_interpreter { return $^X; }
365 =item localize_file_path
367 Convert the file path to the local syntax
371 sub localize_file_path {
372 my ($self, $path) = @_;
374 return VMS::Filespec::vmsify($path);
377 =item localize_dir_path
379 Convert the directory path to the local syntax
383 sub localize_dir_path {
384 my ($self, $path) = @_;
385 return VMS::Filespec::vmspath($path);
392 Michael G Schwern <schwern@pobox.com>
393 Ken Williams <kwilliams@cpan.org>
394 Craig A. Berry <craigberry@mac.com>
398 perl(1), Module::Build(3), ExtUtils::MakeMaker(3)