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