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