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