/usr/share/perl5/Dist/Zilla/Plugin/MakeMaker/Awesome.pm is in libdist-zilla-plugin-makemaker-awesome-perl 0.39-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 | package Dist::Zilla::Plugin::MakeMaker::Awesome; # git description: v0.38-10-g5fd51ab
# ABSTRACT: A more awesome MakeMaker plugin for L<Dist::Zilla>
# KEYWORDS: plugin installer MakeMaker Makefile.PL toolchain customize override
our $VERSION = '0.39';
use Moose;
use MooseX::Types::Moose qw< Str ArrayRef HashRef >;
use MooseX::Types::Stringlike 'Stringlike';
use namespace::autoclean;
use CPAN::Meta::Requirements 2.121; # requirements_for_module
use List::Util 1.29 qw(first pairs pairgrep);
use version;
use Path::Tiny;
extends 'Dist::Zilla::Plugin::MakeMaker' => { -version => 5.001 };
# avoid wiping out the method modifications to dump_config done by superclass
with 'Dist::Zilla::Role::FileGatherer' => { -excludes => 'dump_config' };
sub mvp_multivalue_args { qw(WriteMakefile_arg_strs test_files exe_files header_strs footer_strs) }
sub mvp_aliases {
+{
WriteMakefile_arg => 'WriteMakefile_arg_strs',
test_file => 'test_files',
exe_file => 'exe_files',
header => 'header_strs',
footer => 'footer_strs',
}
}
has MakeFile_PL_template => (
is => 'ro',
isa => Stringlike,
coerce => 1,
lazy => 1,
builder => '_build_MakeFile_PL_template',
documentation => "The Text::Template used to construct the ExtUtils::MakeMaker Makefile.PL",
);
sub _build_MakeFile_PL_template {
my ($self) = @_;
my $template = <<'TEMPLATE';
# This Makefile.PL for {{ $dist->name }} was generated by
# {{ ref $plugin }} {{ ($plugin->VERSION || '<self>')
. (ref $plugin ne 'Dist::Zilla::Plugin::MakeMaker::Awesome'
? "\n" . '# and Dist::Zilla::Plugin::MakeMaker::Awesome '
. Dist::Zilla::Plugin::MakeMaker::Awesome->VERSION
: '') }}.
# Don't edit it but the dist.ini and plugins used to construct it.
use strict;
use warnings;
{{ $perl_prereq ? qq[use $perl_prereq;] : ''; }}
use ExtUtils::MakeMaker{{ 0+$eumm_version ? ' ' . $eumm_version : '' }};
{{ $header }}
{{ $share_dir_block[0] }}
my {{ $WriteMakefileArgs }}
{{
@$extra_args ? "%WriteMakefileArgs = (\n"
. join('', map { " " . $_ . ",\n" } '%WriteMakefileArgs', @$extra_args)
. ");\n"
: '';
}}
my {{ $fallback_prereqs }}
unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
delete $WriteMakefileArgs{TEST_REQUIRES};
delete $WriteMakefileArgs{BUILD_REQUIRES};
$WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}
delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
WriteMakefile(%WriteMakefileArgs);
{{ $share_dir_block[1] }}
{{ $footer }}
TEMPLATE
return $template;
}
around BUILDARGS => sub
{
my $orig = shift;
my $class = shift;
my $args = $class->$orig(@_);
my $delimiter = delete $args->{delimiter};
if (defined $delimiter and length($delimiter))
{
foreach my $arg (grep { exists $args->{$_} } qw(WriteMakefile_arg_strs header_strs footer_strs))
{
s/^\Q$delimiter\E// foreach @{$args->{$arg}};
}
}
return $args;
};
around dump_config => sub
{
my ($orig, $self) = @_;
my $config = $self->$orig;
my $data = {
blessed($self) ne __PACKAGE__ ? ( version => $VERSION ) : (),
};
$config->{+__PACKAGE__} = $data if keys %$data;
$config->{'Dist::Zilla::Plugin::MakeMaker'}{make_path} ||= $self->make_path;
$config->{'Dist::Zilla::Plugin::MakeMaker'}{version} ||= Dist::Zilla::Plugin::MakeMaker->VERSION;
$config->{'Dist::Zilla::Role::TestRunner'}{default_jobs} ||= $self->default_jobs;
$config->{'Dist::Zilla::Role::TestRunner'}{version} ||= Dist::Zilla::Role::TestRunner->VERSION;
return $config;
};
has WriteMakefile_arg_strs => (
is => 'ro', isa => ArrayRef[Str],
traits => ['Array'],
lazy => 1,
default => sub { [] },
documentation => "Additional arguments passed to ExtUtils::MakeMaker's WriteMakefile()",
);
has WriteMakefile_args => (
isa => HashRef,
traits => ['Hash'],
handles => {
WriteMakefile_args => 'elements',
delete_WriteMakefile_arg => 'delete',
WriteMakefile_arg => 'get',
},
lazy => 1,
builder => '_build_WriteMakefile_args',
documentation => "The arguments passed to ExtUtils::MakeMaker's WriteMakefile()",
);
sub _build_WriteMakefile_args {
my ($self) = @_;
(my $name = $self->zilla->name) =~ s/-/::/g;
my $test_files = $self->test_files;
my $perl_prereq = $self->min_perl_version;
my $prereqs_dump = sub {
$self->zilla->prereqs->requirements_for(@_)
->clone
->clear_requirement('perl')
->as_string_hash;
};
my %require_prereqs = map {
$_ => $prereqs_dump->($_, 'requires');
} qw(configure build test runtime);
# EUMM may soon be able to support this, but until we decide to inject a
# higher configure-requires version, we should at least warn the user
# https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker/issues/215
foreach my $phase (qw(configure build test runtime)) {
if (my @version_ranges = pairgrep { defined $b && !version::is_lax($b) } %{ $require_prereqs{$phase} }
and $self->eumm_version < '7.1101') {
$self->log_fatal([
'found version range in %s prerequisites, which ExtUtils::MakeMaker cannot parse (must specify eumm_version of at least 7.1101): %s %s',
$phase, $_->[0], $_->[1]
]) foreach pairs @version_ranges;
}
}
my @authors = @{ $self->zilla->authors };
my $exe_files = $self->exe_files;
my %WriteMakefile = (
DISTNAME => $self->zilla->name,
NAME => $name,
( AUTHOR => @authors > 1 && ($self->eumm_version >= 6.5702 || $perl_prereq >= 5.013005)
? \@authors
: join(q{, }, @authors) ),
ABSTRACT => $self->zilla->abstract,
VERSION => $self->zilla->version,
LICENSE => $self->zilla->license->meta_yml_name,
@$exe_files ? ( EXE_FILES => [ sort @$exe_files ] ) : (),
CONFIGURE_REQUIRES => $require_prereqs{configure},
keys %{ $require_prereqs{build} } ? ( BUILD_REQUIRES => $require_prereqs{build} ) : (),
keys %{ $require_prereqs{test} } ? ( TEST_REQUIRES => $require_prereqs{test} ) : (),
PREREQ_PM => $require_prereqs{runtime},
test => { TESTS => join q{ }, sort @$test_files },
$perl_prereq ? ( MIN_PERL_VERSION => $perl_prereq ) : (),
);
return \%WriteMakefile;
}
# overrides parent version
has eumm_version => (
isa => 'Str',
is => 'rw',
lazy => 1,
default => sub {
my $self = shift;
# do not unnecessarily raise the version just for listref AUTHOR
@{$self->zilla->authors} > 1 && $self->min_perl_version >= 5.013005
? '6.5702' : 0,
},
);
has min_perl_version => (
isa => 'Str',
is => 'rw',
lazy => 1,
builder => '_build_min_perl_version',
);
sub _build_min_perl_version
{
my $self = shift;
my $prereqs = $self->zilla->prereqs;
my $perl_prereq = $prereqs->requirements_for(qw(runtime requires))
->clone
->add_requirements($prereqs->requirements_for(qw(configure requires)))
->add_requirements($prereqs->requirements_for(qw(build requires)))
->add_requirements($prereqs->requirements_for(qw(test requires)))
->as_string_hash->{perl};
$perl_prereq
? version->parse($perl_prereq)->numify
: 0;
}
has WriteMakefile_dump => (
is => 'ro',
isa => Stringlike,
coerce => 1,
lazy => 1,
builder => '_build_WriteMakefile_dump',
documentation => "A Data::Dumper Str for using WriteMakefile_args used by MakeFile_PL_template"
);
sub _build_WriteMakefile_dump {
my ($self) = @_;
# Get arguments for WriteMakefile
my %write_makefile_args = $self->WriteMakefile_args;
return $self->_dump_as(\%write_makefile_args, '*WriteMakefileArgs');
}
has test_files => (
is => 'ro',
isa => ArrayRef[Str],
lazy => 1,
builder => '_build_test_files',
documentation => "The glob paths given to the C<< test => { TESTS => ... } >> parameter for ExtUtils::MakeMaker's WriteMakefile() (in munged form)",
);
sub _build_test_files {
my ($self) = @_;
my %test_files;
for my $file (@{ $self->zilla->files }) {
next unless $file->name =~ m{\At/.+\.t\z};
(my $pattern = $file->name) =~ s{/[^/]+\.t\z}{/*.t}g;
$test_files{$pattern} = 1;
}
return [ keys %test_files ];
}
has exe_files => (
is => 'ro',
isa => ArrayRef[Str],
lazy => 1,
builder => '_build_exe_files',
documentation => "The list of filenames given to ExtUtils::MakeMaker's EXE_FILES (in munged form)",
);
sub _build_exe_files {
my ($self) = @_;
my @exe_files = map { $_->name } @{ $self->zilla->find_files(':ExecFiles') };
return \@exe_files;
}
has share_dir_block => (
is => 'ro',
isa => ArrayRef[Str],
auto_deref => 1,
lazy => 1,
builder => '_build_share_dir_block',
documentation => "The share dir block used in `MakeFile_PL_template'",
);
sub _build_share_dir_block {
my ($self) = @_;
my @share_dir_block = (q{}, q{});
my $share_dir_map = $self->zilla->_share_dir_map;
if ( keys %$share_dir_map ) {
# split in two to foil CPANTS prereq_matches_use
my $preamble = qq{use File::Shar}.qq{eDir::Install;\n};
if ( my $dist_share_dir = $share_dir_map->{dist} ) {
$dist_share_dir = quotemeta $dist_share_dir;
$preamble .= qq{install_share dist => "$dist_share_dir";\n};
}
if ( my $mod_map = $share_dir_map->{module} ) {
for my $mod ( keys %$mod_map ) {
my $mod_share_dir = quotemeta $mod_map->{$mod};
$preamble .= qq{install_share module => "$mod", "$mod_share_dir";\n};
}
}
@share_dir_block = (
$preamble,
qq{\{\npackage\nMY;\nuse File::ShareDir::Install qw(postamble);\n\}\n},
);
}
return \@share_dir_block;
}
has header_strs => (
is => 'ro', isa => ArrayRef[Str],
traits => ['Array'],
lazy => 1,
default => sub { [] },
documentation => "Additional code lines to include at the beginning of Makefile.PL",
);
has header_file => (
is => 'ro', isa => Str,
documentation => 'Additional header content to include from a file',
);
has header => (
is => 'ro',
isa => Str,
lazy => 1,
builder => '_build_header',
documentation => "A string included at the beginning of Makefile.PL",
);
sub _build_header {
my $self = shift;
$self->log_fatal([ 'header_file %s does not exist!', $self->header_file->stringify ])
if $self->header_file and not -e $self->header_file;
join "\n",
@{$self->header_strs},
( $self->header_file ? path($self->header_file)->slurp_utf8 : () );
}
has footer_strs => (
is => 'ro', isa => ArrayRef[Str],
traits => ['Array'],
lazy => 1,
default => sub { [] },
documentation => "Additional code lines to include at the end of Makefile.PL",
);
has footer_file => (
is => 'ro', isa => Str,
documentation => 'Additional footer content to include from a file',
);
has footer => (
is => 'ro',
isa => Str,
lazy => 1,
builder => '_build_footer',
documentation => "A string included at the end of Makefile.PL",
);
sub _build_footer {
my $self = shift;
$self->log_fatal([ 'footer_file %s does not exist!', $self->footer_file->stringify ])
if $self->footer_file and not -e $self->footer_file;
join "\n",
@{$self->footer_strs},
( $self->footer_file ? path($self->footer_file)->slurp_utf8 : () );
}
sub register_prereqs {
my ($self) = @_;
$self->zilla->register_prereqs(
{ phase => 'configure' },
'ExtUtils::MakeMaker' => $self->eumm_version || 0,
);
return unless keys %{ $self->zilla->_share_dir_map };
$self->zilla->register_prereqs(
{ phase => 'configure', type => 'requires' },
'File::ShareDir::Install' => 0.03,
);
return {};
}
sub gather_files
{
my $self = shift;
require Dist::Zilla::File::InMemory;
my $file = Dist::Zilla::File::InMemory->new({
name => 'Makefile.PL',
content => $self->MakeFile_PL_template, # template evaluated later
});
$self->add_file($file);
return;
}
sub setup_installer
{
my $self = shift;
## Sanity checks
$self->log_fatal("can't install files with whitespace in their names")
if grep { /\s/ } @{$self->exe_files};
my $perl_prereq = $self->WriteMakefile_arg('MIN_PERL_VERSION');
# file was already created; find it and fill in the content
my $file = first { $_->name eq 'Makefile.PL' } @{$self->zilla->files};
$self->log_debug([ 'updating contents of Makefile.PL in memory' ]);
$self->log_fatal('Makefile.PL has vanished from the distribution! Did you [PruneFiles] the file after it was gathered?'
. "\n" . '(instead, try [GatherDir] exclude_filename = Makefile.PL)')
if not $file;
my $content = $self->fill_in_string(
$file->content,
{
dist => \($self->zilla),
plugin => \$self,
eumm_version => \($self->eumm_version),
perl_prereq => \$perl_prereq,
share_dir_block => [ $self->share_dir_block ],
fallback_prereqs => \($self->fallback_prereq_pm),
WriteMakefileArgs => \($self->WriteMakefile_dump),
extra_args => \($self->WriteMakefile_arg_strs),
header => \$self->header,
footer => \$self->footer,
},
);
$content =~ s/\n{3,}/\n\n/g;
$content =~ s/\n+\z/\n/;
$file->content($content);
return;
}
__PACKAGE__->meta->make_immutable;
__END__
=pod
=encoding UTF-8
=head1 NAME
Dist::Zilla::Plugin::MakeMaker::Awesome - A more awesome MakeMaker plugin for L<Dist::Zilla>
=head1 VERSION
version 0.39
=head1 SYNOPSIS
In your F<dist.ini>:
[MakeMaker::Awesome]
WriteMakefile_arg = CCFLAGS => `pkg-config --cflags libpng`
WriteMakefile_arg = LIBS => [ `pkg-config --libs libpng` ]
header = die 'Unsupported OS' if $^O eq 'MSWin32';
delimiter = |
footer = |package MY;
footer = |sub postamble {
footer = | my $self = shift;
footer = | return $self->SUPER::postamble . "\n\nfoo: bar\n\t$(CP) bar foo\n";
footer = |}
or:
;; Replace [MakeMaker]
;[MakeMaker]
[=inc::MyMakeMaker]
=head1 DESCRIPTION
L<Dist::Zilla>'s L<MakeMaker|Dist::Zilla::Plugin::MakeMaker> plugin is
limited, if you want to stray from the marked path and do something
that would normally be done in a C<package MY> section or otherwise
run custom code in your F<Makefile.PL> you're out of luck.
This plugin is 100% compatible with L<Dist::Zilla::Plugin::MakeMaker> -- we
add additional customization hooks by subclassing it.
=head1 CONFIGURATION OPTIONS
Many features can be accessed directly via F<dist.ini>, by setting options.
For options where you expect a multi-line string to be inserted into
F<Makefile.PL>, use the config option more than once, setting each line
separately.
=head2 WriteMakefile_arg
A string, which evaluates to an even-numbered list, which will be included in the call to
C<WriteMakefile>. Any code is legal that can be inserted into a list of other
key-value pairs, for example:
[MakeMaker::Awesome]
WriteMakefile_arg = ( $^O eq 'solaris' ? ( CCFLAGS => '-Wall' ) : ())
Can be used more than once.
Available since version 0.21.
=for stopwords DynamicPrereqs
Note: you (intentionally) cannot use this mechanism for specifying dynamic
prerequisites, as previous occurrences of a top-level key will be overwritten
(additionally, you cannot set the fallback prereqs from here). You should take
a look at L<[DynamicPrereqs]|Dist::Zilla::Plugin::DynamicPrereqs> for this.
=head2 header
A line of code which is included near the top of F<Makefile.PL>. Can be used more than once.
Available since version 0.26.
=head2 header_file
The name of a file in the source tree (does not need to be gathered in the
build) whose content is inserted near the top of F<Makefile.PL>.
Available since version 0.35.
=head2 footer
A line of code which is included at the bottom of F<Makefile.PL>. Can be used more than once.
Available since version 0.26.
=head2 footer_file
The name of a file in the source tree (does not need to be gathered in the
build) whose content is inserted at the bottom of F<Makefile.PL>.
Available since version 0.35.
=head2 delimiter
A string, usually a single character, which is stripped from the beginning of
all C<WriteMakefile_arg>, C<header>, and C<footer> lines. This is because the
INI file format strips all leading whitespace from option values, so including
this character at the front allows you to use leading whitespace in an option
string. This is crucial for the formatting of F<Makefile>s, but a nice thing
to have when inserting any block of code.
Available since version 0.27.
=head2 test_file
A glob path given to the C<< test => { TESTS => ... } >> parameter for
L<ExtUtils::MakeMaker/WriteMakefile>. Can be used more than once.
Defaults to F<.t> files under F<t/>. B<NOT> a directory name, despite the name.
Available since version 0.21.
=head2 exe_file
The file given to the C<EXE_FILES> parameter for
L<ExtUtils::MakeMaker/WriteMakefile>. Can be used more than once.
Defaults to using data from C<:ExecDir> plugins.
Available since version 0.21.
=head1 SUBCLASSING
You can further customize the content of F<Makefile.PL> by subclassing this plugin,
L<Dist::Zilla::Plugin::MakeMaker::Awesome>.
As an example, adding a C<package MY> section to your
F<Makefile.PL>:
In your F<dist.ini>:
[=inc::MyDistMakeMaker / MyDistMakeMaker]
Then in your F<inc/MyDistMakeMaker.pm>, real example from L<Hailo>
(which has C<[=inc::HailoMakeMaker / HailoMakeMaker]> in its
F<dist.ini>):
package inc::HailoMakeMaker;
use Moose;
extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';
override _build_MakeFile_PL_template => sub {
my ($self) = @_;
my $template = super();
$template .= <<'TEMPLATE';
package MY;
sub test {
my $inherited = shift->SUPER::test(@_);
# Run tests with Moose and Mouse
$inherited =~ s/^test_dynamic :: pure_all\n\t(.*?)\n/test_dynamic :: pure_all\n\tANY_MOOSE=Mouse $1\n\tANY_MOOSE=Moose $1\n/m;
return $inherited;
}
TEMPLATE
return $template;
};
__PACKAGE__->meta->make_immutable;
=for stopwords distro
Or maybe you're writing an XS distro and want to pass custom arguments
to C<WriteMakefile()>, here's an example of adding a C<LIBS> argument
in L<re::engine::PCRE> (note that you can also achieve this without
subclassing, by passing the L</WriteMakefile_arg> option):
package inc::PCREMakeMaker;
use Moose;
extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';
override _build_WriteMakefile_args => sub { +{
# Add LIBS => to WriteMakefile() args
%{ super() },
LIBS => [ '-lpcre' ],
} };
__PACKAGE__->meta->make_immutable;
And another example from L<re::engine::Plan9>, which determines the arguments
dynamically at build time:
package inc::Plan9MakeMaker;
use Moose;
extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';
override _build_WriteMakefile_args => sub {
my ($self) = @_;
our @DIR = qw(libutf libfmt libregexp);
our @OBJ = map { s/\.c$/.o/; $_ }
grep { ! /test/ }
glob "lib*/*.c";
return +{
%{ super() },
DIR => [ @DIR ],
INC => join(' ', map { "-I$_" } @DIR),
# This used to be '-shared lib*/*.o' but that doesn't work on Win32
LDDLFLAGS => "-shared @OBJ",
};
};
__PACKAGE__->meta->make_immutable;
If you have custom code in your L<ExtUtils::MakeMaker>-based
F<Makefile.PL> that L<Dist::Zilla> can't replace via its default
facilities you'll be able to replace it by using this module.
Even if your F<Makefile.PL> isn't L<ExtUtils::MakeMaker>-based you
should be able to override it. You'll just have to provide a new
L</"_build_MakeFile_PL_template">.
=for stopwords overridable
=head2 OVERRIDABLE METHODS
These are the methods you can currently C<override> or method-modify in your
custom F<inc/> module. The work that this module does is entirely done in
small modular methods that can be overridden in your subclass. Here are
some of the highlights:
=for Pod::Coverage mvp_multivalue_args mvp_aliases
=head3 _build_MakeFile_PL_template
Returns a L<Text::Template> string used to construct the F<Makefile.PL>.
If you need to insert some additional code to the beginning or end of
F<Makefile.PL> (without modifying the existing content, you should use an
C<around> method modifier, something like this:
around _build_MakeFile_PL_template => sub {
my $orig = shift;
my $self = shift;
my $NEW_CONTENT = ...;
# insert new content near the beginning of the file, preserving the
# existing header content
my $string = $self->$orig(@_);
$string =~ m/use warnings;\n\n/g;
return substr($string, 0, pos($string)) . $NEW_CONTENT . substr($string, pos($string));
};
=head3 _build_WriteMakefile_args
A C<HashRef> of arguments that will be passed to
L<ExtUtils::MakeMaker>'s C<WriteMakefile> function.
=head3 _build_WriteMakefile_dump
Takes the return value of L</"_build_WriteMakefile_args"> and
constructs a L<Str> that will be included in the F<Makefile.PL> by
L</"_build_MakeFile_PL_template">.
=head3 _build_header
A C<Str> of code that will be included near the top of F<Makefile.PL>.
=head3 _build_footer
A C<Str> of code that will be included at the bottom of F<Makefile.PL>.
=head3 _build_test_files
The glob paths given to the C<< test => { TESTS => ... } >> parameter for
L<ExtUtils::MakeMaker/WriteMakefile>. Defaults to F<.t> files under F<t/>.
B<NOT> directories, despite the name.
=head3 _build_exe_files
The files given to the C<EXE_FILES> parameter for
L<ExtUtils::MakeMaker/WriteMakefile>.
Defaults to using data from C<:ExecDir> plugins.
=head3 _build_min_perl_version
Extracts from the distribution prerequisite object the minimum version of perl
required; used for the C<MIN_PERL_VERSION> parameter for
L<ExtUtils::MakeMaker/WriteMakefile>.
=head3 register_prereqs
=head3 gather_files
=head3 setup_installer
=for stopwords dirs
The test/bin/share dirs and exe_files. These will all be passed to
F</"_build_WriteMakefile_args"> later.
=head3 _build_share_dir_block
=for stopwords sharedir
An C<ArrayRef[Str]> with two elements to be used by
L</"_build_MakeFile_PL_template">. The first will declare your
L<sharedir|File::ShareDir::Install> and the second will add a magic
C<package MY> section to install it. Deep magic.
=head2 OTHER
The main entry point is C<setup_installer> via the
L<Dist::Zilla::Role::InstallTool> role. There are also other magic
Dist::Zilla roles, check the source for more info.
=head1 DIAGNOSTICS
=over
=item attempt to add F<Makefile.PL> multiple times
This error from L<Dist::Zilla> means that you've used both
C<[MakeMaker]> and C<[MakeMaker::Awesome]>. You've either included
C<MakeMaker> directly in F<dist.ini>, or you have plugin bundle that
includes it. See L<@Filter|Dist::Zilla::PluginBundle::Filter> for how
to filter it out.
=back
=head1 LIMITATIONS
=for stopwords INI
This plugin would suck less if L<Dist::Zilla> didn't use a INI-based
config system so you could add stuff like this in your main
configuration file like you can with L<Module::Install>.
The F<.ini> file format can only support key-value pairs whereas any
complex use of L<ExtUtils::MakeMaker> requires running custom Perl
code and passing complex data structures to C<WriteMakefile>.
=head1 AFTERWORD
________________________
< everything is AWESOME! >
------------------------
\ ___-------___
\ _-~~ ~~-_
\ _-~ /~-_
/^\__/^\ /~ \ / \
/| O|| O| / \_______________/ \
| |___||__| / / \ \
| \ / / \ \
| (_______) /______/ \_________ \
| / / \ / \
\ \^\\ \ / \ /
\ || \______________/ _-_ //\__//
\ ||------_-~~-_ ------------- \ --/~ ~\ || __/
~-----||====/~ |==================| |/~~~~~
(_(__/ ./ / \_\ \.
(_(___/ \_____)_)
=head1 SUPPORT
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-MakeMaker-Awesome>
(or L<bug-Dist-Zilla-Plugin-MakeMaker-Awesome@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-MakeMaker-Awesome@rt.cpan.org>).
There is also a mailing list available for users of this distribution, at
L<http://dzil.org/#mailing-list>.
There is also an irc channel available for users of this distribution, at
L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>.
=head1 AUTHORS
=over 4
=item *
Ævar Arnfjörð Bjarmason <avar@cpan.org>
=item *
Karen Etheridge <ether@cpan.org>
=back
=head1 CONTRIBUTORS
=for stopwords Jesse Luehrs Robin Smidsrød Vladimir Timofeev
=over 4
=item *
Jesse Luehrs <doy@tozt.net>
=item *
Robin Smidsrød <robin@smidsrod.no>
=item *
Vladimir Timofeev <vovkasm@gmail.com>
=back
=head1 COPYRIGHT AND LICENCE
This software is copyright (c) 2010 by Ævar Arnfjörð Bjarmason.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|