add SQLT dep if DBICTEST_SQLT_DEPLOY env is set
[dbsrgits/DBIx-Class.git] / Makefile.PL
1 use strict;
2 use warnings;
3
4 use 5.008001;
5 use inc::Module::Install 1.00;
6
7 ##
8 ## DO NOT USE THIS HACK IN YOUR DISTS!!! (it makes #toolchain sad)
9 ##
10 # get cpanX --installdeps . to behave in a checkout (most users do not expect
11 # the deps for a full test suite run, and if they do - there's MI::AutoInstall
12 # for that)
13 BEGIN {
14   $Module::Install::AUTHOR = 0 if (grep { $ENV{"PERL5_${_}_IS_RUNNING"} } (qw/CPANM CPANPLUS CPAN/) );
15 }
16
17 name     'DBIx-Class';
18 perl_version '5.008001';
19 all_from 'lib/DBIx/Class.pm';
20
21 tests_recursive (qw|
22     t
23 |);
24
25 install_script (qw|
26     script/dbicadmin
27 |);
28
29 homepage 'http://www.dbix-class.org/';
30 resources 'IRC'         => 'irc://irc.perl.org/#dbix-class';
31 resources 'license'     => 'http://dev.perl.org/licenses/';
32 resources 'repository'  => 'git://git.shadowcat.co.uk/dbsrgits/DBIx-Class.git';
33 resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class';
34 resources 'bugtracker'  => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class';
35
36 ###
37 ### DO NOT ADD OPTIONAL DEPENDENCIES HERE, EVEN AS recommends()
38 ### All of them *MUST* go to DBIx::Class::Optional::Dependencies
39 ###
40 my $runtime_requires = {
41   # FIXME - temporary, needs throwing out for something more efficient
42   'Data::Compare'            => '1.22',
43
44   # DBI itself should be capable of installation and execution in pure-perl
45   # mode. However it has never been tested yet, so consider XS for the time
46   # being
47   'DBI'                      => '1.57',
48
49   # XS (or XS-dependent) libs
50   'Sub::Name'                => '0.04',
51
52   # pure-perl (FatPack-able) libs
53   'Class::Accessor::Grouped' => '0.10002',
54   'Class::C3::Componentised' => '1.0009',
55   'Class::Inspector'         => '1.24',
56   'Config::Any'              => '0.20',
57   'Context::Preserve'        => '0.01',
58   'Data::Dumper::Concise'    => '2.020',
59   'Data::Page'               => '2.00',
60   'Hash::Merge'              => '0.12',
61   'Moo'                      => '0.009013',
62   'MRO::Compat'              => '0.09',
63   'Module::Find'             => '0.06',
64   'namespace::clean'         => '0.20',
65   'Path::Class'              => '0.18',
66   'Scope::Guard'             => '0.03',
67   'SQL::Abstract'            => '1.72',
68   'Try::Tiny'                => '0.04',
69
70   # dual-life corelibs needing a specific bugfixed version
71   'File::Path'               => '2.07',
72 };
73
74 my $build_requires = {
75   # needed for testing only, not for operation
76   # we will move away from this dep eventually, perhaps to DBD::CSV or something
77   'DBD::SQLite'              => '1.29',
78 };
79
80 my $test_requires = {
81   'File::Temp'               => '0.22',
82   'Test::Exception'          => '0.31',
83   'Test::Warn'               => '0.21',
84   'Test::More'               => '0.94',
85   # not sure if this is necessary at all, ask schwern some day
86   'Test::Builder'            => '0.94',
87
88   # this is already a dep of n::c, but just in case - used by t/55namespaces_cleaned.t
89   # remove and do a manual glob-collection if n::c is no longer a dep
90   'Package::Stash'           => '0.28',
91 };
92
93 # make strictures.pm happy (DO NOT LIKE, TOO MUCH XS!)
94 # (i.e. what if the .git/.svn is *not* because of DBIC?)
95 #
96 # Note - this is added as test_requires *directly*, so it gets properly
97 # excluded on META.yml cleansing
98 if (-e '.git' or -e '.svn') {
99   test_requires 'indirect'              => '0.25';
100   test_requires 'multidimensional'      => '0.008';
101   test_requires 'bareword::filehandles' => '0.003';
102 }
103
104 # Bail out on parallel testing
105 if (
106   ($ENV{HARNESS_OPTIONS}||'') =~ / (?: ^ | \: ) j(\d+) /x
107     and
108   $1 > 1
109 ) { die <<EOP }
110
111 ******************************************************************************
112 ******************************************************************************
113 ***                                                                        ***
114 ***      PARALLEL TESTING DETECTED ( \$ENV{HARNESS_OPTIONS} = 'j$1' )        ***
115 ***                                                                        ***
116 *** DBIC tests WILL FAIL. It is harder to make them parallel-friendly than ***
117 *** it should be (though work is underway). In the meantime you will have  ***
118 *** to adjust your environment and re-run the installation. Sorry!         ***
119 ***                                                                        ***
120 ******************************************************************************
121 ******************************************************************************
122
123 EOP
124
125 # this is so we can order requires alphabetically
126 # copies are needed for potential author requires injection
127 my $reqs = {
128   build_requires => { %$build_requires },
129   requires => { %$runtime_requires },
130   test_requires => { %$test_requires },
131 };
132
133 # only do author-includes if not part of a `make` run
134 if ($Module::Install::AUTHOR  and ! $ENV{MAKELEVEL}) {
135   # get options here, make $args available to all snippets
136   require Getopt::Long;
137   my $getopt = Getopt::Long::Parser->new(
138     config => [qw/gnu_getopt bundling_override no_ignore_case pass_through/]
139   );
140   my $args = {
141     skip_author_deps => undef,
142   };
143   $getopt->getoptions($args, qw/
144     skip_author_deps|skip-author-deps
145   /);
146   if (@ARGV) {
147     warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
148   }
149
150   require File::Spec;
151   # string-eval, not do(), because we need to provide the
152   # $reqs and $*_requires lexicals to the included file
153   # (some includes *do* modify $reqs above)
154   for (sort glob ( File::Spec->catfile('maint', 'Makefile.PL.inc', '*') ) ) {
155     eval scalar do { local (@ARGV, $/) = $_; <> }
156       or die ($@ || $!);
157   }
158 }
159 else {
160   # make sure this Makefile can not be used to make a dist
161   # (without the author includes there are no meta cleanup, no sanity checks, etc)
162   postamble <<EOP;
163 .PHONY: nonauthor_stop_distdir_creation
164 create_distdir: nonauthor_stop_distdir_creation
165 nonauthor_stop_distdir_creation:
166 \t\$(NOECHO) \$(ECHO) Creation of dists in non-author mode is not allowed
167 \t\$(NOECHO) \$(FALSE)
168 EOP
169
170   # if the user has this env var set and no SQLT installed, tests will fail
171   # same rationale for direct test_requires as the strictures stuff above
172   # (even though no dist will be created from this)
173   if ($ENV{DBICTEST_SQLT_DEPLOY}) {
174     local @INC = ('lib', @INC);
175     require DBIx::Class::Optional::Dependencies;
176     my $dep_req = DBIx::Class::Optional::Dependencies->req_list_for('deploy');
177     for (keys %$dep_req) {
178       test_requires ($_ => $dep_req->{$_})
179     }
180   }
181 }
182
183 # compose final req list, for alphabetical ordering
184 my %final_req;
185 for my $rtype (keys %$reqs) {
186   for my $mod (keys %{$reqs->{$rtype}} ) {
187
188     # sanity check req duplications
189     if ($final_req{$mod}) {
190       die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n";
191     }
192
193     $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ],
194   }
195 }
196
197 # actual require
198 for my $mod (sort keys %final_req) {
199   my ($rtype, $ver) = @{$final_req{$mod}};
200   no strict 'refs';
201   $rtype->($mod, $ver);
202 }
203
204 # author-mode or not - this is where we show a list of missing deps
205 # IFF we are running interactively
206 auto_install();
207
208 WriteAll();