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);
12 # If undefined, try our best, if true, require XS, if false, never do
17 /^--pm/ and $force_xs = 0;
18 /^--xs/ and $force_xs = 1;
21 my $has_compiler = $force_xs;
22 unless ( defined $force_xs ) {
23 $has_compiler = check_for_compiler()
28 'Scalar::Util' => '1.18',
29 'Sub::Name' => '0.04',
30 'Sub::Identify' => '0.03',
31 'MRO::Compat' => '0.05',
33 'Test::Exception' => '0',
36 'Devel::GlobalDestruction' => '0',
39 delete @prereqs{qw(Sub::Name Devel::GlobalDestruction)}
45 my $ccflags = -d '.svn' || $ENV{MAINTAINER_MODE} ? '-Wall' : '';
48 VERSION_FROM => 'lib/Class/MOP.pm',
50 PREREQ_PM => \%prereqs,
53 clean => { FILES => 'test.c test.o' },
54 ABSTRACT_FROM => 'lib/Class/MOP.pm',
55 AUTHOR => 'Stevan Little <stevan@iinteractive.com>',
63 I cannot determine if you have a C compiler
64 so I will install a perl-only implementation
66 You can force installation of the XS version with
73 sub check_for_compiler {
74 print "Testing if you have a C compiler\n";
76 eval { require ExtUtils::CBuilder };
78 return _check_for_compiler_manually();
81 return _check_for_compiler_with_cbuilder();
85 sub _check_for_compiler_with_cbuilder {
86 my $cb = ExtUtils::CBuilder->new( quiet => 1 );
88 return $cb->have_compiler();
91 sub _check_for_compiler_manually {
92 unless ( open F, '>', 'test.c' ) {
94 "Cannot write test.c, skipping test compilation and installing pure Perl version.\n";
99 int main() { return 0; }
104 my $cc = $Config{cc};
105 if ( $cc =~ /cl(\.exe)?$/ ) {
107 # stupid stupid MSVC compiler hack tacken from version.pm's
109 $cc .= ' -c'; # prevent it from calling the linker
112 system("$cc -o test$Config{obj_ext} test.c") and return 0;
114 unlink $_ for grep {-f} 'test.c', "test$Config{obj_ext}";
119 # This is EUMM voodoo
123 unless ($has_compiler) {
124 @{$hash}{ 'XS', 'C' } = ( {}, [] );