Merge branch 'master' into dq2eb
[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 ## TEMPORARY (and non-portable)
9 ## Get the dq stuff
10 ##
11 `rm -rf t/dqlib`;
12 `mkdir t/dqlib`;
13 for (
14   [ 'Data-Query' => 'master' ],
15   [ 'SQL-Abstract' => 'dq' ],
16 ) {
17   my $tdir = '/tmp/dqlib_tmp_clone';
18
19   `rm -rf $tdir`;
20
21   `GIT_SSH=maint/careless_ssh.bash git clone --quiet git://git.shadowcat.co.uk/dbsrgits/$_->[0] $tdir`;
22   printf "\nIncluding %s git rev %s\n",
23     $_->[0],
24     scalar `GIT_DIR=$tdir/.git git rev-parse origin/$_->[1]`,
25   ;
26   `git archive --format=tar --remote=file://$tdir origin/$_->[1] lib/ | tar --strip-components=1 -xC t/dqlib`;
27
28   `rm -rf $tdir`;
29 }
30 `cpanm SQL::ReservedWords 2>&1`;
31 use lib 't/dqlib';
32
33
34 ##
35 ## DO NOT USE THIS HACK IN YOUR DISTS!!! (it makes #toolchain sad)
36 ##
37 # get cpanX --installdeps . to behave in a checkout (most users do not expect
38 # the deps for a full test suite run, and if they do - there's MI::AutoInstall
39 # for that)
40 BEGIN {
41   $Module::Install::AUTHOR = 0 if (grep { $ENV{"PERL5_${_}_IS_RUNNING"} } (qw/CPANM CPANPLUS CPAN/) );
42   makemaker_args( NORECURS => 1 );
43 }
44
45 homepage 'http://www.dbix-class.org/';
46 resources 'IRC'         => 'irc://irc.perl.org/#dbix-class';
47 resources 'license'     => 'http://dev.perl.org/licenses/';
48 resources 'repository'  => 'https://github.com/dbsrgits/DBIx-Class';
49 resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class';
50 resources 'bugtracker'  => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class';
51
52 name     'DBIx-Class';
53 perl_version '5.008001';
54 all_from 'lib/DBIx/Class.pm';
55 Meta->{values}{x_authority} = 'cpan:RIBASUSHI';
56
57 tests_recursive (qw|
58     t
59 |);
60
61 install_script (qw|
62     script/dbicadmin
63 |);
64
65 ###
66 ### DO NOT ADD OPTIONAL DEPENDENCIES HERE, EVEN AS recommends()
67 ### All of them *MUST* go to DBIx::Class::Optional::Dependencies
68 ###
69 my $runtime_requires = {
70   # FIXME - temporary, needs throwing out for something more efficient
71   'Data::Compare'            => '1.22',
72
73   # DBI itself should be capable of installation and execution in pure-perl
74   # mode. However it has never been tested yet, so consider XS for the time
75   # being
76 ###
77 ### IMPORTANT - do not raise this dependency
78 ### even though many bugfixes are present in newer versions, the general DBIC
79 ### rule is to bend over backwards for available DBI versions (given upgrading
80 ### them is often *not* easy or even possible)
81 ###
82   'DBI'                      => '1.57',
83
84   # on older versions first() leaks
85   # for the time being make it a hard dep - when we get
86   # rid of Sub::Name will revisit this (possibility is
87   # to use Devel::HideXS to force the pure-perl version
88   # or something like that)
89   'List::Util'               => '1.16',
90
91   # XS (or XS-dependent) libs
92   'Sub::Name'                => '0.04',
93
94   # pure-perl (FatPack-able) libs
95   'Class::Accessor::Grouped' => '0.10010',
96   'Class::C3::Componentised' => '1.0009',
97   'Class::Inspector'         => '1.24',
98   'Config::Any'              => '0.20',
99   'Context::Preserve'        => '0.01',
100   'Data::Dumper::Concise'    => '2.020',
101   'Data::Page'               => '2.00',
102   'Devel::GlobalDestruction' => '0.09',
103   'Hash::Merge'              => '0.12',
104   'Moo'                      => '1.000006',
105   'MRO::Compat'              => '0.12',
106   'Module::Find'             => '0.07',
107   'namespace::clean'         => '0.24',
108   'Path::Class'              => '0.18',
109   'Scope::Guard'             => '0.03',
110   'SQL::Abstract'            => '1.73',
111   'Try::Tiny'                => '0.07',
112
113   # Technically this is not a core dependency - it is only required
114   # by the MySQL codepath. However this particular version is bundled
115   # since 5.10.0 and is a pure-perl module anyway - let it slide
116   'Text::Balanced'           => '2.00',
117 };
118
119 my $build_requires = {
120   # needed for testing only, not for operation
121   # we will move away from this dep eventually, perhaps to DBD::CSV or something
122 ###
123 ### IMPORTANT - do not raise this dependency
124 ### even though many bugfixes are present in newer versions, the general DBIC
125 ### rule is to bend over backwards for available DBDs (given upgrading them is
126 ### often *not* easy or even possible)
127 ###
128   'DBD::SQLite'              => '1.29',
129 };
130
131 my $test_requires = {
132   'File::Temp'               => '0.22',
133   'Test::Deep'               => '0.101',
134   'Test::Exception'          => '0.31',
135   'Test::Warn'               => '0.21',
136   'Test::More'               => '0.94',
137   # not sure if this is necessary at all, ask schwern some day
138   'Test::Builder'            => '0.94',
139
140   # this is already a dep of n::c, but just in case - used by t/55namespaces_cleaned.t
141   # remove and do a manual glob-collection if n::c is no longer a dep
142   'Package::Stash'           => '0.28',
143 };
144
145 # if the user has this env var set and no SQLT installed, tests will fail
146 # same rationale for direct test_requires as the strictures stuff above
147 # (even though no dist will be created from this)
148 # we force this req regarless of author_deps, worst case scenario it will
149 # be specified twice
150 if ($ENV{DBICTEST_SQLT_DEPLOY}) {
151   local @INC = ('lib', @INC);
152   require DBIx::Class::Optional::Dependencies;
153   my $dep_req = DBIx::Class::Optional::Dependencies->req_list_for('deploy');
154   for (keys %$dep_req) {
155     test_requires ($_ => $dep_req->{$_})
156   }
157 }
158
159 # this is so we can order requires alphabetically
160 # copies are needed for potential author requires injection
161 my $reqs = {
162   build_requires => { %$build_requires },
163   requires => { %$runtime_requires },
164   test_requires => { %$test_requires },
165 };
166
167 # only do author-includes if not part of a `make` run
168 if ($Module::Install::AUTHOR  and ! $ENV{MAKELEVEL}) {
169   # get options here, make $args available to all snippets
170   require Getopt::Long;
171   my $getopt = Getopt::Long::Parser->new(
172     config => [qw/gnu_getopt bundling_override no_ignore_case pass_through/]
173   );
174   my $args = {
175     skip_author_deps => undef,
176   };
177   $getopt->getoptions($args, qw/
178     skip_author_deps|skip-author-deps
179   /);
180   if (@ARGV) {
181     warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
182   }
183
184   # We need the MM facilities to generate the pieces for the final MM run.
185   # Just instantiate a throaway object here
186   my $mm_proto = ExtUtils::MakeMaker->new({
187     NORECURS => 1,
188     NAME => Meta->name || die 'The Module::Install metadata must be available at this point but is not - did you rearrange the Makefile.PL...?',
189   });
190
191   # Crutch for DISTBUILDING_IN_HELL
192   # Spits back a working dos2unix snippet to be used on the supplied path(s)
193   # Ironically EUMM's dos2unix is broken on win32 itself - it does
194   # not take into account the CRLF layer present on win32
195   my $crlf_fixup = sub {
196     return '' unless ($^O eq 'MSWin32' or $^O eq 'cygwin');
197     my $targets = join ', ', map { "q($_)" } @_;
198     "\t" . $mm_proto->oneliner( qq(\$ENV{PERLIO}='unix' and system( \$^X, qw( -MExtUtils::Command -e dos2unix -- ), $targets ) ) );
199   };
200
201   # we are in the process of (re)writing the makefile - some things we
202   # call below very well may fail
203   local $ENV{DBICTEST_NO_MAKEFILE_VERIFICATION} = 1;
204
205   require File::Spec;
206   # string-eval, not do(), because we need to provide the
207   # $mm_proto, $reqs and $*_requires lexicals to the included file
208   # (some includes *do* modify $reqs above)
209   for my $inc (sort glob ( File::Spec->catfile('maint', 'Makefile.PL.inc', '*') ) ) {
210     my $src = do { local (@ARGV, $/) = $inc; <> } or die $!;
211     eval "use warnings; use strict; $src" or die sprintf
212       "Failed execution of %s: %s\n",
213       $inc,
214       ($@ || $! || 'Unknown error'),
215     ;
216   }
217 }
218 else {
219   # make sure this Makefile can not be used to make a dist
220   # (without the author includes there are no meta cleanup, no sanity checks, etc)
221   postamble <<EOP;
222 create_distdir: nonauthor_stop_distdir_creation
223 nonauthor_stop_distdir_creation:
224 \t\$(NOECHO) \$(ECHO) Creation of dists in non-author mode is not allowed
225 \t\$(NOECHO) \$(FALSE)
226 EOP
227 }
228
229 # compose final req list, for alphabetical ordering
230 my %final_req;
231 for my $rtype (keys %$reqs) {
232   for my $mod (keys %{$reqs->{$rtype}} ) {
233
234     # sanity check req duplications
235     if ($final_req{$mod}) {
236       die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n";
237     }
238
239     $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ],
240   }
241 }
242
243 # actual require
244 for my $mod (sort keys %final_req) {
245   my ($rtype, $ver) = @{$final_req{$mod}};
246   no strict 'refs';
247   $rtype->($mod, $ver);
248 }
249
250 # author-mode or not - this is where we show a list of missing deps
251 # IFF we are running interactively
252 auto_install();
253
254 WriteAll();