1 # The perl/C checking voodoo is mostly stolen from Graham Barr's
2 # Scalar-List-Utils distribution.
6 use ExtUtils::MakeMaker;
7 use Config qw(%Config);
10 # If undefined, try our best, if true, require XS, if false, never do
15 /^--pm/ and $force_xs = 0;
16 /^--xs/ and $force_xs = 1;
19 my $has_compiler = $force_xs;
20 unless ( defined $force_xs ) {
21 $has_compiler = check_for_compiler()
26 'Scalar::Util' => '1.18',
27 'Sub::Name' => '0.02',
28 'Sub::Identify' => '0.03',
29 'MRO::Compat' => '0.05',
31 'Devel::GlobalDestruction' => 0,
34 delete @prereqs{qw(Sub::Name Devel::GlobalDestruction)}
40 my $ccflags = -d '.svn' || $ENV{MAINTAINER_MODE} ? '-Wall' : '';
43 VERSION_FROM => 'lib/Class/MOP.pm',
45 PREREQ_PM => \%prereqs,
48 clean => { FILES => 'test.c test.o' },
49 ABSTRACT_FROM => 'lib/Class/MOP.pm',
50 AUTHOR => 'Stevan Little <stevan@iinteractive.com>',
58 I cannot determine if you have a C compiler
59 so I will install a perl-only implementation
61 You can force installation of the XS version with
68 sub check_for_compiler {
69 print "Testing if you have a C compiler\n";
71 eval { require ExtUtils::CBuilder };
73 return _check_for_compiler_manually();
76 return _check_for_compiler_with_cbuilder();
80 sub _check_for_compiler_with_cbuilder {
81 my $cb = ExtUtils::CBuilder->new( quiet => 1 );
83 return $cb->have_compiler();
86 sub _check_for_compiler_manually {
87 unless ( open F, '>', 'test.c' ) {
89 "Cannot write test.c, skipping test compilation and installing pure Perl version.\n";
94 int main() { return 0; }
100 if ( $cc =~ /cl(\.exe)?$/ ) {
102 # stupid stupid MSVC compiler hack tacken from version.pm's
104 $cc .= ' -c'; # prevent it from calling the linker
107 system("$cc -o test$Config{obj_ext} test.c") and return 0;
109 unlink $_ for grep {-f} 'test.c', "test$Config{obj_ext}";
114 # This is EUMM voodoo
118 unless ($has_compiler) {
119 @{$hash}{ 'XS', 'C' } = ( {}, [] );