fixed rels ending with me breaking subquery realiasing
[dbsrgits/DBIx-Class.git] / Makefile.PL
1 use inc::Module::Install 0.97;
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 use Getopt::Long qw/:config gnu_getopt bundling_override no_ignore_case pass_through/;
16 my $args = {
17   skip_author_deps => undef,
18 };
19 GetOptions ($args, 'skip_author_deps');
20 if (@ARGV) {
21   warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
22 }
23
24 ###
25 ### DO NOT ADD OPTIONAL DEPENDENCIES HERE, EVEN AS recommends()
26 ### All of them should go to DBIx::Class::Optional::Dependencies
27 ###
28
29 name     'DBIx-Class';
30 perl_version '5.008001';
31 all_from 'lib/DBIx/Class.pm';
32
33 my $build_requires = {
34   'DBD::SQLite'              => '1.25',
35 };
36
37 my $test_requires = {
38   'File::Temp'               => '0.22',
39   'Test::Builder'            => '0.33',
40   'Test::Exception'          => '0',
41   'Test::More'               => '0.92',
42   'Test::Warn'               => '0.21',
43 };
44
45 my $runtime_requires = {
46   'Carp::Clan'               => '6.0',
47   'Class::Accessor::Grouped' => '0.09003',
48   'Class::C3::Componentised' => '1.0005',
49   'Class::Inspector'         => '1.24',
50   'Data::Page'               => '2.00',
51   'DBI'                      => '1.609',
52   'File::Path'               => '2.07',
53   'MRO::Compat'              => '0.09',
54   'Module::Find'             => '0.06',
55   'Path::Class'              => '0.18',
56   'SQL::Abstract'            => '1.67',
57   'SQL::Abstract::Limit'     => '0.13',
58   'Sub::Name'                => '0.04',
59   'Data::Dumper::Concise'    => '1.000',
60   'Scope::Guard'             => '0.03',
61   'Context::Preserve'        => '0.01',
62   'Try::Tiny'                => '0.04',
63   'namespace::clean'         => '0.14',
64   'Math::BigInt'             => '1.89',
65   'Math::Base36'             => '0.07',
66 };
67
68 # this is so we can order requires alphabetically
69 # copies are needed for author requires injection
70 my $reqs = {
71   build_requires => { %$build_requires },
72   requires => { %$runtime_requires },
73   test_requires => { %$test_requires },
74 };
75
76
77 # require extra modules for testing if we're in a checkout
78 my $optdep_msg;
79 if ($Module::Install::AUTHOR) {
80   if ($args->{skip_author_deps}) {
81     $optdep_msg = <<'EOW';
82
83 ******************************************************************************
84 ******************************************************************************
85 ***                                                                        ***
86 *** IGNORING AUTHOR MODE: no optional test dependencies will be forced.    ***
87 ***                                                                        ***
88 *** If you are using this checkout with the intention of submitting a DBIC ***
89 *** patch, you are *STRONGLY ENCOURAGED* to install all dependencies, so   ***
90 *** that every possible unit-test will run.                                ***
91 ***                                                                        ***
92 ******************************************************************************
93 ******************************************************************************
94
95 EOW
96   }
97   else {
98     $optdep_msg = <<'EOW';
99
100 ******************************************************************************
101 ******************************************************************************
102 ***                                                                        ***
103 *** AUTHOR MODE: all optional test dependencies converted to hard requires ***
104 ***      ( to disabled re-run Makefile.PL with --skip_author_deps )        ***
105 ***                                                                        ***
106 ******************************************************************************
107 ******************************************************************************
108
109 EOW
110
111     require DBIx::Class::Optional::Dependencies;
112     $reqs->{test_requires} = {
113       %{$reqs->{test_requires}},
114       map { %$_ } (values %{DBIx::Class::Optional::Dependencies->req_group_list}),
115     };
116   }
117 }
118
119 # compose final req list, for alphabetical ordering
120 my %final_req;
121 for my $rtype (keys %$reqs) {
122   for my $mod (keys %{$reqs->{$rtype}} ) {
123
124     # sanity check req duplications
125     if ($final_req{$mod}) {
126       die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n";
127     }
128
129     $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ],
130   }
131 }
132
133 # actual require
134 for my $mod (sort keys %final_req) {
135   my ($rtype, $ver) = @{$final_req{$mod}};
136   no strict 'refs';
137   $rtype->($mod, $ver);
138 }
139
140 # output twice since the deplist is > 70 lines
141 warn $optdep_msg if $Module::Install::AUTHOR;
142 auto_install();
143 warn $optdep_msg if $Module::Install::AUTHOR;
144
145 # re-create various autogenerated documentation bits
146 if ($Module::Install::AUTHOR) {
147
148   print "Regenerating README\n";
149   system('pod2text lib/DBIx/Class.pm > README');
150
151   if (-f 'MANIFEST') {
152     print "Removing MANIFEST\n";
153     unlink 'MANIFEST';
154   }
155
156   print "Regenerating Optional/Dependencies.pod\n";
157   require DBIx::Class::Optional::Dependencies;
158   DBIx::Class::Optional::Dependencies->_gen_pod;
159
160   # FIXME Disabled due to unsolved issues, ask theorbtwo
161   #  require Module::Install::Pod::Inherit;
162   #  PodInherit();
163 }
164
165
166 tests_recursive (qw|
167     t
168 |);
169
170 # temporary(?) until I get around to fix M::I wrt xt/
171 # needs Module::Install::AuthorTests
172 eval {
173   recursive_author_tests (qw/xt/);
174   1;
175 } || do {
176   unless ($args->{skip_author_deps}) {
177     my $err = $@;
178     eval { require Module::Install::AuthorTests }
179       || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode (or supply --skip_author_deps):\n\n$@\n";
180     die $@;
181   }
182 };
183
184
185 install_script (qw|
186     script/dbicadmin
187 |);
188
189
190 ### Mangle makefile - read the comments for more info
191 #
192 postamble <<"EOP";
193
194 # This will add an extra dep-spec for the distdir target,
195 # which `make` will fold together in a first-come first-serve
196 # fashion. What we do here is essentially adding extra
197 # commands to execute once the distdir is assembled (via
198 # create_distdir), but before control is returned to a higher
199 # calling rule.
200 distdir : dbicadmin_pod_inject
201
202 # The pod self-injection code is in fact a hidden option in
203 # dbicadmin itself
204 dbicadmin_pod_inject :
205 \tcd \$(DISTVNAME) && \$(ABSPERL) -Ilib script/dbicadmin --selfinject-pod
206
207 # Regenerate manifest before running create_distdir.
208 create_distdir : manifest
209
210 EOP
211
212 homepage 'http://www.dbix-class.org/';
213 resources 'IRC'         => 'irc://irc.perl.org/#dbix-class';
214 resources 'license'     => 'http://dev.perl.org/licenses/';
215 resources 'repository'  => 'git://git.shadowcat.co.uk/dbsrgits/DBIx-Class.git';
216 resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class';
217
218 # Deprecated/internal modules need no exposure
219 no_index directory => $_ for (qw|
220   lib/DBIx/Class/Admin
221   lib/DBIx/Class/SQLAHacks
222   lib/DBIx/Class/PK/Auto
223   lib/DBIx/Class/CDBICompat
224 |);
225 no_index package => $_ for (qw/
226   DBIx::Class::SQLAHacks DBIx::Class::Storage::DBIHacks
227 /);
228
229
230 WriteAll();
231
232 # Re-write META.yml to _exclude_ all forced requires (we do not want to ship this)
233 # We are also not using M::I::AuthorRequires as this will be an extra dep, and
234 # deps in Makefile.PL suck (no autoinstall)
235 if ($Module::Install::AUTHOR && ! $args->{skip_author_deps} ) {
236
237   # FIXME test_requires is not yet part of META
238   my %original_build_requires = ( %$build_requires, %$test_requires );
239   my @all_build_requires = @{delete Meta->{values}{build_requires}};
240   my %removed_build_requires;
241
242   for (@all_build_requires) {
243     if ($original_build_requires{$_->[0]}) {
244       push @{Meta->{values}{build_requires}}, $_;
245     }
246     else {
247       $removed_build_requires{$_->[0]} = $_->[1]
248         unless $_->[0] eq 'ExtUtils::MakeMaker';
249     }
250   }
251
252   print "Regenerating META with author requires excluded\n";
253   Meta->write;
254
255   # test that we really took things away (just in case)
256   my $meta = do { local @ARGV = 'META.yml'; local $/; <> };
257   for (keys %removed_build_requires) {
258     delete $removed_build_requires{$_}
259       unless $meta =~ /^ \s+ $_: \s+ $removed_build_requires{$_} \s* $/mx
260   }
261
262   if (keys %removed_build_requires) {
263     die join ("\n", "\n\nFATAL FAIL! It looks like some author dependencies made it to the META.yml:\n",
264       map { "\t$_" } (keys %removed_build_requires)
265     ) . "\n\n";
266   }
267 }