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