package ExtUtils
::MM_Any
;
use vars
qw($VERSION @ISA);
BEGIN { @ISA = qw(File::Spec); }
use ExtUtils
::MakeMaker
qw($Verbose);
use ExtUtils::MakeMaker::Config;
# So we don't have to keep calling the methods over and over again,
# we have these globals to cache the values. Faster and shrtr.
my $Curdir = __PACKAGE__->curdir;
my $Rootdir = __PACKAGE__->rootdir;
my $Updir = __PACKAGE__->updir;
ExtUtils::MM_Any - Platform-agnostic MM methods
package ExtUtils::MM_SomeOS;
# Temporarily, you have to subclass both. Put MM_Any first.
require ExtUtils::MM_Any;
require ExtUtils::MM_Unix;
@ISA = qw(ExtUtils::MM_Any ExtUtils::Unix);
B<FOR INTERNAL USE ONLY!>
ExtUtils::MM_Any is a superclass for the ExtUtils::MM_* set of
modules. It contains methods which are either inherently
cross-platform or are written in a cross-platform manner.
Subclass off of ExtUtils::MM_Any I<and> ExtUtils::MM_Unix. This is a
B<THIS MAY BE TEMPORARY!>
Any methods marked I<Abstract> must be implemented by subclasses.
=head2 Cross-platform helper methods
These are methods which help writing cross-platform code.
=head3 os_flavor I<Abstract>
my @os_flavor = $mm->os_flavor;
@os_flavor is the style of operating system this is, usually
corresponding to the MM_*.pm file we're using.
The first element of @os_flavor is the major family (ie. Unix,
Windows, VMS, OS/2, etc...) and the rest are sub families.
Cygwin98 ('Unix', 'Cygwin', 'Cygwin9x')
Windows NT ('Win32', 'WinNT')
MacOS X ('Unix', 'Darwin', 'MacOS', 'MacOS X')
This is used to write code for styles of operating system.
See os_flavor_is() for use.
my $is_this_flavor = $mm->os_flavor_is($this_flavor);
my $is_this_flavor = $mm->os_flavor_is(@one_of_these_flavors);
Checks to see if the current operating system is one of the given flavors.
This is useful for code like:
if( $mm->os_flavor_is('Unix') ) {
my %flavors = map { ($_ => 1) } $self->os_flavor;
return (grep { $flavors{$_} } @_) ?
1 : 0;
my @cmds = $MM->split_command($cmd, @args);
Most OS have a maximum command length they can execute at once. Large
modules can easily generate commands well past that limit. Its
necessary to split long commands up into a series of shorter commands.
C<split_command> will return a series of @cmds each processing part of
the args. Collectively they will process all the arguments. Each
individual line in @cmds will not be longer than the
$self->max_exec_len being careful to take into account macro expansion.
$cmd should include any switches and repeated initial arguments.
If no @args are given, no @cmds will be returned.
Pairs of arguments will always be preserved in a single command, this
is a heuristic for things like pm_to_blib and pod2man which work on
pairs of arguments. This makes things like this safe:
$self->split_command($cmd, %pod2man);
my($self, $cmd, @args) = @_;
return(@cmds) unless @args;
# If the command was given as a here-doc, there's probably a trailing
# set aside 20% for macro expansion.
my $len_left = int($self->max_exec_len * 0.80);
$len_left -= length $self->_expand_macros($cmd);
while( @next_args = splice(@args, 0, 2) ) {
# Two at a time to preserve pairs.
my $next_arg_str = "\t ". join ' ', @next_args, "\n";
$arg_str .= $next_arg_str
elsif( length($arg_str) + length($next_arg_str) > $len_left ) {
unshift @args, @next_args;
$arg_str .= $next_arg_str;
push @cmds, $self->escape_newlines("$cmd \n$arg_str");
defined $self->{$1} ?
$self->{$1} : "\$($1)"
my @commands = $MM->echo($text);
my @commands = $MM->echo($text, $file);
my @commands = $MM->echo($text, $file, $appending);
Generates a set of @commands which print the $text to a $file.
If $file is not given, output goes to STDOUT.
If $appending is true the $file will be appended to rather than
my($self, $text, $file, $appending) = @_;
my @cmds = map { '$(NOECHO) $(ECHO) '.$self->quote_literal($_) }
my $redirect = $appending ?
'>>' : '>';
$cmds[0] .= " $redirect $file";
$_ .= " >> $file" foreach @cmds[1..$#cmds];
my $args = $mm->wraplist(@list);
Takes an array of items and turns them into a well-formatted list of
arguments. In most cases this is simply something like:
return join " \\\n\t", @_;
my $subdir_cmd = $MM->cd($subdir, @cmds);
This will generate a make fragment which runs the @cmds in the given
$dir. The rough equivalent to this, except cross platform.
Currently $dir can only go down one level. "foo" is fine. "foo/bar" is
not. "../foo" is right out.
The resulting $subdir_cmd has no leading tab nor trailing newline. This
makes it easier to embed in a make string. For example.
my $make = sprintf <<'CODE', $subdir_cmd;
=head3 oneliner I<Abstract>
my $oneliner = $MM->oneliner($perl_code);
my $oneliner = $MM->oneliner($perl_code, \@switches);
This will generate a perl one-liner safe for the particular platform
you're on based on the given $perl_code and @switches (a -e is
assumed) suitable for using in a make target. It will use the proper
shell quoting and escapes.
$(PERLRUN) will be used as perl.
Any newlines in $perl_code will be escaped. Leading and trailing
newlines will be stripped. Makes this idiom much easier:
my $code = $MM->oneliner(<<'CODE', [...switches...]);
Usage might be something like:
$oneliner = $MM->oneliner('print "Foo\n"');
$make = '$oneliner > somefile';
All dollar signs must be doubled in the $perl_code if you expect them
to be interpreted normally, otherwise it will be considered a make
macro. Also remember to quote make macros else it might be used as a
# Assign the value of the $(VERSION_FROM) make macro to $vf.
$oneliner = $MM->oneliner('$$vf = "$(VERSION_FROM)"');
Its currently very simple and may be expanded sometime in the figure
to include more flexible code and switches.
=head3 quote_literal I<Abstract>
my $safe_text = $MM->quote_literal($text);
This will quote $text so it is interpreted literally in the shell.
For example, on Unix this would escape any single-quotes in $text and
put single-quotes around the whole thing.
=head3 escape_newlines I<Abstract>
my $escaped_text = $MM->escape_newlines($text);
Shell escapes newlines in $text.
=head3 max_exec_len I<Abstract>
my $max_exec_len = $MM->max_exec_len;
Calculates the maximum command size the OS can exec. Effectively,
this is the max size of a shell command line.
$self->{_MAX_EXEC_LEN} is set by this method, but only for testing purposes.
These are methods which produce make targets.
Generate the default target 'all'.
my $make_frag = $mm->blibdirs_target;
Creates the blibdirs target which creates all the directories we use
The blibdirs.ts target is deprecated. Depend on blibdirs instead.
my @dirs = map { uc "\$(INST_$_)" } qw(libdir archlib
my @exists = map { $_.'$(DFSEP).exists' } @dirs;
my $make = sprintf <<'MAKE', join(' ', @exists);
# Backwards compat with 6.18 through 6.25
$make .= $self->dir_target(@dirs);
Defines the clean target.
# --- Cleanup and Distribution Sections ---
my($self, %attribs) = @_;
# Delete temporary files but do not touch installed files. We don\'t delete
# the Makefile here so a later make realclean still has a makefile to use.
my @files = values %{$self->{XS
}}; # .c files from *.xs files
# Normally these are all under blib but they might have been
# XXX normally this would be a good idea, but the Perl core sets
# INST_LIB = ../../lib rather than actually installing the files.
# So a "make clean" in an ext/ directory would blow away lib.
# Until the core is adjusted let's leave this out.
# push @dirs, qw($(INST_ARCHLIB) $(INST_LIB)
# $(INST_BIN) $(INST_SCRIPT)
# $(INST_MAN1DIR) $(INST_MAN3DIR)
# $(INST_LIBDIR) $(INST_ARCHLIBDIR) $(INST_AUTODIR)
# $(INST_STATIC) $(INST_DYNAMIC) $(INST_BOOT)
# Use @dirs because we don't know what's in here.
push @dirs, ref $attribs{FILES
} ?
split /\s+/, $attribs{FILES
} ;
push(@files, qw
[$(MAKE_APERL_FILE
)
perlmain
.c tmon
.out mon
.out so_locations
blibdirs
.ts pm_to_blib pm_to_blib
.ts
*$(OBJ_EXT
) *$(LIB_EXT
) perl
.exe perl perl
$(EXE_EXT
)
$(BOOTSTRAP
) $(BASEEXT
).bso
$(BASEEXT
).def lib
$(BASEEXT
).def
$(BASEEXT
).exp $(BASEEXT
).x
push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'));
push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.ld'));
push(@files, qw
[core core
.*perl
.*.?
*perl
.core
]);
push(@files, map { "core." . "[0-9]"x
$_ } (1..5));
# OS specific things to clean up. Use @dirs since we don't know
push @dirs, $self->extra_clean_files;
# Occasionally files are repeated several times from different sources
{ my(%f) = map { ($_ => 1) } @files; @files = keys %f; }
{ my(%d) = map { ($_ => 1) } @dirs; @dirs = keys %d; }
push @m, map "\t$_\n", $self->split_command('- $(RM_F)', @files);
push @m, map "\t$_\n", $self->split_command('- $(RM_RF)', @dirs);
# Leave Makefile.old around for realclean
- $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL)
push(@m, "\t$attribs{POSTOP}\n") if $attribs{POSTOP
};
=head3 clean_subdirs_target
my $make_frag = $MM->clean_subdirs_target;
Returns the clean_subdirs target. This is used by the clean target to
call clean on any subdirectories which contain Makefiles.
sub clean_subdirs_target
{
# No subdirectories, no cleaning.
return <<'NOOP_FRAG' unless @{$self->{DIR}};
my $clean = "clean_subdirs :\n";
for my $dir (@
{$self->{DIR
}}) {
my $subclean = $self->oneliner(sprintf <<'CODE', $dir);
chdir '%s'; system '$(MAKE) clean' if -f '$(FIRST_MAKEFILE)';
$clean .= "\t$subclean\n";
my $make_frag = $mm->dir_target(@directories);
Generates targets to create the specified directories and set its
Because depending on a directory to just ensure it exists doesn't work
too well (the modified time changes too often) dir_target() creates a
.exists file in the created directory. It is this you should depend on.
For portability purposes you should use the $(DIRFILESEP) macro rather
than a '/' to seperate the directory from the file.
yourdirectory$(DIRFILESEP).exists
foreach my $dir (@dirs) {
$make .= sprintf <<'MAKE', ($dir) x 7;
%s$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(CHMOD) 755 %s
$(NOECHO) $(TOUCH) %s$(DFSEP).exists
Defines the scratch directory target that will hold the distribution
before tar-ing (or shar-ing).
# For backwards compatibility.
my $meta_target = $self->{NO_META
} ?
'' : 'distmeta';
my $sign_target = !$self->{SIGN
} ?
'' : 'distsignature';
return sprintf <<'MAKE_FRAG', $meta_target, $sign_target;
$(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
-e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
distdir : create_distdir %s %s
Defines a target that produces the distribution in the
scratchdirectory, and runs 'perl Makefile.PL; make ;make test' in that
my $mpl_args = join " ", map qq["$_"], @ARGV;
my $test = $self->cd('$(DISTVNAME)',
'$(ABSPERLRUN) Makefile.PL '.$mpl_args,
'$(MAKE
) test
$(PASTHRU
)'
return sprintf <<'MAKE_FRAG', $test;
Defines the dynamic target.
# --- Dynamic Loading Sections ---
dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT)
=head3 makemakerdflt_target
my $make_frag = $mm->makemakerdflt_target
Returns a make fragment with the makemakerdeflt_target specified.
This target is the first target in the Makefile, is the default target
and simply points off to 'all' just in case any make variant gets
confused or something gets snuck in before the real 'all' target.
sub makemakerdflt_target
{
my $manifypods_target = $self->manifypods_target;
Generates the manifypods target. This target generates man pages from
all POD files in MAN1PODS and MAN3PODS.
# populate manXpods & dependencies:
foreach my $name (keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}}) {
$dependencies .= " \\\n\t$name";
foreach my $name (keys %{$self->{MAN3PODS}}) {
$dependencies .= " \\\n\t$name"
manifypods : pure_all $dependencies
foreach my $section (qw(1 3)) {
my $pods = $self->{"MAN${section}PODS"};
push @man_cmds, $self->split_command(<<CMD, %$pods);
\$(NOECHO) \$(POD2MAN) --section=$section --perm_rw=\$(PERM_RW)
$manify .= "\t\$(NOECHO) \$(NOOP)\n" unless @man_cmds;
$manify .= join '', map { "$_\n" } @man_cmds;
my $target = $mm->metafile_target;
Generate the metafile target.
Writes the file META.yml YAML encoded meta-data about the module in
the distdir. The format follows Module::Build's as closely as
possible. Additionally, we include:
return <<'MAKE_FRAG' if $self->{NO_META};
foreach my $mod ( sort { lc $a cmp lc $b } keys %{$self->{PREREQ_PM}} ) {
my $ver = $self->{PREREQ_PM}{$mod};
$prereq_pm .= sprintf " %-30s %s\n", "$mod:", $ver;
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
version: $self->{VERSION}
version_from: $self->{VERSION_FROM}
installdirs: $self->{INSTALLDIRS}
distribution_type: module
generated_by: ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION
my @write_meta = $self->echo($meta, 'META_new.yml');
return sprintf <<'MAKE_FRAG', join("\n\t", @write_meta);
metafile : create_distdir
$(NOECHO) $(ECHO) Generating META.yml
-$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml
my $make_frag = $mm->distmeta_target;
Generates the distmeta target to add META.yml to the MANIFEST in the
my $add_meta = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) }
or print "Could not add META.yml to MANIFEST: $${'@'}\n"
my $add_meta_to_distdir = $self->cd('$(DISTVNAME)', $add_meta);
return sprintf <<'MAKE', $add_meta_to_distdir;
distmeta : create_distdir metafile
Defines the realclean target.
my($self, %attribs) = @_;
my @dirs = qw($(DISTVNAME));
my @files = qw($(FIRST_MAKEFILE) $(MAKEFILE_OLD
));
# Special exception for the perl core where INST_* is not in blib.
# This cleans up the files built from the ext/ directory (all XS).
if( $self->{PERL_CORE
} ) {
push @dirs, qw($(INST_AUTODIR) $(INST_ARCHAUTODIR
));
push @files, values %{$self->{PM
}};
if( $self->has_link_code ){
push @files, qw($(OBJECT));
if( ref $attribs{FILES
} ) {
push @dirs, @
{ $attribs{FILES
} };
push @dirs, split /\s+/, $attribs{FILES
};
# Occasionally files are repeated several times from different sources
{ my(%f) = map { ($_ => 1) } @files; @files = keys %f; }
{ my(%d) = map { ($_ => 1) } @dirs; @dirs = keys %d; }
my $rm_cmd = join "\n\t", map { "$_" }
$self->split_command('- $(RM_F)', @files);
my $rmf_cmd = join "\n\t", map { "$_" }
$self->split_command('- $(RM_RF)', @dirs);
my $m = sprintf <<'MAKE', $rm_cmd, $rmf_cmd;
# Delete temporary files (via clean) and also delete dist files
realclean purge :: clean realclean_subdirs
$m .= "\t$attribs{POSTOP}\n" if $attribs{POSTOP
};
=head3 realclean_subdirs_target
my $make_frag = $MM->realclean_subdirs_target;
Returns the realclean_subdirs target. This is used by the realclean
target to call realclean on any subdirectories which contain Makefiles.
sub realclean_subdirs_target
{
return <<'NOOP_FRAG' unless @{$self->{DIR}};
my $rclean = "realclean_subdirs :\n";
foreach my $dir (@
{$self->{DIR
}}) {
foreach my $makefile ('$(MAKEFILE_OLD)', '$(FIRST_MAKEFILE)' ) {
my $subrclean .= $self->oneliner(sprintf <<'CODE', $dir, ($makefile) x 2);
chdir '%s'; system '$(MAKE) $(USEMAKEFILE) %s realclean' if -f '%s';
$rclean .= sprintf <<'RCLEAN', $subrclean;
my $target = $mm->signature_target;
Generate the signature target.
Writes the file SIGNATURE with "cpansign -s".
=head3 distsignature_target
my $make_frag = $mm->distsignature_target;
Generates the distsignature target to add SIGNATURE to the MANIFEST in the
sub distsignature_target {
my $add_sign = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) }
or print "Could not add SIGNATURE to MANIFEST: $${'@'}\n"
my $sign_dist = $self->cd('$(DISTVNAME)' => 'cpansign -s');
# cpansign -s complains if SIGNATURE is in the MANIFEST yet does not
my $touch_sig = $self->cd('$(DISTVNAME)' => '$(TOUCH) SIGNATURE');
my $add_sign_to_dist = $self->cd('$(DISTVNAME)' => $add_sign );
return sprintf <<'MAKE', $add_sign_to_dist, $touch_sig, $sign_dist
distsignature : create_distdir
my $make_frag = $mm->special_targets
Returns a make fragment containing any targets which have special
meaning to make. For example, .SUFFIXES and .PHONY.
my $make_frag = <<'MAKE_FRAG';
.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT)
.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir
$make_frag .= <<'MAKE_FRAG
' if $ENV{CLEARCASE_ROOT};
Methods which help initialize the MakeMaker object and macros.
Called by init_main. Sets up all INST_* variables except those related
to XS code. Those are handled in init_xs.
$self->{INST_ARCHLIB} ||= $self->catdir($Curdir,"blib","arch");
$self->{INST_BIN} ||= $self->catdir($Curdir,'blib
','bin
');
# INST_LIB typically pre-set if building an extension after
# perl has been built and installed. Setting INST_LIB allows
# you to build directly into, say $Config{privlibexp}.
unless ($self->{INST_LIB}){
if ($self->{PERL_CORE}) {
if (defined $Cross::platform) {
$self->{INST_LIB} = $self->{INST_ARCHLIB} =
$self->catdir($self->{PERL_LIB},"..","xlib",
$self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
$self->{INST_LIB} = $self->catdir($Curdir,"blib","lib");
my @parentdir = split(/::/, $self->{PARENT_NAME});
$self->{INST_LIBDIR} = $self->catdir('$(INST_LIB
)', @parentdir);
$self->{INST_ARCHLIBDIR} = $self->catdir('$(INST_ARCHLIB
)', @parentdir);
$self->{INST_AUTODIR} = $self->catdir('$(INST_LIB
)', 'auto
',
$self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB
)', 'auto
',
$self->{INST_SCRIPT} ||= $self->catdir($Curdir,'blib
','script
');
$self->{INST_MAN1DIR} ||= $self->catdir($Curdir,'blib
','man1
');
$self->{INST_MAN3DIR} ||= $self->catdir($Curdir,'blib
','man3
');
Called by init_main. Sets up all INSTALL_* variables (except
INSTALLDIRS) and *PREFIX.
if( $self->{ARGS}{INSTALLBASE} and $self->{ARGS}{PREFIX} ) {
die "Only one of PREFIX or INSTALLBASE can be given. Not both.\n";
if( $self->{ARGS}{INSTALLBASE} ) {
$self->init_INSTALL_from_INSTALLBASE;
$self->init_INSTALL_from_PREFIX;
=head3 init_INSTALL_from_PREFIX
$mm->init_INSTALL_from_PREFIX;
sub init_INSTALL_from_PREFIX {
# There are often no Config.pm defaults for these new man variables so
# we fall back to the old behavior which is to use installman*dir
my $k = 'installsiteman
'.$num.'dir
';
$self->{uc $k} ||= uc "\$(installman${num}dir)"
my $k = 'installvendorman
'.$num.'dir
';
$self->{uc $k} ||= $Config{usevendorprefix}
? uc "\$(installman${num}dir)"
$self->{INSTALLSITEBIN} ||= '$(INSTALLBIN
)'
unless $Config{installsitebin};
unless( $Config{installvendorbin} ) {
$self->{INSTALLVENDORBIN} ||= $Config{usevendorprefix}
my $iprefix = $Config{installprefixexp} || $Config{installprefix} ||
$Config{prefixexp} || $Config{prefix} || '';
my $vprefix = $Config{usevendorprefix} ? $Config{vendorprefixexp} : '';
my $sprefix = $Config{siteprefixexp} || '';
# 5.005_03 doesn't have a siteprefix
.
$sprefix = $iprefix unless $sprefix;
@
{$self}{qw(PERLPREFIX SITEPREFIX VENDORPREFIX)} =
$self->{PERLPREFIX
} ||= $iprefix;
$self->{SITEPREFIX
} ||= $sprefix;
$self->{VENDORPREFIX
} ||= $vprefix;
# Lots of MM extension authors like to use $(PREFIX) so we
# put something sensible in there no matter what.
$self->{PREFIX
} = '$('.uc $self->{INSTALLDIRS
}.'PREFIX)';
my $arch = $Config{archname
};
my $version = $Config{version
};
my $libstyle = $Config{installstyle
} || 'lib/perl5';
if( $self->{LIBSTYLE
} ) {
$libstyle = $self->{LIBSTYLE
};
$manstyle = $self->{LIBSTYLE
} eq 'lib/perl5' ?
'lib/perl5' : '';
# Some systems, like VOS, set installman*dir to '' if they can't
$self->{'INSTALLMAN'.$num.'DIR'} ||= 'none'
unless $Config{'installman'.$num.'dir'};
vendorbin
=> { s
=> $vprefix,
sitebin
=> { s
=> $sprefix,
script
=> { s
=> $iprefix,
man1dir
=> { s
=> $iprefix,
siteman1dir
=> { s
=> $sprefix,
vendorman1dir
=> { s
=> $vprefix,
man3dir
=> { s
=> $iprefix,
siteman3dir
=> { s
=> $sprefix,
vendorman3dir
=> { s
=> $vprefix,
privlib
=> { s
=> $iprefix,
vendorlib
=> { s
=> $vprefix,
sitelib
=> { s
=> $sprefix,
archlib
=> { s
=> $iprefix,
vendorarch
=> { s
=> $vprefix,
sitearch
=> { s
=> $sprefix,
d
=> "site_perl/$version/$arch",
foreach my $var (keys %lib_layouts) {
my $Installvar = uc "install$var";
$self->catdir($self->{LIB
}, $Config{archname
});
$self->{$Installvar} ||= $self->{LIB
};
my %type2prefix = ( perl
=> 'PERLPREFIX',
my %layouts = (%bin_layouts, %man_layouts, %lib_layouts);
while( my($var, $layout) = each(%layouts) ) {
my($s, $t, $d, $style) = @
{$layout}{qw(s t d style)};
my $r = '$('.$type2prefix{$t}.')';
print STDERR
"Prefixing $var\n" if $Verbose >= 2;
my $installvar = "install$var";
my $Installvar = uc $installvar;
next if $self->{$Installvar};
$d = "$style/$d" if $style;
$self->prefixify($installvar, $s, $r, $d);
print STDERR
" $Installvar == $self->{$Installvar}\n"
# Generate these if they weren't figured out.
$self->{VENDORARCHEXP
} ||= $self->{INSTALLVENDORARCH
};
$self->{VENDORLIBEXP
} ||= $self->{INSTALLVENDORLIB
};
=head3 init_from_INSTALLBASE
$mm->init_from_INSTALLBASE
arch
=> [('lib', 'perl5', $Config{archname
})],
man1dir
=> [qw(man man1)],
man3dir
=> [qw(man man3)]
$map{script
} = $map{bin
};
sub init_INSTALL_from_INSTALLBASE
{
@
{$self}{qw(PREFIX VENDORPREFIX SITEPREFIX PERLPREFIX)} =
foreach my $thing (keys %map) {
foreach my $dir (('', 'SITE', 'VENDOR')) {
my $uc_thing = uc $thing;
my $key = "INSTALL".$dir.$uc_thing;
$self->catdir('$(INSTALLBASE)', @
{$map{$thing}});
# Adjust for variable quirks.
$install{INSTALLARCHLIB
} ||= delete $install{INSTALLARCH
};
$install{INSTALLPRIVLIB
} ||= delete $install{INSTALLLIB
};
delete @install{qw(INSTALLVENDORSCRIPT INSTALLSITESCRIPT)};
foreach my $key (keys %install) {
$self->{$key} ||= $install{$key};
=head3 init_VERSION I<Abstract>
Initialize macros representing versions of MakeMaker and other tools
MAKEMAKER: path to the MakeMaker module.
MM_VERSION: ExtUtils::MakeMaker Version
MM_REVISION: ExtUtils::MakeMaker version control revision (for backwards
VERSION: version of your module
VERSION_MACRO: which macro represents the version (usually 'VERSION')
VERSION_SYM: like version but safe for use as an RCS revision number
DEFINE_VERSION: -D line to set the module version when compiling
XS_VERSION: version in your .xs file. Defaults to $(VERSION)
XS_VERSION_MACRO: which macro represents the XS version.
XS_DEFINE_VERSION: -D line to set the xs version when compiling.
$self->{MAKEMAKER
} = $ExtUtils::MakeMaker
::Filename
;
$self->{MM_VERSION
} = $ExtUtils::MakeMaker
::VERSION
;
$self->{MM_REVISION
}= $ExtUtils::MakeMaker
::Revision
;
$self->{VERSION_FROM
} ||= '';
if ($self->{VERSION_FROM
}){
$self->{VERSION
} = $self->parse_version($self->{VERSION_FROM
});
if( $self->{VERSION
} eq 'undef' ) {
Carp
::carp
("WARNING: Setting VERSION via file ".
"'$self->{VERSION_FROM}' failed\n");
if (defined $self->{VERSION
}) {
$self->{VERSION
} =~ s/^\s+//;
$self->{VERSION
} =~ s/\s+$//;
$self->{VERSION_MACRO
} = 'VERSION';
($self->{VERSION_SYM
} = $self->{VERSION
}) =~ s/\W/_/g;
$self->{DEFINE_VERSION
} = '-D$(VERSION_MACRO)=\"$(VERSION)\"';
# Graham Barr and Paul Marquess had some ideas how to ensure
# version compatibility between the *.pm file and the
# corresponding *.xs file. The bottomline was, that we need an
# XS_VERSION macro that defaults to VERSION:
$self->{XS_VERSION
} ||= $self->{VERSION
};
$self->{XS_VERSION_MACRO
} = 'XS_VERSION';
$self->{XS_DEFINE_VERSION
} = '-D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"';
=head3 init_others I<Abstract>
Initializes the macro definitions used by tools_other() and places them
If there is no description, its the same as the parameter to
WriteMakefile() documented in ExtUtils::MakeMaker.
Defines at least these macros.
NOECHO Tell make not to display the command itself
MAKE_APERL_FILE File used by MAKE_APERL
SHELL Program used to run
ECHO Print text adding a newline on the end
TOUCH Update a file's timestamp
TEST_F Test for a file's existence
CHMOD Change permissions on a
DEV_NULL Supress all command output
=head3 init_DIRFILESEP I<Abstract>
my $dirfilesep = $MM->{DIRFILESEP};
Initializes the DIRFILESEP macro which is the seperator between the
directory and filename in a filepath. ie. / on Unix, \ on Win32 and
# instead of $(INST_ARCHAUTODIR)/extralibs.ld
$(INST_ARCHAUTODIR)$(DIRFILESEP)extralibs.ld
Something of a hack but it prevents a lot of code duplication between
Do not use this as a seperator between directories. Some operating
systems use different seperators between subdirectories as between
directories and filenames (for example: VOLUME:[dir1.dir2]file on VMS).
=head3 init_linker I<Abstract>
Initialize macros which have to do with linking.
PERL_ARCHIVE: path to libperl.a equivalent to be linked to dynamic
PERL_ARCHIVE_AFTER: path to a library which should be put on the
linker command line I<after> the external libraries to be linked to
dynamic extensions. This may be needed if the linker is one-pass, and
Perl includes some overrides for C RTL functions, such as malloc().
EXPORT_LIST: name of a file that is passed to linker to define symbols
Some OSes do not need these in which case leave it blank.
Initialize any macros which are for platform specific use only.
A typical one is the version number of your OS specific mocule.
(ie. MM_Unix_VERSION or MM_VMS_VERSION).
A grab bag of methods to generate specific macros and commands.
Defines targets and routines to translate the pods into manpages and
put them into the INST_* directories.
my $POD2MAN_macro = $self->POD2MAN_macro();
my $manifypods_target = $self->manifypods_target();
my $pod2man_macro = $self->POD2MAN_macro
Returns a definition for the POD2MAN macro. This is a program
which emulates the pod2man utility. You can add more switches to the
command by simply appending them on the macro.
$(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...
# Need the trailing '--' so perl stops gobbling arguments and - happens
# to be an alternative end of line seperator on VMS so we quote it
POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"
my $command = $mm->test_via_harness($perl, $tests);
Returns a $command line which runs the given set of $tests with
Test::Harness and the given $perl.
my($self, $perl, $tests) = @_;
return qq{\t$perl "-MExtUtils::Command::MM" }.
qq{"-e" "test_harness(\$(TEST_VERBOSE), '\$(INST_LIB)', '\$(INST_ARCHLIB)')" $tests\n};
my $command = $mm->test_via_script($perl, $script);
Returns a $command line which just runs a single test without
Test::Harness. No checks are done on the results, they're just
Used for test.pl, since they don't always follow Test::Harness
my($self, $perl, $script) = @_;
return qq{\t$perl "-I\$(INST_LIB)" "-I\$(INST_ARCHLIB)" $script\n};
Defines a simple perl call that runs autosplit. May be deprecated by
my($self, %attribs) = @_;
my $maxlen = $attribs{MAXLEN} ? '$$AutoSplit::Maxlen=$attribs{MAXLEN};'
my $asplit = $self->oneliner(sprintf <<'PERL_CODE', $maxlen);
use AutoSplit; %s autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)
return sprintf <<'MAKE_FRAG', $asplit;
# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
=head2 File::Spec wrappers
ExtUtils::MM_Any is a subclass of File::Spec. The methods noted here
File::Spec <= 0.83 has a bug where the file part of catfile is not
canonicalized. This override fixes that bug.
return $self->canonpath($self->SUPER::catfile(@_));
Methods I can't really figure out where they should go yet.
my $test = $mm->find_tests;
Returns a string suitable for feeding to the shell to return all
return -d 't' ? 't/*.t' : '';
my @files_to_clean = $MM->extra_clean_files;
Returns a list of OS specific files to be removed in the clean target in
addition to the usual set.
# An empty method here tickled a perl 5.8.1 bug and would return its object.
my @installvars = $mm->installvars;
A list of all the INSTALL* variables without the INSTALL prefix. Useful
for iteration or building related variable sets.
return qw(PRIVLIB SITELIB VENDORLIB
ARCHLIB SITEARCH VENDORARCH
MAN1DIR SITEMAN1DIR VENDORMAN1DIR
MAN3DIR SITEMAN3DIR VENDORMAN3DIR
my $wanted = $self->libscan($path);
Takes a path to a file or dir and returns an empty string if we don't
want to include this file in the library. Otherwise it returns the
Mainly used to exclude version control administrative directories from
my($dirs,$file) = ($self->splitpath($path))[1,2];
return '' if grep /^(?:RCS|CVS|SCCS|\.svn|_darcs)$/,
$self->splitdir($dirs), $file;
=head3 platform_constants
my $make_frag = $mm->platform_constants
Returns a make fragment defining all the macros initialized in
init_platform() rather than put them in constants().
Michael G Schwern <schwern@pobox.com> and the denizens of
makemaker@perl.org with code from ExtUtils::MM_Unix and