Remove the transparrent hook lazy-pager-count experiment
[dbsrgits/DBIx-Class.git] / Makefile.PL
CommitLineData
47a4aa51 1use inc::Module::Install 1.00;
fe650234 2use strict;
3use warnings;
4
55087b99 5use 5.008001;
ce4c07df 6
8057ed01 7use FindBin;
8use lib "$FindBin::Bin/lib";
2f5a6e87 9use DBIx::Class::Optional::Dependencies;
93c50889 10
d1dc7a98 11# get cpanX --installdeps . to behave in a checkout (most users do not need
12# the deps for a full test suite run, and if they do - there's MI::AutoInstall
13# for that)
14##
15## DO NOT USE THIS HACK IN YOUR DISTS!!! (it makes #toolchain sad)
16##
17$Module::Install::AUTHOR = 0 if (grep { $ENV{"PERL5_${_}_IS_RUNNING"} } (qw/CPANM CPANPLUS CPAN/) );
18
4b5544ad 19###
20### DO NOT ADD OPTIONAL DEPENDENCIES HERE, EVEN AS recommends()
21### All of them should go to DBIx::Class::Optional::Dependencies
22###
23
ce4c07df 24name 'DBIx-Class';
b50d0dd3 25perl_version '5.008001';
8e0f16f1 26all_from 'lib/DBIx/Class.pm';
ce4c07df 27
8057ed01 28my $build_requires = {
79680fc0 29 # needed for testing only, not for operation
b9df8e39 30 'DBD::SQLite' => '1.29',
8057ed01 31};
32
33my $test_requires = {
30da8374 34 'File::Temp' => '0.22',
35 'Test::Builder' => '0.33',
0007aedf 36 'Test::Exception' => '0.31',
30da8374 37 'Test::More' => '0.92',
38 'Test::Warn' => '0.21',
90cfe42b 39
40 # this is already a dep of n::c, but just in case - used by t/55namespaces_cleaned.t
41 # remove and do a manual glob-collection if n::c is no longer a dep
42 'Package::Stash' => '0.28',
8057ed01 43};
44
45my $runtime_requires = {
b8d22f13 46 'Class::Accessor::Grouped' => '0.10002',
9c1700e3 47 'Class::C3::Componentised' => '1.0009',
8057ed01 48 'Class::Inspector' => '1.24',
79680fc0 49 'Config::Any' => '0.20',
50 'Context::Preserve' => '0.01',
2b8cc2f2 51 'Data::Dumper::Concise' => '2.020',
8057ed01 52 'Data::Page' => '2.00',
b8d22f13 53 'Hash::Merge' => '0.12',
8057ed01 54 'MRO::Compat' => '0.09',
55 'Module::Find' => '0.06',
cd122820 56 'namespace::clean' => '0.20',
f4d7449c 57 'Path::Class' => '0.18',
b7b18f32 58 'Scope::Guard' => '0.03',
bf51641f 59 'SQL::Abstract' => '1.72',
20674fcd 60 'Try::Tiny' => '0.04',
79680fc0 61
62 # XS (or XS-dependent) libs
997a3638 63 'DBI' => '1.57',
79680fc0 64 'Sub::Name' => '0.04',
79680fc0 65
c7d50a7d 66 # dual-life corelibs needing a specific bugfixed version
79680fc0 67 'File::Path' => '2.07',
cd122820 68
69 # FIXME - temporary, needs throwing out for something more efficient
70 'Data::Compare' => '1.22',
8057ed01 71};
72
bb7950c0 73
74# Bail out on parallel testing
75if (
76 ($ENV{HARNESS_OPTIONS}||'') =~ / (?: ^ | \: ) j(\d+) /x
77 and
78 $1 > 1
79) { die <<EOP }
80
81******************************************************************************
82******************************************************************************
83*** ***
84*** PARALLEL TESTING DETECTED ( \$ENV{HARNESS_OPTIONS} = 'j$1' ) ***
85*** ***
86*** DBIC tests will fail. It is harder to make them parallel-friendly than ***
87*** it should be (though work is underway). In the meantime you will have ***
88*** to adjust your environment and re-run the installation. Sorry! ***
89*** ***
90******************************************************************************
91******************************************************************************
92
93EOP
94
95require Getopt::Long;
96my $getopt = Getopt::Long::Parser->new(
97 config => [qw/gnu_getopt bundling_override no_ignore_case pass_through/]
98);
99my $args = {
100 skip_author_deps => undef,
101};
102$getopt->getoptions($args, 'skip_author_deps');
103if (@ARGV) {
104 warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
105}
106
8057ed01 107# this is so we can order requires alphabetically
108# copies are needed for author requires injection
109my $reqs = {
110 build_requires => { %$build_requires },
111 requires => { %$runtime_requires },
112 test_requires => { %$test_requires },
113};
3a4251e2 114
be68095d 115my %reqs_for_group = %{DBIx::Class::Optional::Dependencies->req_group_list};
116
117# exclude the rdbms_* groups which are for DBIC users
2f5a6e87 118my $opt_testdeps = {
be68095d 119 map { %{$reqs_for_group{$_}} } grep { !/^rdbms_/ } keys %reqs_for_group
2f5a6e87 120};
8057ed01 121
92f8f62a 122# require extra modules for testing if we're in a checkout
0424d17a 123my $optdep_msg;
92f8f62a 124if ($Module::Install::AUTHOR) {
0424d17a 125 if ($args->{skip_author_deps}) {
126 $optdep_msg = <<'EOW';
127
128******************************************************************************
129******************************************************************************
130*** ***
131*** IGNORING AUTHOR MODE: no optional test dependencies will be forced. ***
132*** ***
133*** If you are using this checkout with the intention of submitting a DBIC ***
134*** patch, you are *STRONGLY ENCOURAGED* to install all dependencies, so ***
135*** that every possible unit-test will run. ***
136*** ***
137******************************************************************************
138******************************************************************************
139
140EOW
141 }
142 else {
143 $optdep_msg = <<'EOW';
144
8057ed01 145******************************************************************************
146******************************************************************************
147*** ***
148*** AUTHOR MODE: all optional test dependencies converted to hard requires ***
7adae31a 149*** ( to disable re-run Makefile.PL with --skip_author_deps ) ***
8057ed01 150*** ***
151******************************************************************************
152******************************************************************************
153
154EOW
155
0424d17a 156 $reqs->{test_requires} = {
157 %{$reqs->{test_requires}},
2f5a6e87 158 %$opt_testdeps
0424d17a 159 };
160 }
8057ed01 161}
162
163# compose final req list, for alphabetical ordering
164my %final_req;
165for my $rtype (keys %$reqs) {
166 for my $mod (keys %{$reqs->{$rtype}} ) {
167
168 # sanity check req duplications
169 if ($final_req{$mod}) {
b718fd0a 170 die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n";
8057ed01 171 }
172
173 $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ],
174 }
175}
176
177# actual require
178for my $mod (sort keys %final_req) {
179 my ($rtype, $ver) = @{$final_req{$mod}};
180 no strict 'refs';
181 $rtype->($mod, $ver);
182}
a410299d 183
0424d17a 184# output twice since the deplist is > 70 lines
f90896ae 185warn $optdep_msg if $Module::Install::AUTHOR;
92f8f62a 186auto_install();
f90896ae 187warn $optdep_msg if $Module::Install::AUTHOR;
92f8f62a 188
4557be61 189
92f8f62a 190# re-create various autogenerated documentation bits
191if ($Module::Install::AUTHOR) {
192
bb7950c0 193 # adjust ENV for $AUTHOR system() calls
194 require Config;
195 $ENV{PERL5LIB} = join ($Config::Config{path_sep}, @INC);
196
92f8f62a 197 print "Regenerating README\n";
198 system('pod2text lib/DBIx/Class.pm > README');
199
200 if (-f 'MANIFEST') {
201 print "Removing MANIFEST\n";
202 unlink 'MANIFEST';
203 }
204
92f8f62a 205 print "Regenerating Optional/Dependencies.pod\n";
206 require DBIx::Class::Optional::Dependencies;
ccebe1f1 207 DBIx::Class::Optional::Dependencies->_gen_pod (Meta->version);
92f8f62a 208
209 # FIXME Disabled due to unsolved issues, ask theorbtwo
210 # require Module::Install::Pod::Inherit;
211 # PodInherit();
212}
213
f90896ae 214
7eaae8db 215tests_recursive (qw|
216 t
217|);
218
f90896ae 219# temporary(?) until I get around to fix M::I wrt xt/
220# needs Module::Install::AuthorTests
c1fdb460 221eval {
c5e9d46d 222 # this should not be necessary since the autoloader is supposed
223 # to work, but there were reports of it failing
224 require Module::Install::AuthorTests;
7f2c37b8 225 recursive_author_tests (qw/xt/);
226 1;
227} || do {
d1dc7a98 228 if ($Module::Install::AUTHOR && ! $args->{skip_author_deps}) {
22a2062e 229 my $err = $@;
c5e9d46d 230
231 # better error message in case of missing dep
22a2062e 232 eval { require Module::Install::AuthorTests }
eeaf8701 233 || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode (or supply --skip_author_deps):\n\n$@\n";
c5e9d46d 234
235 die $err;
22a2062e 236 }
7f2c37b8 237};
f90896ae 238
239
a410299d 240install_script (qw|
241 script/dbicadmin
242|);
243
7eaae8db 244
245### Mangle makefile - read the comments for more info
246#
247postamble <<"EOP";
248
249# This will add an extra dep-spec for the distdir target,
250# which `make` will fold together in a first-come first-serve
251# fashion. What we do here is essentially adding extra
252# commands to execute once the distdir is assembled (via
253# create_distdir), but before control is returned to a higher
254# calling rule.
255distdir : dbicadmin_pod_inject
256
257# The pod self-injection code is in fact a hidden option in
258# dbicadmin itself
259dbicadmin_pod_inject :
260\tcd \$(DISTVNAME) && \$(ABSPERL) -Ilib script/dbicadmin --selfinject-pod
261
262# Regenerate manifest before running create_distdir.
263create_distdir : manifest
264
265EOP
266
f90896ae 267homepage 'http://www.dbix-class.org/';
a410299d 268resources 'IRC' => 'irc://irc.perl.org/#dbix-class';
269resources 'license' => 'http://dev.perl.org/licenses/';
aeb669b8 270resources 'repository' => 'git://git.shadowcat.co.uk/dbsrgits/DBIx-Class.git';
a410299d 271resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class';
70fbb0b8 272resources 'bugtracker' => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class';
a410299d 273
974fe5e8 274# Deprecated/internal modules need no exposure
275no_index directory => $_ for (qw|
bc6f129c 276 lib/DBIx/Class/Admin
281738a4 277 lib/DBIx/Class/PK/Auto
bc6f129c 278 lib/DBIx/Class/CDBICompat
974fe5e8 279|);
280no_index package => $_ for (qw/
d5dedbd6 281 DBIx::Class::Storage::DBIHacks
70c28808 282 DBIx::Class::Carp
cd122820 283 DBIx::Class::ResultSet::Pager
974fe5e8 284/);
a410299d 285
713cc98e 286WriteAll();
09d46657 287
2f5a6e87 288# Re-write META.yml to _exclude_ all forced build-requires (we do not want to ship
289# this) We are also not using M::I::AuthorRequires as this will be an extra dep,
290# and deps in Makefile.PL still suck
291# Also always test the result so we stop shipping borked dependency lists to CPAN
713cc98e 292
2f5a6e87 293# FIXME test_requires is not yet part of META
294my %original_build_requires = ( %$build_requires, %$test_requires );
295my @all_build_requires = @{delete Meta->{values}{build_requires}};
296my %removed_build_requires;
8057ed01 297
2f5a6e87 298for (@all_build_requires) {
299 if ($original_build_requires{$_->[0]}) {
300 push @{Meta->{values}{build_requires}}, $_;
301 }
302 else {
303 $removed_build_requires{$_->[0]} = $_->[1]
304 unless $_->[0] eq 'ExtUtils::MakeMaker';
1278e5f0 305 }
2f5a6e87 306}
713cc98e 307
2f5a6e87 308# Rewrite only in author mode, the original META should not contain anything anyway
309# if we executed as non-author
310if ($Module::Install::AUTHOR && keys %removed_build_requires) {
1278e5f0 311 print "Regenerating META with author requires excluded\n";
713cc98e 312 Meta->write;
2f5a6e87 313}
1278e5f0 314
2f5a6e87 315# test that we really took things away (just in case, happened twice somehow)
b8d22f13 316if (! -f 'META.yml') {
317 warn "No META.yml generated?! aborting...\n";
318 exit 1;
319}
2f5a6e87 320my $meta = do { local @ARGV = 'META.yml'; local $/; <> };
321
322# this is safe as there is a fatal check earlier to make sure $opt_testdeps does
323# not contain any real dependencies
324my @illegal_leftovers = grep
325 { $meta =~ /^ \s+ \Q$_\E \: \s+ /mx }
326 ( sort keys %$opt_testdeps )
327;
328
329if (@illegal_leftovers) {
330 die join ("\n",
331 "\n\nFATAL FAIL! It looks like some author dependencies made it to the META.yml:\n",
332 map { "\t$_" } @illegal_leftovers
333 ) . "\n\n";
09d46657 334}