summaryrefslogtreecommitdiffstats
path: root/inc/MakeMaker.pm
blob: 25cbf7e2a5796e1cdc51faeeb0528104f10e12be (plain) (blame)
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
package inc::MakeMaker;
use Moose;

extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';

around _build_MakeFile_PL_template => sub {
    my $orig = shift;
    my $self = shift;
    my $tmpl = $self->$orig;
    my $extra = <<'EXTRA';
use Config;
use Devel::CallParser 'callparser1_h', 'callparser_linkable';
open my $fh, '>', 'callparser1.h' or die "Couldn't write to callparser1.h";
$fh->print(callparser1_h);
my @linkable = callparser_linkable;
unshift @linkable, "Keyword$Config{obj_ext}" if @linkable;
$WriteMakefileArgs{OBJECT} = join(' ', @linkable) if @linkable;
EXTRA
    $tmpl =~ s/^(WriteMakefile\()/$extra\n$1/m
        or die "Couldn't fix template";
    return $tmpl;
};

around _build_WriteMakefile_args => sub {
    my $orig = shift;
    my $self = shift;
    my $args = $self->$orig(@_);
    $args->{clean} = {
        FILES => "callparser1.h",
    };
    return $args;
};

__PACKAGE__->meta->make_immutable;
no Moose;

1;