-# 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 Module::Install::AuthorRequires;
+use Module::Install::ExtraTests;
+use 5.008001;
-use ExtUtils::MakeMaker;
-use Config qw(%Config);
-use File::Spec;
+check_conflicts();
-use 5.008;
+name 'Class-MOP';
+perl_version '5.008001';
+all_from 'lib/Class/MOP.pm';
+license 'perl';
-# If undefined, try our best, if true, require XS, if false, never do
-# XS
-my $force_xs;
+require Config;
+my $ccflags = ( $Config::Config{ccflags} || '' ) . ' -I.';
-for (@ARGV) {
- /^--pm/ and $force_xs = 0;
- /^--xs/ and $force_xs = 1;
+if ( -d '.git' || $ENV{MAINTAINER_MODE} ) {
+ $ccflags .= ' -Wall -Wdeclaration-after-statement';
}
-my $has_compiler = $force_xs;
-unless ( defined $force_xs ) {
- $has_compiler = check_for_compiler()
- or no_cc();
-}
+requires 'Carp';
+requires 'Data::OptList';
+requires 'Devel::GlobalDestruction';
+requires 'List::MoreUtils' => '0.12';
+requires 'MRO::Compat' => '0.05';
+requires 'Package::DeprecationManager' => '0.10';
+requires 'Package::Stash' => '0.13';
+requires 'Scalar::Util' => '1.18';
+requires 'Sub::Name' => '0.05';
+requires 'Try::Tiny' => '0.02';
+requires 'Task::Weaken';
+
+test_requires 'File::Spec';
+test_requires 'Test::More' => '0.88';
+test_requires 'Test::Fatal' => '0.001';
+test_requires 'Test::Requires' => '0.05';
+
+author_requires 'Algorithm::C3';
+author_requires 'Module::Info';
+author_requires 'Test::LeakTrace';
+author_requires 'Test::NoTabs';
+author_requires 'Test::Output';
+author_requires 'Test::Spelling';
+
+repository 'git://git.moose.perl.org/Class-MOP.git';
+add_metadata(x_authority => 'cpan:STEVAN');
+
+extra_tests();
+
+makemaker_args( CCFLAGS => $ccflags );
+
+{
+ my (@clean, @OBJECT, %XS);
+
+ for my $xs (<xs/*.xs>) {
+ (my $c = $xs) =~ s/\.xs$/.c/i;
+ (my $o = $xs) =~ s/\.xs$/\$(OBJ_EXT)/i;
+
+ $XS{$xs} = $c;
+ push @OBJECT, $o;
+ push @clean, $o;
+ }
-my %prereqs = (
- 'Scalar::Util' => '1.18',
- 'Sub::Name' => '0.04',
- 'Sub::Identify' => '0.03',
- 'MRO::Compat' => '0.05',
- 'Test::More' => '0',
- 'Test::Exception' => '0',
- 'File::Spec' => '0',
- 'Carp' => '0',
- 'Devel::GlobalDestruction' => '0',
-);
-
-delete @prereqs{qw(Sub::Name Devel::GlobalDestruction)}
- unless $has_compiler;
-
-if ($has_compiler && is_maintainer()) {
- create_pp_tests();
-}
+ for my $c (<*.c>) {
+ (my $o = $c) =~ s/\.c$/\$(OBJ_EXT)/i;
+ push @OBJECT, $o;
+ push @clean, $o;
+ }
-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 t/pp*' },
- ABSTRACT_FROM => 'lib/Class/MOP.pm',
- AUTHOR => 'Stevan Little <stevan@iinteractive.com>',
- LICENSE => 'perl',
+ makemaker_args(
+ clean => { FILES => join(q{ }, @clean) },
+ OBJECT => join (q{ }, @OBJECT),
+ XS => \%XS,
);
}
-sub no_cc {
- print <<'EOF';
+postamble(<<'EOM');
+$(OBJECT) : mop.h
+EOM
- I cannot determine if you have a C compiler
- so I will install a perl-only implementation
+WriteAll();
- You can force installation of the XS version with
-
- perl Makefile.PL --xs
-
-EOF
-}
+# 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' => '1.14',
+ 'namespace::autoclean' => '0.08',
+ );
-sub check_for_compiler {
- print "Testing if you have a C compiler\n";
+ my $found = 0;
+ for my $mod ( sort keys %conflicts ) {
+ eval "require $mod";
+ next if $@;
- eval { require ExtUtils::CBuilder };
- if ($@) {
- return _check_for_compiler_manually();
- }
- else {
- return _check_for_compiler_with_cbuilder();
- }
-}
+ my $installed = $mod->VERSION();
+ if ( $installed le $conflicts{$mod} ) {
-sub _check_for_compiler_with_cbuilder {
- my $cb = ExtUtils::CBuilder->new( quiet => 1 );
+ print <<"EOF";
- return $cb->have_compiler();
-}
+***
+ This version of Class::MOP conflicts with the version of
+ $mod ($installed) you have installed.
-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;
- }
+ You will need to upgrade $mod after installing
+ this version of Class::MOP.
+***
- print F <<'EOF';
-int main() { return 0; }
EOF
- close F or return 0;
-
- my $cc = $Config{cc};
- if ( $cc =~ /cl(\.exe)?$/ ) {
-
- # stupid stupid MSVC compiler hack tacken from version.pm's
- # Makefile.PL
- $cc .= ' -c'; # prevent it from calling the linker
+ $found = 1;
+ }
}
- system("$cc -o test$Config{obj_ext} test.c") and return 0;
-
- unlink $_ for grep {-f} 'test.c', "test$Config{obj_ext}";
-
- return 1;
-}
+ return unless $found;
-# This sucks, but it's the best guess we can make. Since we just use
-# it to run two sets of tests, it's not big deal if it ends up true
-# for a non-maintainer.
-sub is_maintainer {
- return 0 if $ENV{PERL5_CPAN_IS_RUNNING} || $ENV{PERL5_CPANPLUS_IS_RUNNING};
+ # 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;
}
-sub create_pp_tests {
- opendir my $dh, 't' or die "Cannot read t: $!";
-
- foreach my $file ( grep {/^\d.+\.t$/} readdir $dh ) {
- next if $file =~ /^99/;
-
- my $real_file = File::Spec->catfile( 't', $file );
-
- open my $fh, '<', $real_file
- or die "Cannot read $real_file: $!";
+package MY;
- my $shbang = <$fh>;
- my $test = do { local $/; <$fh> };
+use Config;
- close $fh;
+sub const_cccmd {
+ my $ret = shift->SUPER::const_cccmd(@_);
+ return q{} unless $ret;
- $test = "$shbang\nBEGIN { \$ENV{CLASS_MOP_NO_XS} = 1 }\n\n$test";
-
- my $new_file = File::Spec->catfile( 't', "pp_$file" );
- open my $new_fh, '>', $new_file
- or die "Cannot write to $new_file: $!";
-
- print $new_fh $test;
-
- close $new_fh;
+ if ($Config{cc} =~ /^cl\b/i) {
+ warn 'you are using MSVC... my condolences.';
+ $ret .= ' /Fo$@';
}
-}
-
-# This is EUMM voodoo
-sub init {
- my $hash = $_[1];
-
- unless ($has_compiler) {
- @{$hash}{ 'XS', 'C' } = ( {}, [] );
+ else {
+ $ret .= ' -o $@';
}
- $hash;
+ return $ret;
}