xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/ExtUtils/MM.pm (revision 0:68f95e015346)
1*0Sstevel@tonic-gatepackage ExtUtils::MM;
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateuse strict;
4*0Sstevel@tonic-gateuse Config;
5*0Sstevel@tonic-gateuse vars qw(@ISA $VERSION);
6*0Sstevel@tonic-gate$VERSION = 0.04;
7*0Sstevel@tonic-gate
8*0Sstevel@tonic-gaterequire ExtUtils::Liblist;
9*0Sstevel@tonic-gaterequire ExtUtils::MakeMaker;
10*0Sstevel@tonic-gate
11*0Sstevel@tonic-gate@ISA = qw(ExtUtils::Liblist ExtUtils::MakeMaker);
12*0Sstevel@tonic-gate
13*0Sstevel@tonic-gate=head1 NAME
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gateExtUtils::MM - OS adjusted ExtUtils::MakeMaker subclass
16*0Sstevel@tonic-gate
17*0Sstevel@tonic-gate=head1 SYNOPSIS
18*0Sstevel@tonic-gate
19*0Sstevel@tonic-gate  require ExtUtils::MM;
20*0Sstevel@tonic-gate  my $mm = MM->new(...);
21*0Sstevel@tonic-gate
22*0Sstevel@tonic-gate=head1 DESCRIPTION
23*0Sstevel@tonic-gate
24*0Sstevel@tonic-gateB<FOR INTERNAL USE ONLY>
25*0Sstevel@tonic-gate
26*0Sstevel@tonic-gateExtUtils::MM is a subclass of ExtUtils::MakeMaker which automatically
27*0Sstevel@tonic-gatechooses the appropriate OS specific subclass for you
28*0Sstevel@tonic-gate(ie. ExtUils::MM_Unix, etc...).
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gateIt also provides a convenient alias via the MM class (I didn't want
31*0Sstevel@tonic-gateMakeMaker modules outside of ExtUtils/).
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gateThis class might turn out to be a temporary solution, but MM won't go
34*0Sstevel@tonic-gateaway.
35*0Sstevel@tonic-gate
36*0Sstevel@tonic-gate=cut
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gate{
39*0Sstevel@tonic-gate    # Convenient alias.
40*0Sstevel@tonic-gate    package MM;
41*0Sstevel@tonic-gate    use vars qw(@ISA);
42*0Sstevel@tonic-gate    @ISA = qw(ExtUtils::MM);
43*0Sstevel@tonic-gate    sub DESTROY {}
44*0Sstevel@tonic-gate}
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gatemy %Is = ();
47*0Sstevel@tonic-gate$Is{VMS}    = 1 if $^O eq 'VMS';
48*0Sstevel@tonic-gate$Is{OS2}    = 1 if $^O eq 'os2';
49*0Sstevel@tonic-gate$Is{MacOS}  = 1 if $^O eq 'MacOS';
50*0Sstevel@tonic-gateif( $^O eq 'MSWin32' ) {
51*0Sstevel@tonic-gate    Win32::IsWin95() ? $Is{Win95} = 1 : $Is{Win32} = 1;
52*0Sstevel@tonic-gate}
53*0Sstevel@tonic-gate$Is{UWIN}   = 1 if $^O eq 'uwin';
54*0Sstevel@tonic-gate$Is{Cygwin} = 1 if $^O eq 'cygwin';
55*0Sstevel@tonic-gate$Is{NW5}    = 1 if $Config{osname} eq 'NetWare';  # intentional
56*0Sstevel@tonic-gate$Is{BeOS}   = 1 if $^O =~ /beos/i;    # XXX should this be that loose?
57*0Sstevel@tonic-gate$Is{DOS}    = 1 if $^O eq 'dos';
58*0Sstevel@tonic-gate
59*0Sstevel@tonic-gate$Is{Unix}   = 1 if !keys %Is;
60*0Sstevel@tonic-gate
61*0Sstevel@tonic-gateif( $Is{NW5} ) {
62*0Sstevel@tonic-gate    $^O = 'NetWare';
63*0Sstevel@tonic-gate    delete $Is{Win32};
64*0Sstevel@tonic-gate}
65*0Sstevel@tonic-gate
66*0Sstevel@tonic-gate_assert( keys %Is == 1 );
67*0Sstevel@tonic-gatemy($OS) = keys %Is;
68*0Sstevel@tonic-gate
69*0Sstevel@tonic-gate
70*0Sstevel@tonic-gatemy $class = "ExtUtils::MM_$OS";
71*0Sstevel@tonic-gateeval "require $class" unless $INC{"ExtUtils/MM_$OS.pm"};
72*0Sstevel@tonic-gatedie $@ if $@;
73*0Sstevel@tonic-gateunshift @ISA, $class;
74*0Sstevel@tonic-gate
75*0Sstevel@tonic-gate
76*0Sstevel@tonic-gatesub _assert {
77*0Sstevel@tonic-gate    my $sanity = shift;
78*0Sstevel@tonic-gate    die sprintf "Assert failed at %s line %d\n", (caller)[1,2] unless $sanity;
79*0Sstevel@tonic-gate    return;
80*0Sstevel@tonic-gate}
81