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