Rewrite all Makefile oneliners in terms of EU::MM::oneliner
[dbsrgits/DBIx-Class.git] / maint / Makefile.PL.inc / 53_autogen_pod.pl
1 use File::Path();
2 use File::Glob();
3
4 # leftovers in old checkouts
5 unlink 'lib/DBIx/Class/Optional/Dependencies.pod'
6   if -f 'lib/DBIx/Class/Optional/Dependencies.pod';
7 File::Path::rmtree( File::Glob::bsd_glob('.generated_pod'), { verbose => 0 } )
8   if -d '.generated_pod';
9
10 my $pod_dir = 'maint/.Generated_Pod';
11 my $ver = Meta->version;
12
13 # cleanup the generated pod dir (again - kill leftovers from old checkouts)
14 if (-d $pod_dir) {
15   File::Path::rmtree( File::Glob::bsd_glob("$pod_dir/*"), { verbose => 0 } );
16 }
17 else {
18   mkdir $pod_dir or die "Unable to create $pod_dir: $!";
19 }
20
21 # generate the OptDeps pod both in the clone-dir and during the makefile distdir
22 {
23   print "Regenerating Optional/Dependencies.pod\n";
24   require DBIx::Class::Optional::Dependencies;
25   DBIx::Class::Optional::Dependencies->_gen_pod ($ver, $pod_dir);
26
27   postamble <<"EOP";
28
29 clonedir_generate_files : dbic_clonedir_gen_optdeps_pod
30
31 dbic_clonedir_gen_optdeps_pod :
32 \t@{[
33   $mm_proto->oneliner("DBIx::Class::Optional::Dependencies->_gen_pod(q($ver), q($pod_dir))", [qw/-Ilib -MDBIx::Class::Optional::Dependencies/])
34 ]}
35
36 EOP
37 }
38
39
40 # generate the inherit pods both in the clone-dir and during the makefile distdir
41 {
42   print "Regenerating project documentation to include inherited methods\n";
43
44   # if the author doesn't have them, don't fail the initial "perl Makefile.pl" step
45   do "maint/gen_pod_inherit" or print "\n!!! FAILED: $@\n";
46
47   postamble <<"EOP";
48
49 clonedir_generate_files : dbic_clonedir_gen_inherit_pods
50
51 dbic_clonedir_gen_inherit_pods :
52 \t\$(ABSPERLRUN) -Ilib maint/gen_pod_inherit
53
54 EOP
55 }
56
57
58 # copy the contents of $pod_dir over to lib/
59 # (yes, overwriting is fine, though nothing should reside there)
60 {
61   postamble <<"EOP";
62
63 clonedir_post_generate_files : dbic_clonedir_copy_generated_pod
64
65 dbic_clonedir_copy_generated_pod :
66 \t\$(RM_F) $pod_dir.packlist
67 \t@{[
68   $mm_proto->oneliner("install([ from_to => {q($pod_dir) => 'lib', write => q($pod_dir.packlist)}, verbose => 0, uninstall_shadows => 0, skip => [] ])", ['-MExtUtils::Install'])
69 ]}
70 EOP
71 }
72
73
74 # everything that came from $pod_dir, needs to be removed from our lib/
75 {
76   postamble <<"EOP";
77
78 clonedir_cleanup_generated_files : dbic_clonedir_cleanup_generated_pod_copies
79
80 dbic_clonedir_cleanup_generated_pod_copies :
81 \t@{[
82   $mm_proto->oneliner("uninstall(q($pod_dir.packlist))", ['-MExtUtils::Install'])
83 ]}
84
85 EOP
86 }
87
88 # keep the Makefile.PL eval happy
89 1;