Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / maint / Makefile.PL.inc / 53_autogen_pod.pl
CommitLineData
95252a8c 1use File::Path();
2use File::Glob();
3
a14c7707 4# leftovers in old checkouts
5unlink 'lib/DBIx/Class/Optional/Dependencies.pod'
6 if -f 'lib/DBIx/Class/Optional/Dependencies.pod';
aff5e9c1 7File::Path::rmtree([ '.generated_pod' ])
95252a8c 8 if -d '.generated_pod';
a14c7707 9
95252a8c 10my $pod_dir = 'maint/.Generated_Pod';
a14c7707 11my $ver = Meta->version;
12
13# cleanup the generated pod dir (again - kill leftovers from old checkouts)
95252a8c 14if (-d $pod_dir) {
aff5e9c1 15 File::Path::rmtree([ File::Glob::bsd_glob("$pod_dir/*") ]);
95252a8c 16}
17else {
18 mkdir $pod_dir or die "Unable to create $pod_dir: $!";
19}
a14c7707 20
21# generate the OptDeps pod both in the clone-dir and during the makefile distdir
22{
23 print "Regenerating Optional/Dependencies.pod\n";
4a51243f 24
7c29ff83 25 eval {
26 require DBIx::Class::Optional::Dependencies;
27 DBIx::Class::Optional::Dependencies->_gen_pod ($ver, "$pod_dir/lib");
28 1;
29 }
30 or
31 printf ("FAILED!!! Subsequent `make dist` will fail. %s\n",
32 $ENV{DBICDIST_DEBUG}
33 ? "Full error: $@"
34 : 'Re-run with $ENV{DBICDIST_DEBUG} set for more info'
35 );
a14c7707 36
37 postamble <<"EOP";
38
a0c96f24 39clonedir_generate_files : dbic_clonedir_gen_optdeps_pod
a14c7707 40
41dbic_clonedir_gen_optdeps_pod :
3ba58fe4 42\t@{[
3e2a5d5d 43 $mm_proto->oneliner("DBIx::Class::Optional::Dependencies->_gen_pod(q($ver), q($pod_dir/lib))", [qw/-Ilib -MDBIx::Class::Optional::Dependencies/])
3ba58fe4 44]}
a14c7707 45
46EOP
47}
48
a0c96f24 49
e2633789 50# generate the script/dbicadmin pod
51{
52 print "Regenerating script/dbicadmin.pod\n";
53
54 # generating it in the root of $pod_dir
55 # it will *not* be copied over due to not being listed at the top
56 # of MANIFEST.SKIP - this is a *good* thing
57 # we only want to ship a script/dbicadmin, with the POD appended
58 # (see inject_dbicadmin_pod.pl), but still want to spellcheck and
59 # whatnot the intermediate step
60 my $pod_fn = "$pod_dir/dbicadmin.pod";
61
62 # if the author doesn't have the prereqs, don't fail the initial "perl Makefile.pl" step
4a51243f 63 my $great_success;
64 {
65 local @ARGV = ('--documentation-as-pod', $pod_fn);
b8a27054 66 local $0 = 'dbicadmin';
4a51243f 67 local *CORE::GLOBAL::exit = sub { $great_success++; die; };
68 do 'script/dbicadmin';
69 }
70 if (!$great_success and ($@ || $!) ) {
71 printf ("FAILED!!! Subsequent `make dist` will fail. %s\n",
72 $ENV{DBICDIST_DEBUG}
73 ? 'Full error: ' . ($@ || $!)
74 : 'Re-run with $ENV{DBICDIST_DEBUG} set for more info'
75 );
76 }
e2633789 77
78 postamble <<"EOP";
79
80clonedir_generate_files : dbic_clonedir_gen_dbicadmin_pod
81
82dbic_clonedir_gen_dbicadmin_pod :
83\t\$(ABSPERLRUN) -Ilib -- script/dbicadmin --documentation-as-pod @{[ $mm_proto->quote_literal($pod_fn) ]}
84
85EOP
86}
87
88
4a51243f 89# generate the inherit pods only during distbuilding phase
90# it is too slow to do at regular Makefile.PL
a14c7707 91{
a14c7707 92 postamble <<"EOP";
93
a0c96f24 94clonedir_generate_files : dbic_clonedir_gen_inherit_pods
a14c7707 95
96dbic_clonedir_gen_inherit_pods :
a0c96f24 97\t\$(ABSPERLRUN) -Ilib maint/gen_pod_inherit
98
99EOP
100}
101
102
3440100b 103# generate the DBIx/Class.pod only during distdir
104{
aff5e9c1 105 my $dist_pod_fn = "$pod_dir/lib/DBIx/Class.pod";
3440100b 106
107 postamble <<"EOP";
108
109clonedir_generate_files : dbic_distdir_gen_dbic_pod
110
111dbic_distdir_gen_dbic_pod :
112
113\tperldoc -u lib/DBIx/Class.pm > $dist_pod_fn
114\t@{[ $mm_proto->oneliner(
1fb834df 115 "s!^.*?this line is replaced with the author list.*! qq{List of the awesome contributors who made DBIC v$ver possible\\n\\n} . qx(\$^X -Ilib maint/gen_pod_authors)!me",
116 [qw( -0777 -p -i.arghwin32 )]
3440100b 117) ]} $dist_pod_fn
1fb834df 118\t\$(RM_F) $dist_pod_fn.arghwin32
3440100b 119
120create_distdir : dbic_distdir_defang_authors
121
122# Remove the maintainer-only warning (be nice ;)
123dbic_distdir_defang_authors :
1fb834df 124\t@{[ $mm_proto->oneliner('s/ ^ \s* \# \s* \*\*\* .+ \n ( ^ \s* \# \s*? \n )? //xmg', [qw( -0777 -p -i.arghwin32 )] ) ]} \$(DISTVNAME)/AUTHORS
125@{[ $crlf_fixup->( '$(DISTVNAME)/AUTHORS' ) ]}
126\t\$(RM_F) \$(DISTVNAME)/AUTHORS.arghwin32
3440100b 127
128EOP
129}
130
131
204f57da 132# on some OSes generated files may have an incorrect \n - fix it
133# so that the xt tests pass on a fresh checkout (also shipping a
134# dist with CRLFs is beyond obnoxious)
204f57da 135if ($^O eq 'MSWin32' or $^O eq 'cygwin') {
204f57da 136 {
137 local $ENV{PERLIO} = 'unix';
138 system( $^X, qw( -MExtUtils::Command -e dos2unix -- ), $pod_dir );
139 }
140
141 postamble <<"EOP";
142
ffce4b65 143clonedir_post_generate_files : pod_crlf_fixup
204f57da 144
ffce4b65 145pod_crlf_fixup :
146@{[ $crlf_fixup->($pod_dir) ]}
204f57da 147
148EOP
149}
150
a0c96f24 151{
152 postamble <<"EOP";
153
154clonedir_post_generate_files : dbic_clonedir_copy_generated_pod
155
156dbic_clonedir_copy_generated_pod :
95252a8c 157\t\$(RM_F) $pod_dir.packlist
3ba58fe4 158\t@{[
aff5e9c1 159 $mm_proto->oneliner("install([ from_to => {q($pod_dir) => './', write => q($pod_dir.packlist)}, verbose => 0, uninstall_shadows => 0, skip => [] ])", ['-MExtUtils::Install'])
3ba58fe4 160]}
ffce4b65 161
a0c96f24 162EOP
163}
164
165
3e2a5d5d 166# everything that came from $pod_dir, needs to be removed from the workdir
a0c96f24 167{
168 postamble <<"EOP";
169
170clonedir_cleanup_generated_files : dbic_clonedir_cleanup_generated_pod_copies
171
172dbic_clonedir_cleanup_generated_pod_copies :
ad944588 173\t@{[ $mm_proto->oneliner('chomp && unlink || die', ['-n']) ]} $pod_dir.packlist
174\t\$(RM_F) $pod_dir.packlist
a14c7707 175
176EOP
177}
178
179# keep the Makefile.PL eval happy
1801;