Do not mask Makefile.PL errors in END block
[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 makemaker_args(
38   PMLIBDIRS => [qw(lib .generated_pod)],
39   PMLIBPARENTDIRS => [qw(lib .generated_pod)],
40 );
41
42 ###
43 ### DO NOT ADD OPTIONAL DEPENDENCIES HERE, EVEN AS recommends()
44 ### All of them *MUST* go to DBIx::Class::Optional::Dependencies
45 ###
46 my $runtime_requires = {
47   # FIXME - temporary, needs throwing out for something more efficient
48   'Data::Compare'            => '1.22',
49
50   # DBI itself should be capable of installation and execution in pure-perl
51   # mode. However it has never been tested yet, so consider XS for the time
52   # being
53   'DBI'                      => '1.57',
54
55   # XS (or XS-dependent) libs
56   'Sub::Name'                => '0.04',
57
58   # pure-perl (FatPack-able) libs
59   'Class::Accessor::Grouped' => '0.10009',
60   'Class::C3::Componentised' => '1.0009',
61   'Class::Inspector'         => '1.24',
62   'Config::Any'              => '0.20',
63   'Context::Preserve'        => '0.01',
64   'Data::Dumper::Concise'    => '2.020',
65   'Data::Page'               => '2.00',
66   'Devel::GlobalDestruction' => '0.09',
67   'Hash::Merge'              => '0.12',
68   'Moo'                      => '1.000006',
69   'MRO::Compat'              => '0.12',
70   'Module::Find'             => '0.07',
71   'namespace::clean'         => '0.24',
72   'Path::Class'              => '0.18',
73   'Scope::Guard'             => '0.03',
74   'SQL::Abstract'            => '1.73',
75   'Try::Tiny'                => '0.07',
76 };
77
78 my $build_requires = {
79   # needed for testing only, not for operation
80   # we will move away from this dep eventually, perhaps to DBD::CSV or something
81   'DBD::SQLite'              => '1.29',
82 };
83
84 my $test_requires = {
85   'File::Temp'               => '0.22',
86   'Test::Exception'          => '0.31',
87   'Test::Warn'               => '0.21',
88   'Test::More'               => '0.94',
89   # not sure if this is necessary at all, ask schwern some day
90   'Test::Builder'            => '0.94',
91
92   # this is already a dep of n::c, but just in case - used by t/55namespaces_cleaned.t
93   # remove and do a manual glob-collection if n::c is no longer a dep
94   'Package::Stash'           => '0.28',
95 };
96
97 # make strictures.pm happy (DO NOT LIKE, TOO MUCH XS!)
98 # (i.e. what if the .git/.svn is *not* because of DBIC?)
99 #
100 # Note - this is added as test_requires *directly*, so it gets properly
101 # excluded on META.yml cleansing
102 if (-e '.git' or -e '.svn') {
103   test_requires 'indirect'              => '0.25';
104   test_requires 'multidimensional'      => '0.008';
105   test_requires 'bareword::filehandles' => '0.003';
106 }
107
108 # if the user has this env var set and no SQLT installed, tests will fail
109 # same rationale for direct test_requires as the strictures stuff above
110 # (even though no dist will be created from this)
111 # we force this req regarless of author_deps, worst case scenario it will
112 # be specified twice
113 if ($ENV{DBICTEST_SQLT_DEPLOY}) {
114   local @INC = ('lib', @INC);
115   require DBIx::Class::Optional::Dependencies;
116   my $dep_req = DBIx::Class::Optional::Dependencies->req_list_for('deploy');
117   for (keys %$dep_req) {
118     test_requires ($_ => $dep_req->{$_})
119   }
120 }
121
122 # this is so we can order requires alphabetically
123 # copies are needed for potential author requires injection
124 my $reqs = {
125   build_requires => { %$build_requires },
126   requires => { %$runtime_requires },
127   test_requires => { %$test_requires },
128 };
129
130 # only do author-includes if not part of a `make` run
131 if ($Module::Install::AUTHOR  and ! $ENV{MAKELEVEL}) {
132   # get options here, make $args available to all snippets
133   require Getopt::Long;
134   my $getopt = Getopt::Long::Parser->new(
135     config => [qw/gnu_getopt bundling_override no_ignore_case pass_through/]
136   );
137   my $args = {
138     skip_author_deps => undef,
139   };
140   $getopt->getoptions($args, qw/
141     skip_author_deps|skip-author-deps
142   /);
143   if (@ARGV) {
144     warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
145   }
146
147   require File::Spec;
148   # string-eval, not do(), because we need to provide the
149   # $reqs and $*_requires lexicals to the included file
150   # (some includes *do* modify $reqs above)
151   for my $inc (sort glob ( File::Spec->catfile('maint', 'Makefile.PL.inc', '*') ) ) {
152     my $src = do { local (@ARGV, $/) = $inc; <> } or die $!;
153     eval "use warnings; use strict; $src" or die sprintf
154       "Failed execution of %s: %s\n",
155       $inc,
156       ($@ || $! || 'Unknown error'),
157     ;
158   }
159 }
160 else {
161   # make sure this Makefile can not be used to make a dist
162   # (without the author includes there are no meta cleanup, no sanity checks, etc)
163   postamble <<EOP;
164 .PHONY: nonauthor_stop_distdir_creation
165 create_distdir: nonauthor_stop_distdir_creation
166 nonauthor_stop_distdir_creation:
167 \t\$(NOECHO) \$(ECHO) Creation of dists in non-author mode is not allowed
168 \t\$(NOECHO) \$(FALSE)
169 EOP
170 }
171
172 # compose final req list, for alphabetical ordering
173 my %final_req;
174 for my $rtype (keys %$reqs) {
175   for my $mod (keys %{$reqs->{$rtype}} ) {
176
177     # sanity check req duplications
178     if ($final_req{$mod}) {
179       die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n";
180     }
181
182     $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ],
183   }
184 }
185
186 # actual require
187 for my $mod (sort keys %final_req) {
188   my ($rtype, $ver) = @{$final_req{$mod}};
189   no strict 'refs';
190   $rtype->($mod, $ver);
191 }
192
193 # author-mode or not - this is where we show a list of missing deps
194 # IFF we are running interactively
195 auto_install();
196
197 WriteAll();