account for coderefs partially
[dbsrgits/DBIx-Class.git] / maint / Makefile.PL.inc / 50_redefine_makefile_flow.pl
1 # Split create_distdir into several subtargets, allowing us to generate
2 # stuff, inject it into lib/, manifest it, and then clean all of it up
3 {
4   package MY;
5   sub distdir {
6     (my $snippet = shift->SUPER::distdir(@_)) =~ s/^create_distdir :/create_distdir_copy_manifested :/;
7     return <<"EOM";
8 $snippet
9
10 .NOTPARALLEL :
11
12 create_distdir : check_create_distdir_prereqs clonedir_generate_files clonedir_post_generate_files fresh_manifest create_distdir_copy_manifested clonedir_cleanup_generated_files
13 \t\$(NOECHO) \$(NOOP)
14
15 clonedir_generate_files :
16 \t\$(NOECHO) \$(NOOP)
17
18 clonedir_post_generate_files :
19 \t\$(NOECHO) \$(NOOP)
20
21 clonedir_cleanup_generated_files :
22 \t\$(NOECHO) \$(NOOP)
23
24 check_create_distdir_prereqs :
25 \t\$(NOECHO) @{[
26   $mm_proto->oneliner("DBIx::Class::Optional::Dependencies->die_unless_req_ok_for(q(dist_dir))", [qw/-Ilib -MDBIx::Class::Optional::Dependencies/])
27 ]}
28
29 EOM
30   }
31 }
32
33 # M::I inserts its own default postamble, so we can't easily override upload
34 # but we can still hook postamble in EU::MM
35 {
36   package MY;
37
38   sub postamble {
39     my $snippet = shift->SUPER::postamble(@_);
40     return <<"EOM";
41 $snippet
42
43 upload :: check_create_distdir_prereqs check_upload_dist_prereqs
44
45 check_upload_dist_prereqs :
46 \t\$(NOECHO) @{[
47   $mm_proto->oneliner("DBIx::Class::Optional::Dependencies->die_unless_req_ok_for(q(dist_upload))", [qw/-Ilib -MDBIx::Class::Optional::Dependencies/])
48 ]}
49
50 EOM
51   }
52 }
53
54 # EU::MM BUG - workaround
55 # somehow the init_PM of EUMM (in MM_Unix) interprets ResultClass.pod.proto
56 # as a valid ResultClass.pod. While this has no effect on dist-building
57 # it royally screws up the local Makefile.PL $TO_INST_PM and friends,
58 # making it impossible to make/make test from a checkout
59 # just rip it out here (remember - this is only executed under author mode)
60 {
61   package MY;
62   sub init_PM {
63     my $self = shift;
64     my $rv = $self->SUPER::init_PM(@_);
65     delete @{$self->{PM}}{qw(lib/DBIx/Class/Manual/ResultClass.pod lib/DBIx/Class/Manual/ResultClass.pod.proto)};
66     $rv
67   }
68 }
69
70 # make the install (and friends) target a noop - instead of
71 # doing a perl Makefile.PL && make && make install (which will leave pod
72 # behind), one ought to assemble a distdir first
73
74 {
75   package MY;
76   sub install {
77     (my $snippet = shift->SUPER::install(@_))
78       =~ s/^( (?: install [^\:]+ | \w+_install \s) \:+ )/$1 block_install_from_checkout/mxg;
79     return <<"EOM";
80 $snippet
81
82 block_install_from_checkout :
83 \t\$(NOECHO) \$(ECHO) Installation directly from a checkout is not possible. You need to prepare a distdir, enter it, and run the installation from within.
84 \t\$(NOECHO) \$(FALSE)
85
86 EOM
87   }
88 }
89
90 # keep the Makefile.PL eval happy
91 1;