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()
28 my $ccflags = -d '.svn' || $ENV{MAINTAINER_MODE} ? '-Wall' : '';
31 VERSION_FROM => 'lib/Class/MOP.pm',
34 'Scalar::Util' => '1.18',
35 'Sub::Name' => '0.02',
36 'Sub::Identify' => '0.03',
37 'MRO::Compat' => '0.05',
42 clean => { FILES => 'test.c test.o' },
43 ABSTRACT_FROM => 'lib/Class/MOP.pm',
44 AUTHOR => 'Stevan Little <stevan@iinteractive.com>',
52 I cannot determine if you have a C compiler
53 so I will install a perl-only implementation
55 You can force installation of the XS version with
62 sub check_for_compiler {
63 print "Testing if you have a C compiler\n";
65 eval { require ExtUtils::CBuilder };
67 return _check_for_compiler_manually();
70 return _check_for_compiler_with_cbuilder();
74 sub _check_for_compiler_with_cbuilder {
75 my $cb = ExtUtils::CBuilder->new( quiet => 1 );
77 return $cb->have_compiler();
80 sub _check_for_compiler_manually {
81 unless ( open F, '>', 'test.c' ) {
83 "Cannot write test.c, skipping test compilation and installing pure Perl version.\n";
88 int main() { return 0; }
94 if ( $cc =~ /cl(\.exe)?$/ ) {
96 # stupid stupid MSVC compiler hack tacken from version.pm's
98 $cc .= ' -c'; # prevent it from calling the linker
101 system("$cc -o test$Config{obj_ext} test.c") and return 0;
103 unlink $_ for grep {-f} 'test.c', "test$Config{obj_ext}";
108 # This is EUMM voodoo
112 unless ($has_compiler) {
113 @{$hash}{ 'XS', 'C' } = ( {}, [] );