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