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()
27 'Scalar::Util' => '1.18',
28 'Sub::Name' => '0.04',
29 'Sub::Identify' => '0.03',
30 'MRO::Compat' => '0.05',
32 'Devel::GlobalDestruction' => 0,
35 delete @prereqs{qw(Sub::Name Devel::GlobalDestruction)}
41 my $ccflags = -d '.svn' || $ENV{MAINTAINER_MODE} ? '-Wall' : '';
44 VERSION_FROM => 'lib/Class/MOP.pm',
46 PREREQ_PM => \%prereqs,
49 clean => { FILES => 'test.c test.o' },
50 ABSTRACT_FROM => 'lib/Class/MOP.pm',
51 AUTHOR => 'Stevan Little <stevan@iinteractive.com>',
59 I cannot determine if you have a C compiler
60 so I will install a perl-only implementation
62 You can force installation of the XS version with
69 sub check_for_compiler {
70 print "Testing if you have a C compiler\n";
72 eval { require ExtUtils::CBuilder };
74 return _check_for_compiler_manually();
77 return _check_for_compiler_with_cbuilder();
81 sub _check_for_compiler_with_cbuilder {
82 my $cb = ExtUtils::CBuilder->new( quiet => 1 );
84 return $cb->have_compiler();
87 sub _check_for_compiler_manually {
88 unless ( open F, '>', 'test.c' ) {
90 "Cannot write test.c, skipping test compilation and installing pure Perl version.\n";
95 int main() { return 0; }
100 my $cc = $Config{cc};
101 if ( $cc =~ /cl(\.exe)?$/ ) {
103 # stupid stupid MSVC compiler hack tacken from version.pm's
105 $cc .= ' -c'; # prevent it from calling the linker
108 system("$cc -o test$Config{obj_ext} test.c") and return 0;
110 unlink $_ for grep {-f} 'test.c', "test$Config{obj_ext}";
115 # This is EUMM voodoo
119 unless ($has_compiler) {
120 @{$hash}{ 'XS', 'C' } = ( {}, [] );