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',
33 delete $prereqs{'Sub::Name'}
39 my $ccflags = -d '.svn' || $ENV{MAINTAINER_MODE} ? '-Wall' : '';
42 VERSION_FROM => 'lib/Class/MOP.pm',
44 PREREQ_PM => \%prereqs,
47 clean => { FILES => 'test.c test.o' },
48 ABSTRACT_FROM => 'lib/Class/MOP.pm',
49 AUTHOR => 'Stevan Little <stevan@iinteractive.com>',
57 I cannot determine if you have a C compiler
58 so I will install a perl-only implementation
60 You can force installation of the XS version with
67 sub check_for_compiler {
68 print "Testing if you have a C compiler\n";
70 eval { require ExtUtils::CBuilder };
72 return _check_for_compiler_manually();
75 return _check_for_compiler_with_cbuilder();
79 sub _check_for_compiler_with_cbuilder {
80 my $cb = ExtUtils::CBuilder->new( quiet => 1 );
82 return $cb->have_compiler();
85 sub _check_for_compiler_manually {
86 unless ( open F, '>', 'test.c' ) {
88 "Cannot write test.c, skipping test compilation and installing pure Perl version.\n";
93 int main() { return 0; }
99 if ( $cc =~ /cl(\.exe)?$/ ) {
101 # stupid stupid MSVC compiler hack tacken from version.pm's
103 $cc .= ' -c'; # prevent it from calling the linker
106 system("$cc -o test$Config{obj_ext} test.c") and return 0;
108 unlink $_ for grep {-f} 'test.c', "test$Config{obj_ext}";
113 # This is EUMM voodoo
117 unless ($has_compiler) {
118 @{$hash}{ 'XS', 'C' } = ( {}, [] );