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