Scope::Upper somehow confuses pseudofork on older perls - investigation pending
[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
80 my $build_requires = {
81   # needed for testing only, not for operation
82   # we will move away from this dep eventually, perhaps to DBD::CSV or something
83   'DBD::SQLite'              => '1.29',
84 };
85
86 my $test_requires = {
87   'File::Temp'               => '0.22',
88   'Test::Exception'          => '0.31',
89   'Test::Warn'               => '0.21',
90   'Test::More'               => '0.94',
91   # not sure if this is necessary at all, ask schwern some day
92   'Test::Builder'            => '0.94',
93
94   # this is already a dep of n::c, but just in case - used by t/55namespaces_cleaned.t
95   # remove and do a manual glob-collection if n::c is no longer a dep
96   'Package::Stash'           => '0.28',
97 };
98
99 # make strictures.pm happy (DO NOT LIKE, TOO MUCH XS!)
100 # (i.e. what if the .git/.svn is *not* because of DBIC?)
101 #
102 # Note - this is added as test_requires *directly*, so it gets properly
103 # excluded on META.yml cleansing
104 if (-e '.git' or -e '.svn') {
105   test_requires 'indirect'              => '0.25';
106   test_requires 'multidimensional'      => '0.008';
107   test_requires 'bareword::filehandles' => '0.003';
108 }
109
110 # if the user has this env var set and no SQLT installed, tests will fail
111 # same rationale for direct test_requires as the strictures stuff above
112 # (even though no dist will be created from this)
113 # we force this req regarless of author_deps, worst case scenario it will
114 # be specified twice
115 if ($ENV{DBICTEST_SQLT_DEPLOY}) {
116   local @INC = ('lib', @INC);
117   require DBIx::Class::Optional::Dependencies;
118   my $dep_req = DBIx::Class::Optional::Dependencies->req_list_for('deploy');
119   for (keys %$dep_req) {
120     test_requires ($_ => $dep_req->{$_})
121   }
122 }
123
124 # this is so we can order requires alphabetically
125 # copies are needed for potential author requires injection
126 my $reqs = {
127   build_requires => { %$build_requires },
128   requires => { %$runtime_requires },
129   test_requires => { %$test_requires },
130 };
131
132 # only do author-includes if not part of a `make` run
133 if ($Module::Install::AUTHOR  and ! $ENV{MAKELEVEL}) {
134   # get options here, make $args available to all snippets
135   require Getopt::Long;
136   my $getopt = Getopt::Long::Parser->new(
137     config => [qw/gnu_getopt bundling_override no_ignore_case pass_through/]
138   );
139   my $args = {
140     skip_author_deps => undef,
141   };
142   $getopt->getoptions($args, qw/
143     skip_author_deps|skip-author-deps
144   /);
145   if (@ARGV) {
146     warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
147   }
148
149   # We need the MM facilities to generate the pieces for the final MM run.
150   # Just instantiate a throaway object here
151   my $mm_proto = ExtUtils::MakeMaker->new({
152     NAME => Meta->name || die 'The Module::Install metadata must be available at this point but is not - did you rearrange the Makefile.PL...?',
153   });
154
155   # Crutch for DISTBUILDING_IN_HELL
156   # Spits back a working dos2unix snippet to be used on the supplied path(s)
157   # Ironically EUMM's dos2unix is broken on win32 itself - it does
158   # not take into account the CRLF layer present on win32
159   my $crlf_fixup = sub {
160     return '' unless ($^O eq 'MSWin32' or $^O eq 'cygwin');
161     my $targets = join ', ', map { "q($_)" } @_;
162     "\t" . $mm_proto->oneliner( qq(\$ENV{PERLIO}='unix' and system( \$^X, qw( -MExtUtils::Command -e dos2unix -- ), $targets ) ) );
163   };
164
165   # we are in the process of (re)writing the makefile - some things we
166   # call below very well may fail
167   local $ENV{DBICTEST_NO_MAKEFILE_VERIFICATION} = 1;
168
169   require File::Spec;
170   # string-eval, not do(), because we need to provide the
171   # $mm_proto, $reqs and $*_requires lexicals to the included file
172   # (some includes *do* modify $reqs above)
173   for my $inc (sort glob ( File::Spec->catfile('maint', 'Makefile.PL.inc', '*') ) ) {
174     my $src = do { local (@ARGV, $/) = $inc; <> } or die $!;
175     eval "use warnings; use strict; $src" or die sprintf
176       "Failed execution of %s: %s\n",
177       $inc,
178       ($@ || $! || 'Unknown error'),
179     ;
180   }
181 }
182 else {
183   # make sure this Makefile can not be used to make a dist
184   # (without the author includes there are no meta cleanup, no sanity checks, etc)
185   postamble <<EOP;
186 create_distdir: nonauthor_stop_distdir_creation
187 nonauthor_stop_distdir_creation:
188 \t\$(NOECHO) \$(ECHO) Creation of dists in non-author mode is not allowed
189 \t\$(NOECHO) \$(FALSE)
190 EOP
191 }
192
193 # compose final req list, for alphabetical ordering
194 my %final_req;
195 for my $rtype (keys %$reqs) {
196   for my $mod (keys %{$reqs->{$rtype}} ) {
197
198     # sanity check req duplications
199     if ($final_req{$mod}) {
200       die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n";
201     }
202
203     $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ],
204   }
205 }
206
207 # actual require
208 for my $mod (sort keys %final_req) {
209   my ($rtype, $ver) = @{$final_req{$mod}};
210   no strict 'refs';
211   $rtype->($mod, $ver);
212 }
213
214 # author-mode or not - this is where we show a list of missing deps
215 # IFF we are running interactively
216 auto_install();
217
218 WriteAll();