ExtUtils::MakeMaker 6.10_06 (plus FAQ update)
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_Any.pm
index 20c6bd6..f7cb4e8 100644 (file)
@@ -2,7 +2,7 @@ package ExtUtils::MM_Any;
 
 use strict;
 use vars qw($VERSION @ISA);
-$VERSION = 0.04;
+$VERSION = 0.06;
 @ISA = qw(File::Spec);
 
 use Config;
@@ -42,6 +42,34 @@ B<THIS MAY BE TEMPORARY!>
 These are methods which are by their nature cross-platform and should
 always be cross-platform.
 
+=over 4
+
+=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
@@ -213,7 +241,7 @@ Called by init_main.
 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} ||= '';
@@ -333,6 +361,7 @@ END
 CMD
     }
 
+    $manify .= "\t\$(NOECHO) \$(NOOP)\n" unless @man_cmds;
     $manify .= join '', map { "$_\n" } @man_cmds;
 
     return $manify;
@@ -528,6 +557,11 @@ include:
 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}} ) {
         $prereq_pm .= sprintf "    %-30s %s\n", "$mod:", $ver;
@@ -565,8 +599,14 @@ Adds the META.yml file to the MANIFEST.
 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;
@@ -665,8 +705,8 @@ Defines at least these macros.
 
   Macro             Description
 
-  NOOP              
-  NOECHO                                        
+  NOOP              Do nothing
+  NOECHO            Tell make not to display the command itself
 
   MAKEFILE
   FIRST_MAKEFILE
@@ -676,6 +716,7 @@ Defines at least these macros.
   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   
@@ -755,6 +796,29 @@ sub platform_constants {
     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