summaryrefslogtreecommitdiff
path: root/lib/ExtUtils/MM.pm
blob: 2c23263c9ca8702f74333a5441c5bd7dbd53dd14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package ExtUtils::MM;

use strict;
use Config;
use vars qw(@ISA $VERSION);
$VERSION = 0.04;

require ExtUtils::Liblist;
require ExtUtils::MakeMaker;

@ISA = qw(ExtUtils::Liblist ExtUtils::MakeMaker);

=head1 NAME

ExtUtils::MM - OS adjusted ExtUtils::MakeMaker subclass

=head1 SYNOPSIS

  require ExtUtils::MM;
  my $mm = MM->new(...);

=head1 DESCRIPTION

B<FOR INTERNAL USE ONLY>

ExtUtils::MM is a subclass of ExtUtils::MakeMaker which automatically
chooses the appropriate OS specific subclass for you
(ie. ExtUils::MM_Unix, etc...).

It also provides a convenient alias via the MM class (I didn't want
MakeMaker modules outside of ExtUtils/).

This class might turn out to be a temporary solution, but MM won't go
away.

=cut

{
    # Convenient alias.
    package MM;
    use vars qw(@ISA);
    @ISA = qw(ExtUtils::MM);
    sub DESTROY {}
}

my %Is = ();
$Is{VMS}    = 1 if $^O eq 'VMS';
$Is{OS2}    = 1 if $^O eq 'os2';
$Is{MacOS}  = 1 if $^O eq 'MacOS';
if( $^O eq 'MSWin32' ) {
    Win32::IsWin95() ? $Is{Win95} = 1 : $Is{Win32} = 1;
}
$Is{UWIN}   = 1 if $^O eq 'uwin';
$Is{Cygwin} = 1 if $^O eq 'cygwin';
$Is{NW5}    = 1 if $Config{osname} eq 'NetWare';  # intentional
$Is{BeOS}   = 1 if $^O =~ /beos/i;    # XXX should this be that loose?
$Is{DOS}    = 1 if $^O eq 'dos';

$Is{Unix}   = 1 if !keys %Is;

if( $Is{NW5} ) {
    $^O = 'NetWare';
    delete $Is{Win32};
}

_assert( keys %Is == 1 );
my($OS) = keys %Is;


my $class = "ExtUtils::MM_$OS";
eval "require $class" unless $INC{"ExtUtils/MM_$OS.pm"};
die $@ if $@;
unshift @ISA, $class;


sub _assert {
    my $sanity = shift;
    die sprintf "Assert failed at %s line %d\n", (caller)[1,2] unless $sanity;
    return;
}