This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
e310c6fd09632ef572fc5cdc2a0dace6170149ad
[perl5.git] / cpan / ExtUtils-MakeMaker / lib / ExtUtils / MM.pm
1 package ExtUtils::MM;
2
3 use strict;
4 use ExtUtils::MakeMaker::Config;
5
6 our $VERSION = '6.70';
7
8 require ExtUtils::Liblist;
9 require ExtUtils::MakeMaker;
10 our @ISA = qw(ExtUtils::Liblist ExtUtils::MakeMaker);
11
12 =head1 NAME
13
14 ExtUtils::MM - OS adjusted ExtUtils::MakeMaker subclass
15
16 =head1 SYNOPSIS
17
18   require ExtUtils::MM;
19   my $mm = MM->new(...);
20
21 =head1 DESCRIPTION
22
23 B<FOR INTERNAL USE ONLY>
24
25 ExtUtils::MM is a subclass of ExtUtils::MakeMaker which automatically
26 chooses the appropriate OS specific subclass for you
27 (ie. ExtUils::MM_Unix, etc...).
28
29 It also provides a convenient alias via the MM class (I didn't want
30 MakeMaker modules outside of ExtUtils/).
31
32 This class might turn out to be a temporary solution, but MM won't go
33 away.
34
35 =cut
36
37 {
38     # Convenient alias.
39     package MM;
40     our @ISA = qw(ExtUtils::MM);
41     sub DESTROY {}
42 }
43
44 sub _is_win95 {
45     # miniperl might not have the Win32 functions available and we need
46     # to run in miniperl.
47     my $have_win32 = eval { require Win32 };
48     return $have_win32 && defined &Win32::IsWin95 ? Win32::IsWin95()
49                                                   : ! defined $ENV{SYSTEMROOT};
50 }
51
52 my %Is = ();
53 $Is{VMS}    = $^O eq 'VMS';
54 $Is{OS2}    = $^O eq 'os2';
55 $Is{MacOS}  = $^O eq 'MacOS';
56 if( $^O eq 'MSWin32' ) {
57     _is_win95() ? $Is{Win95} = 1 : $Is{Win32} = 1;
58 }
59 $Is{UWIN}   = $^O =~ /^uwin(-nt)?$/;
60 $Is{Cygwin} = $^O eq 'cygwin';
61 $Is{NW5}    = $Config{osname} eq 'NetWare';  # intentional
62 $Is{BeOS}   = ($^O =~ /beos/i or $^O eq 'haiku');
63 $Is{DOS}    = $^O eq 'dos';
64 if( $Is{NW5} ) {
65     $^O = 'NetWare';
66     delete $Is{Win32};
67 }
68 $Is{VOS}    = $^O eq 'vos';
69 $Is{QNX}    = $^O eq 'qnx';
70 $Is{AIX}    = $^O eq 'aix';
71 $Is{Darwin} = $^O eq 'darwin';
72
73 $Is{Unix}   = !grep { $_ } values %Is;
74
75 map { delete $Is{$_} unless $Is{$_} } keys %Is;
76 _assert( keys %Is == 1 );
77 my($OS) = keys %Is;
78
79
80 my $class = "ExtUtils::MM_$OS";
81 eval "require $class" unless $INC{"ExtUtils/MM_$OS.pm"}; ## no critic
82 die $@ if $@;
83 unshift @ISA, $class;
84
85
86 sub _assert {
87     my $sanity = shift;
88     die sprintf "Assert failed at %s line %d\n", (caller)[1,2] unless $sanity;
89     return;
90 }