1 package inc::MMPackageStash;
4 extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';
6 # XXX: this is pretty gross, it should be possible to clean this up later
7 around _build_MakeFile_PL_template => sub {
12 my $can_cc = <<'CAN_CC';
16 # check if we can run some command
21 return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
23 for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
25 my $abs = File::Spec->catfile($dir, $_[1]);
26 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
32 # can we locate a (the) C compiler
34 my @chunks = split(/ /, $Config::Config{cc}) or return;
36 # $Config{cc} may contain args; try to find out the program part
38 return can_run("@chunks") || (pop(@chunks), next);
46 my $check_conflicts = <<'CHECK_CONFLICTS';
49 'Class::MOP' => '1.08',
50 'MooseX::Role::WithOverloading' => '0.08',
51 'namespace::clean' => '0.18',
54 for my $mod ( sort keys %conflicts ) {
58 my $installed = $mod->VERSION();
59 if ( $installed le $conflicts{$mod} ) {
64 This version of Package::Stash conflicts with the version of
65 $mod ($installed) you have installed.
67 You will need to upgrade $mod after installing
68 this version of Package::Stash.
79 # More or less copied from Module::Build
80 return if $ENV{PERL_MM_USE_DEFAULT};
81 return unless -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT));
87 my $template = $self->$orig(@_);
89 $template =~ s/(use ExtUtils::MakeMaker.*)/$1\n\ncheck_conflicts();/;
90 $template =~ s/(WriteMakefile\()/delete \$WriteMakefileArgs{PREREQ_PM}{'Package::Stash::XS'}\n unless can_cc();\n\n$1/;
92 return $template . $can_cc . $check_conflicts;
95 __PACKAGE__->meta->make_immutable;