X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=Makefile.PL;h=a872582be71c84f2e053b7ae6ffe8a5efbd6dd85;hb=e347ce3fe9e40dc060e73e07f282729f4191c878;hp=4fdf33563cdcb7efb39165f3175714c004194148;hpb=9ad4163c74cdbbaf9d1026ab3c0de31baaff32dd;p=gitmo%2FClass-MOP.git diff --git a/Makefile.PL b/Makefile.PL index 4fdf335..a872582 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,123 +1,121 @@ -# The perl/C checking voodoo is mostly stolen from Graham Barr's -# Scalar-List-Utils distribution. use strict; use warnings; +use inc::Module::Install; +use 5.008001; -use ExtUtils::MakeMaker; -use Config qw(%Config); -use File::Spec; +check_conflicts(); -# If undefined, try our best, if true, require XS, if false, never do -# XS -my $force_xs; +name 'Class-MOP'; +perl_version '5.008001'; +all_from 'lib/Class/MOP.pm'; +license 'perl'; -for (@ARGV) { - /^--pm/ and $force_xs = 0; - /^--xs/ and $force_xs = 1; -} - -my $has_compiler = $force_xs; -unless ( defined $force_xs ) { - $has_compiler = check_for_compiler() - or no_cc(); -} - -my %prereqs = ( - 'Scalar::Util' => '1.18', - 'Sub::Name' => '0.02', - 'Sub::Identify' => '0.03', - 'MRO::Compat' => '0.05', - 'Carp' => 0, - 'Devel::GlobalDestruction' => 0, -); - -delete @prereqs{qw(Sub::Name Devel::GlobalDestruction)} - unless $has_compiler; - -write_makefile(); - -sub write_makefile { - my $ccflags = -d '.svn' || $ENV{MAINTAINER_MODE} ? '-Wall' : ''; - - WriteMakefile( - VERSION_FROM => 'lib/Class/MOP.pm', - NAME => 'Class::MOP', - PREREQ_PM => \%prereqs, - CONFIGURE => \&init, - CCFLAGS => $ccflags, - clean => { FILES => 'test.c test.o' }, - ABSTRACT_FROM => 'lib/Class/MOP.pm', - AUTHOR => 'Stevan Little ', - LICENSE => 'perl', - ); -} +require Config; +my $ccflags = ( $Config::Config{ccflags} || '' ) . ' -I.'; +$ccflags .= ' -Wall' if -d '.svn' || -d '.git' || $ENV{MAINTAINER_MODE}; -sub no_cc { - print <<'EOF'; +requires 'Carp'; +requires 'Devel::GlobalDestruction'; +requires 'MRO::Compat' => '0.05'; +requires 'Scalar::Util' => '1.18'; +requires 'Sub::Name' => '0.04'; +requires 'Task::Weaken'; - I cannot determine if you have a C compiler - so I will install a perl-only implementation +test_requires 'File::Spec'; +test_requires 'Test::More' => '0.88'; +test_requires 'Test::Exception' => '0.27'; - You can force installation of the XS version with +extra_tests(); - perl Makefile.PL --xs +makemaker_args( CCFLAGS => $ccflags ); -EOF -} +{ + my (@clean, @OBJECT, %XS); -sub check_for_compiler { - print "Testing if you have a C compiler\n"; + for my $xs () { + (my $c = $xs) =~ s/\.xs$/.c/i; + (my $o = $xs) =~ s/\.xs$/\$(OBJ_EXT)/i; - eval { require ExtUtils::CBuilder }; - if ($@) { - return _check_for_compiler_manually(); + $XS{$xs} = $c; + push @OBJECT, $o; + push @clean, $o; } - else { - return _check_for_compiler_with_cbuilder(); + + for my $c (<*.c>) { + (my $o = $c) =~ s/\.c$/\$(OBJ_EXT)/i; + push @OBJECT, $o; + push @clean, $o; } + + makemaker_args( + clean => { FILES => join(q{ }, @clean) }, + OBJECT => join (q{ }, @OBJECT), + XS => \%XS, + ); } -sub _check_for_compiler_with_cbuilder { - my $cb = ExtUtils::CBuilder->new( quiet => 1 ); +postamble(<<'EOM'); +$(OBJECT) : mop.h +EOM - return $cb->have_compiler(); -} +WriteAll(); -sub _check_for_compiler_manually { - unless ( open F, '>', 'test.c' ) { - warn - "Cannot write test.c, skipping test compilation and installing pure Perl version.\n"; - return 0; - } +# Use the cpan-smolder-stable script in the Moose svn root to figure +# out what on CPAN will break with the latest Moose, then update this +# before a release. +sub check_conflicts { + my %conflicts = ( + 'Moose' => '0.85', + ); - print F <<'EOF'; -int main() { return 0; } -EOF + my $found = 0; + for my $mod ( sort keys %conflicts ) { + eval "require $mod"; + next if $@; + + my $installed = $mod->VERSION(); + if ( $installed le $conflicts{$mod} ) { + + print <<"EOF"; - close F or return 0; +*** + This version of Class::MOP conflicts with the version of + $mod ($installed) you have installed. - my $cc = $Config{cc}; - if ( $cc =~ /cl(\.exe)?$/ ) { + You will need to upgrade $mod after installing + this version of Class::MOP. +*** - # stupid stupid MSVC compiler hack tacken from version.pm's - # Makefile.PL - $cc .= ' -c'; # prevent it from calling the linker +EOF + + $found = 1; + } } - system("$cc -o test$Config{obj_ext} test.c") and return 0; + return unless $found; - unlink $_ for grep {-f} 'test.c', "test$Config{obj_ext}"; + # More or less copied from Module::Build + return if $ENV{PERL_MM_USE_DEFAULT}; + return unless -t STDIN && ( -t STDOUT || !( -f STDOUT || -c STDOUT ) ); - return 1; + sleep 4; } -# This is EUMM voodoo -sub init { - my $hash = $_[1]; +package MY; + +use Config; - unless ($has_compiler) { - @{$hash}{ 'XS', 'C' } = ( {}, [] ); +sub const_cccmd { + my $ret = shift->SUPER::const_cccmd(@_); + return q{} unless $ret; + + if ($Config{cc} =~ /^cl\b/i) { + warn 'you are using MSVC... my condolences.'; + $ret .= ' /Fo$@'; + } + else { + $ret .= ' -o $@'; } - $hash; + return $ret; }