Enhance 19b088d1 to add SQLT dep regardless of Makefile mode
[dbsrgits/DBIx-Class.git] / Makefile.PL
1 use strict;
2 use warnings;
3
4 use 5.008001;
5 use inc::Module::Install 1.06;
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   'Class::Method::Modifiers' => '1.06',
57   'Config::Any'              => '0.20',
58   'Context::Preserve'        => '0.01',
59   'Data::Dumper::Concise'    => '2.020',
60   'Data::Page'               => '2.00',
61   'Hash::Merge'              => '0.12',
62   'Moo'                      => '0.009013',
63   'MRO::Compat'              => '0.09',
64   'Module::Find'             => '0.06',
65   'namespace::clean'         => '0.20',
66   'Path::Class'              => '0.18',
67   'Scope::Guard'             => '0.03',
68   'SQL::Abstract'            => '1.72',
69   'Try::Tiny'                => '0.04',
70
71   # dual-life corelibs needing a specific bugfixed version
72   'File::Path'               => '2.07',
73 };
74
75 my $build_requires = {
76   # needed for testing only, not for operation
77   # we will move away from this dep eventually, perhaps to DBD::CSV or something
78   'DBD::SQLite'              => '1.29',
79 };
80
81 my $test_requires = {
82   'File::Temp'               => '0.22',
83   'Test::Exception'          => '0.31',
84   'Test::Warn'               => '0.21',
85   'Test::More'               => '0.94',
86   # not sure if this is necessary at all, ask schwern some day
87   'Test::Builder'            => '0.94',
88
89   # this is already a dep of n::c, but just in case - used by t/55namespaces_cleaned.t
90   # remove and do a manual glob-collection if n::c is no longer a dep
91   'Package::Stash'           => '0.28',
92 };
93
94 # make strictures.pm happy (DO NOT LIKE, TOO MUCH XS!)
95 # (i.e. what if the .git/.svn is *not* because of DBIC?)
96 #
97 # Note - this is added as test_requires *directly*, so it gets properly
98 # excluded on META.yml cleansing
99 if (-e '.git' or -e '.svn') {
100   test_requires 'indirect'              => '0.25';
101   test_requires 'multidimensional'      => '0.008';
102   test_requires 'bareword::filehandles' => '0.003';
103 }
104
105 # if the user has this env var set and no SQLT installed, tests will fail
106 # same rationale for direct test_requires as the strictures stuff above
107 # (even though no dist will be created from this)
108 # we force this req regarless of author_deps, worst case scenario it will
109 # be specified twice
110 if ($ENV{DBICTEST_SQLT_DEPLOY}) {
111   local @INC = ('lib', @INC);
112   require DBIx::Class::Optional::Dependencies;
113   my $dep_req = DBIx::Class::Optional::Dependencies->req_list_for('deploy');
114   for (keys %$dep_req) {
115     test_requires ($_ => $dep_req->{$_})
116   }
117 }
118
119 # Bail out on parallel testing
120 if (
121   ($ENV{HARNESS_OPTIONS}||'') =~ / (?: ^ | \: ) j(\d+) /x
122     and
123   $1 > 1
124 ) { die <<EOP }
125
126 ******************************************************************************
127 ******************************************************************************
128 ***                                                                        ***
129 ***      PARALLEL TESTING DETECTED ( \$ENV{HARNESS_OPTIONS} = 'j$1' )        ***
130 ***                                                                        ***
131 *** DBIC tests WILL FAIL. It is harder to make them parallel-friendly than ***
132 *** it should be (though work is underway). In the meantime you will have  ***
133 *** to adjust your environment and re-run the installation. Sorry!         ***
134 ***                                                                        ***
135 ******************************************************************************
136 ******************************************************************************
137
138 EOP
139
140 # this is so we can order requires alphabetically
141 # copies are needed for potential author requires injection
142 my $reqs = {
143   build_requires => { %$build_requires },
144   requires => { %$runtime_requires },
145   test_requires => { %$test_requires },
146 };
147
148 # only do author-includes if not part of a `make` run
149 if ($Module::Install::AUTHOR  and ! $ENV{MAKELEVEL}) {
150   # get options here, make $args available to all snippets
151   require Getopt::Long;
152   my $getopt = Getopt::Long::Parser->new(
153     config => [qw/gnu_getopt bundling_override no_ignore_case pass_through/]
154   );
155   my $args = {
156     skip_author_deps => undef,
157   };
158   $getopt->getoptions($args, qw/
159     skip_author_deps|skip-author-deps
160   /);
161   if (@ARGV) {
162     warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
163   }
164
165   require File::Spec;
166   # string-eval, not do(), because we need to provide the
167   # $reqs and $*_requires lexicals to the included file
168   # (some includes *do* modify $reqs above)
169   for (sort glob ( File::Spec->catfile('maint', 'Makefile.PL.inc', '*') ) ) {
170     eval scalar do { local (@ARGV, $/) = $_; <> }
171       or die ($@ || $!);
172   }
173 }
174 else {
175   # make sure this Makefile can not be used to make a dist
176   # (without the author includes there are no meta cleanup, no sanity checks, etc)
177   postamble <<EOP;
178 .PHONY: nonauthor_stop_distdir_creation
179 create_distdir: nonauthor_stop_distdir_creation
180 nonauthor_stop_distdir_creation:
181 \t\$(NOECHO) \$(ECHO) Creation of dists in non-author mode is not allowed
182 \t\$(NOECHO) \$(FALSE)
183 EOP
184 }
185
186 # compose final req list, for alphabetical ordering
187 my %final_req;
188 for my $rtype (keys %$reqs) {
189   for my $mod (keys %{$reqs->{$rtype}} ) {
190
191     # sanity check req duplications
192     if ($final_req{$mod}) {
193       die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n";
194     }
195
196     $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ],
197   }
198 }
199
200 # actual require
201 for my $mod (sort keys %final_req) {
202   my ($rtype, $ver) = @{$final_req{$mod}};
203   no strict 'refs';
204   $rtype->($mod, $ver);
205 }
206
207 # author-mode or not - this is where we show a list of missing deps
208 # IFF we are running interactively
209 auto_install();
210
211 WriteAll();