Commit | Line | Data |
---|---|---|
f6d6199c MS |
1 | package ExtUtils::MM; |
2 | ||
3 | use strict; | |
7292dc67 | 4 | use ExtUtils::MakeMaker::Config; |
a592ba15 | 5 | |
a8509e91 | 6 | our $VERSION = '6.94'; |
f6d6199c MS |
7 | |
8 | require ExtUtils::Liblist; | |
9 | require ExtUtils::MakeMaker; | |
a592ba15 | 10 | our @ISA = qw(ExtUtils::Liblist ExtUtils::MakeMaker); |
f6d6199c MS |
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; | |
a592ba15 | 40 | our @ISA = qw(ExtUtils::MM); |
f6d6199c MS |
41 | sub DESTROY {} |
42 | } | |
43 | ||
c8d65f10 RGS |
44 | sub _is_win95 { |
45 | # miniperl might not have the Win32 functions available and we need | |
46 | # to run in miniperl. | |
75e3c8a3 DM |
47 | my $have_win32 = eval { require Win32 }; |
48 | return $have_win32 && defined &Win32::IsWin95 ? Win32::IsWin95() | |
49 | : ! defined $ENV{SYSTEMROOT}; | |
c8d65f10 RGS |
50 | } |
51 | ||
f6d6199c | 52 | my %Is = (); |
5dca256e RGS |
53 | $Is{VMS} = $^O eq 'VMS'; |
54 | $Is{OS2} = $^O eq 'os2'; | |
55 | $Is{MacOS} = $^O eq 'MacOS'; | |
f6d6199c | 56 | if( $^O eq 'MSWin32' ) { |
c8d65f10 | 57 | _is_win95() ? $Is{Win95} = 1 : $Is{Win32} = 1; |
f6d6199c | 58 | } |
5dca256e RGS |
59 | $Is{UWIN} = $^O =~ /^uwin(-nt)?$/; |
60 | $Is{Cygwin} = $^O eq 'cygwin'; | |
61 | $Is{NW5} = $Config{osname} eq 'NetWare'; # intentional | |
1487aac6 | 62 | $Is{BeOS} = ($^O =~ /beos/i or $^O eq 'haiku'); |
5dca256e | 63 | $Is{DOS} = $^O eq 'dos'; |
f6d6199c MS |
64 | if( $Is{NW5} ) { |
65 | $^O = 'NetWare'; | |
66 | delete $Is{Win32}; | |
67 | } | |
7292dc67 RGS |
68 | $Is{VOS} = $^O eq 'vos'; |
69 | $Is{QNX} = $^O eq 'qnx'; | |
70 | $Is{AIX} = $^O eq 'aix'; | |
a592ba15 | 71 | $Is{Darwin} = $^O eq 'darwin'; |
7292dc67 | 72 | |
5dca256e | 73 | $Is{Unix} = !grep { $_ } values %Is; |
f6d6199c | 74 | |
5dca256e | 75 | map { delete $Is{$_} unless $Is{$_} } keys %Is; |
f6d6199c MS |
76 | _assert( keys %Is == 1 ); |
77 | my($OS) = keys %Is; | |
78 | ||
79 | ||
80 | my $class = "ExtUtils::MM_$OS"; | |
a592ba15 | 81 | eval "require $class" unless $INC{"ExtUtils/MM_$OS.pm"}; ## no critic |
f6d6199c MS |
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 | } |