use strict;
use vars qw($VERSION @ISA);
-$VERSION = 0.04;
+$VERSION = 0.07;
@ISA = qw(File::Spec);
use Config;
These are methods which are by their nature cross-platform and should
always be cross-platform.
+=over 4
+
+=item installvars
+
+ my @installvars = $mm->installvars;
+
+A list of all the INSTALL* variables without the INSTALL prefix. Useful
+for iteration or building related variable sets.
+
+=cut
+
+sub installvars {
+ return qw(PRIVLIB SITELIB VENDORLIB
+ ARCHLIB SITEARCH VENDORARCH
+ BIN SITEBIN VENDORBIN
+ SCRIPT
+ MAN1DIR SITEMAN1DIR VENDORMAN1DIR
+ MAN3DIR SITEMAN3DIR VENDORMAN3DIR
+ );
+}
+
+=item os_flavor_is
+
+ $mm->os_flavor_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') ) {
+ $out = `foo 2>&1`;
+ }
+ else {
+ $out = `foo`;
+ }
+
+=cut
+
+sub os_flavor_is {
+ my $self = shift;
+ my %flavors = map { ($_ => 1) } $self->os_flavor;
+ return (grep { $flavors{$_} } @_) ? 1 : 0;
+}
+
+=back
+
=head2 File::Spec wrappers
ExtUtils::MM_Any is a subclass of File::Spec. The methods noted here
sub init_VERSION {
my($self) = shift;
- $self->{MAKEMAKER} = $INC{'ExtUtils/MakeMaker.pm'};
+ $self->{MAKEMAKER} = $ExtUtils::MakeMaker::Filename;
$self->{MM_VERSION} = $ExtUtils::MakeMaker::VERSION;
$self->{MM_REVISION}= $ExtUtils::MakeMaker::Revision;
$self->{VERSION_FROM} ||= '';
sub manifypods {
my $self = shift;
- my $POD2MAN_EXE_macro = $self->POD2MAN_EXE_macro();
+ my $POD2MAN_macro = $self->POD2MAN_macro();
my $manifypods_target = $self->manifypods_target();
return <<END_OF_TARGET;
-# --- Begin manifypods section:
-$POD2MAN_EXE_macro
+$POD2MAN_macro
$manifypods_target
-# --- End manifypods section --- #
-
END_OF_TARGET
}
foreach my $section (qw(1 3)) {
my $pods = $self->{"MAN${section}PODS"};
push @man_cmds, $self->split_command(<<CMD, %$pods);
- \$(NOECHO) \$(POD2MAN_EXE) --section=$section --perm_rw=\$(PERM_RW)
+ \$(NOECHO) \$(POD2MAN) --section=$section --perm_rw=\$(PERM_RW)
CMD
}
+ $manify .= "\t\$(NOECHO) \$(NOOP)\n" unless @man_cmds;
$manify .= join '', map { "$_\n" } @man_cmds;
return $manify;
return $make_frag;
}
-=item POD2MAN_EXE_macro
+=item POD2MAN_macro
- my $pod2man_exe_macro = $self->POD2MAN_EXE_macro
+ my $pod2man_macro = $self->POD2MAN_macro
-Returns a definition for the POD2MAN_EXE macro. This is a program
+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.
Typical usage:
- $(POD2MAN_EXE) --section=3 --perm_rw=$(PERM_RW) podfile man_page
+ $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...
=cut
-sub POD2MAN_EXE_macro {
+sub POD2MAN_macro {
my $self = shift;
# Need the trailing '--' so perl stops gobbling arguments and - happens
# to be an alternative end of line seperator on VMS so we quote it
return <<'END_OF_DEF';
POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"
+POD2MAN = $(POD2MAN_EXE)
END_OF_DEF
}
sub libscan {
my($self,$path) = @_;
my($dirs,$file) = ($self->splitpath($path))[1,2];
- return '' if grep /^RCS|CVS|SCCS|\.svn$/,
+ return '' if grep /^(?:RCS|CVS|SCCS|\.svn)$/,
$self->splitdir($dirs), $file;
return $path;
sub metafile_target {
my $self = shift;
+ return <<'MAKE_FRAG' if $self->{NO_META};
+metafile:
+ $(NOECHO) $(NOOP)
+MAKE_FRAG
+
my $prereq_pm = '';
- while( my($mod, $ver) = each %{$self->{PREREQ_PM}} ) {
+ 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;
}
my $meta = <<YAML;
+# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: $self->{DISTNAME}
version: $self->{VERSION}
sub metafile_addtomanifest_target {
my $self = shift;
+ return <<'MAKE_FRAG' if $self->{NO_META};
+metafile_addtomanifest:
+ $(NOECHO) $(NOOP)
+MAKE_FRAG
+
my $add_meta = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
-maniadd({q{META.yml} => q{Module meta-data in YAML}});
+eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) }
+ or print "Could not add META.yml to MANIFEST: $${'@'}\n"
CODE
return sprintf <<'MAKE_FRAG', $add_meta;
Macro Description
- NOOP
- NOECHO
+ NOOP Do nothing
+ NOECHO Tell make not to display the command itself
MAKEFILE
FIRST_MAKEFILE
SHELL Program used to run
shell commands
+ ECHO Print text adding a newline on the end
RM_F Remove a file
RM_RF Remove a directory
TOUCH Update a file's timestamp
return '';
}
+=item os_flavor
+
+ 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, MacOS, etc...) and the rest are sub families.
+
+Some examples:
+
+ Cygwin98 ('Unix', 'Cygwin', 'Cygwin9x')
+ Windows NT ('Win32', 'WinNT')
+ Win98 ('Win32', 'Win9x')
+ Linux ('Unix', 'Linux')
+ MacOS Classic ('MacOS', 'MacOS Classic')
+ MacOS X ('Unix', 'Darwin', 'MacOS', 'MacOS X')
+ OS/2 ('OS/2')
+
+This is used to write code for styles of operating system.
+See os_flavor_is() for use.
+
=back