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