Cleanup the makefile regen a bit
[dbsrgits/DBIx-Class.git] / Makefile.PL
1 use inc::Module::Install 0.93;
2 use strict;
3 use warnings;
4 use POSIX ();
5
6 use 5.008001;
7
8 use FindBin;
9 use lib "$FindBin::Bin/lib";
10
11 # adjust ENV for $AUTHOR system() calls
12 use Config;
13 $ENV{PERL5LIB} = join ($Config{path_sep}, @INC);
14
15
16 ###
17 ### DO NOT ADD OPTIONAL DEPENDENCIES HERE, EVEN AS recommends()
18 ### All of them should go to DBIx::Class::Optional::Dependencies
19 ###
20
21
22 name     'DBIx-Class';
23 perl_version '5.008001';
24 all_from 'lib/DBIx/Class.pm';
25
26 my $build_requires = {
27   'DBD::SQLite'              => '1.25',
28 };
29
30 my $test_requires = {
31   'File::Temp'               => '0.22',
32   'Test::Builder'            => '0.33',
33   'Test::Deep'               => '0',
34   'Test::Exception'          => '0',
35   'Test::More'               => '0.92',
36   'Test::Warn'               => '0.21',
37 };
38
39 my $runtime_requires = {
40   # Core
41   'List::Util'               => '0',
42   'Scalar::Util'             => '0',
43   'Storable'                 => '0',
44
45   # Dependencies
46   'Carp::Clan'               => '6.0',
47   'Class::Accessor::Grouped' => '0.09002',
48   'Class::C3::Componentised' => '1.0005',
49   'Class::Inspector'         => '1.24',
50   'Data::Page'               => '2.00',
51   'DBI'                      => '1.609',
52   'MRO::Compat'              => '0.09',
53   'Module::Find'             => '0.06',
54   'Path::Class'              => '0.18',
55   'Scope::Guard'             => '0.03',
56   'SQL::Abstract'            => '1.61',
57   'SQL::Abstract::Limit'     => '0.13',
58   'Sub::Name'                => '0.04',
59   'Data::Dumper::Concise'    => '1.000',
60 };
61
62 # this is so we can order requires alphabetically
63 # copies are needed for author requires injection
64 my $reqs = {
65   build_requires => { %$build_requires },
66   requires => { %$runtime_requires },
67   test_requires => { %$test_requires },
68 };
69
70 # autogenerate docs and require extra modules for testing if we're in a checkout
71 if ($Module::Install::AUTHOR) {
72
73   print "Regenerating README\n";
74   system('pod2text lib/DBIx/Class.pm > README');
75
76   if (-f 'MANIFEST') {
77     print "Removing MANIFEST\n";
78     unlink 'MANIFEST';
79   }
80
81   print "Regenerating dbicadmin.pod\n";
82   system('perl script/dbicadmin --pod > lib/dbicadmin.pod');
83
84   print "Regenerating Optional/Dependencies.pod\n";
85   require DBIx::Class::Optional::Dependencies;
86   DBIx::Class::Optional::Dependencies->_gen_pod;
87
88 # FIXME Disabled due to unsolved issues, ask theorbtwo
89 #  require Module::Install::Pod::Inherit;
90 #  PodInherit();
91
92   warn <<'EOW';
93 ******************************************************************************
94 ******************************************************************************
95 ***                                                                        ***
96 *** AUTHOR MODE: all optional test dependencies converted to hard requires ***
97 ***                                                                        ***
98 ******************************************************************************
99 ******************************************************************************
100
101 EOW
102
103   $reqs->{test_requires} = {
104     %{$reqs->{test_requires}},
105     %{DBIx::Class::Optional::Dependencies->_all_optional_requirements},
106   };
107 }
108
109 # compose final req list, for alphabetical ordering
110 my %final_req;
111 for my $rtype (keys %$reqs) {
112   for my $mod (keys %{$reqs->{$rtype}} ) {
113
114     # sanity check req duplications
115     if ($final_req{$mod}) {
116       die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n";
117     }
118
119     $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ],
120   }
121 }
122
123 # actual require
124 for my $mod (sort keys %final_req) {
125   my ($rtype, $ver) = @{$final_req{$mod}};
126   no strict 'refs';
127   $rtype->($mod, $ver);
128 }
129
130 install_script (qw|
131     script/dbicadmin
132 |);
133
134 tests_recursive (qw|
135     t
136 |);
137
138 resources 'IRC'         => 'irc://irc.perl.org/#dbix-class';
139 resources 'license'     => 'http://dev.perl.org/licenses/';
140 resources 'repository'  => 'http://dev.catalyst.perl.org/repos/bast/DBIx-Class/';
141 resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class';
142
143 # Deprecated/internal modules need no exposure
144 no_index directory => $_ for (qw|
145   lib/DBIx/Class/SQLAHacks
146   lib/DBIx/Class/PK/Auto
147 |);
148 no_index package => $_ for (qw/
149   DBIx::Class::Storage::DBI::AmbiguousGlob
150   DBIx::Class::SQLAHacks DBIx::Class::Storage::DBIHacks
151 /);
152
153
154 auto_install();
155
156 WriteAll();
157
158
159 # Re-write META.yml to _exclude_ all forced requires (we do not want to ship this)
160 if ($Module::Install::AUTHOR) {
161
162   # FIXME test_requires is not yet part of META
163   my %original_build_requires = ( %$build_requires, %$test_requires );
164
165   print "Regenerating META with author requires excluded\n";
166   Meta->{values}{build_requires} = [ grep
167     { exists $original_build_requires{$_->[0]} }
168    ( @{Meta->{values}{build_requires}} )
169   ];
170
171   Meta->write;
172 }