why the hell did I put that in import?
[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.000006',
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
121 my $build_requires = {
122   # needed for testing only, not for operation
123   # we will move away from this dep eventually, perhaps to DBD::CSV or something
124 ###
125 ### IMPORTANT - do not raise this dependency
126 ### even though many bugfixes are present in newer versions, the general DBIC
127 ### rule is to bend over backwards for available DBDs (given upgrading them is
128 ### often *not* easy or even possible)
129 ###
130   'DBD::SQLite'              => '1.29',
131 };
132
133 my $test_requires = {
134   'File::Temp'               => '0.22',
135   'Test::Deep'               => '0.101',
136   'Test::Exception'          => '0.31',
137   'Test::Warn'               => '0.21',
138   'Test::More'               => '0.94',
139   # not sure if this is necessary at all, ask schwern some day
140   'Test::Builder'            => '0.94',
141
142   # this is already a dep of n::c, but just in case - used by t/55namespaces_cleaned.t
143   # remove and do a manual glob-collection if n::c is no longer a dep
144   'Package::Stash'           => '0.28',
145 };
146
147 # if the user has this env var set and no SQLT installed, tests will fail
148 # same rationale for direct test_requires as the strictures stuff above
149 # (even though no dist will be created from this)
150 # we force this req regarless of author_deps, worst case scenario it will
151 # be specified twice
152 if ($ENV{DBICTEST_SQLT_DEPLOY}) {
153   local @INC = ('lib', @INC);
154   require DBIx::Class::Optional::Dependencies;
155   my $dep_req = DBIx::Class::Optional::Dependencies->req_list_for('deploy');
156   for (keys %$dep_req) {
157     test_requires ($_ => $dep_req->{$_})
158   }
159 }
160
161 # this is so we can order requires alphabetically
162 # copies are needed for potential author requires injection
163 my $reqs = {
164   build_requires => { %$build_requires },
165   requires => { %$runtime_requires },
166   test_requires => { %$test_requires },
167 };
168
169 # only do author-includes if not part of a `make` run
170 if ($Module::Install::AUTHOR  and ! $ENV{MAKELEVEL}) {
171   # get options here, make $args available to all snippets
172   require Getopt::Long;
173   my $getopt = Getopt::Long::Parser->new(
174     config => [qw/gnu_getopt bundling_override no_ignore_case pass_through/]
175   );
176   my $args = {
177     skip_author_deps => undef,
178   };
179   $getopt->getoptions($args, qw/
180     skip_author_deps|skip-author-deps
181   /);
182   if (@ARGV) {
183     warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
184   }
185
186   # We need the MM facilities to generate the pieces for the final MM run.
187   # Just instantiate a throaway object here
188   my $mm_proto = ExtUtils::MakeMaker->new({
189     NORECURS => 1,
190     NAME => Meta->name || die 'The Module::Install metadata must be available at this point but is not - did you rearrange the Makefile.PL...?',
191   });
192
193   # Crutch for DISTBUILDING_IN_HELL
194   # Spits back a working dos2unix snippet to be used on the supplied path(s)
195   # Ironically EUMM's dos2unix is broken on win32 itself - it does
196   # not take into account the CRLF layer present on win32
197   my $crlf_fixup = sub {
198     return '' unless ($^O eq 'MSWin32' or $^O eq 'cygwin');
199     my $targets = join ', ', map { "q($_)" } @_;
200     "\t" . $mm_proto->oneliner( qq(\$ENV{PERLIO}='unix' and system( \$^X, qw( -MExtUtils::Command -e dos2unix -- ), $targets ) ) );
201   };
202
203   # we are in the process of (re)writing the makefile - some things we
204   # call below very well may fail
205   local $ENV{DBICTEST_NO_MAKEFILE_VERIFICATION} = 1;
206
207   require File::Spec;
208   # string-eval, not do(), because we need to provide the
209   # $mm_proto, $reqs and $*_requires lexicals to the included file
210   # (some includes *do* modify $reqs above)
211   for my $inc (sort glob ( File::Spec->catfile('maint', 'Makefile.PL.inc', '*') ) ) {
212     my $src = do { local (@ARGV, $/) = $inc; <> } or die $!;
213     eval "use warnings; use strict; $src" or die sprintf
214       "Failed execution of %s: %s\n",
215       $inc,
216       ($@ || $! || 'Unknown error'),
217     ;
218   }
219 }
220 else {
221   # make sure this Makefile can not be used to make a dist
222   # (without the author includes there are no meta cleanup, no sanity checks, etc)
223   postamble <<EOP;
224 create_distdir: nonauthor_stop_distdir_creation
225 nonauthor_stop_distdir_creation:
226 \t\$(NOECHO) \$(ECHO) Creation of dists in non-author mode is not allowed
227 \t\$(NOECHO) \$(FALSE)
228 EOP
229 }
230
231 # compose final req list, for alphabetical ordering
232 my %final_req;
233 for my $rtype (keys %$reqs) {
234   for my $mod (keys %{$reqs->{$rtype}} ) {
235
236     # sanity check req duplications
237     if ($final_req{$mod}) {
238       die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n";
239     }
240
241     $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ],
242   }
243 }
244
245 # actual require
246 for my $mod (sort keys %final_req) {
247   my ($rtype, $ver) = @{$final_req{$mod}};
248   no strict 'refs';
249   $rtype->($mod, $ver);
250 }
251
252 # author-mode or not - this is where we show a list of missing deps
253 # IFF we are running interactively
254 auto_install();
255
256 WriteAll();