Clarify why Makefile.PL failed
[dbsrgits/DBIx-Class.git] / Makefile.PL
1 use inc::Module::Install 0.97;
2 use strict;
3 use warnings;
4 use POSIX ();
5
6 use 5.008001;
7
8 use FindBin;
9 use lib "$FindBin::Bin/lib";
10
11 # adjust ENV for $AUTHOR system() calls
12 use Config;
13 $ENV{PERL5LIB} = join ($Config{path_sep}, @INC);
14
15 use Getopt::Long ();
16
17 my $getopt = Getopt::Long::Parser->new(
18   config => [qw/gnu_getopt bundling_override no_ignore_case pass_through/]
19 );
20 my $args = {
21   skip_author_deps => undef,
22 };
23 $getopt->getoptions($args, 'skip_author_deps');
24 if (@ARGV) {
25   warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
26 }
27
28 ###
29 ### DO NOT ADD OPTIONAL DEPENDENCIES HERE, EVEN AS recommends()
30 ### All of them should go to DBIx::Class::Optional::Dependencies
31 ###
32
33 name     'DBIx-Class';
34 perl_version '5.008001';
35 all_from 'lib/DBIx/Class.pm';
36
37 my $build_requires = {
38   'DBD::SQLite'              => '1.25',
39 };
40
41 my $test_requires = {
42   'File::Temp'               => '0.22',
43   'Test::Builder'            => '0.33',
44   'Test::Exception'          => '0',
45   'Test::More'               => '0.92',
46   'Test::Warn'               => '0.21',
47 };
48
49 my $runtime_requires = {
50   'Carp::Clan'               => '6.0',
51   'Class::Accessor::Grouped' => '0.09003',
52   'Class::C3::Componentised' => '1.0005',
53   'Class::Inspector'         => '1.24',
54   'Data::Page'               => '2.00',
55   'DBI'                      => '1.609',
56   'File::Path'               => '2.07',
57   'MRO::Compat'              => '0.09',
58   'Module::Find'             => '0.06',
59   'Path::Class'              => '0.18',
60   'SQL::Abstract'            => '1.67',
61   'SQL::Abstract::Limit'     => '0.13',
62   'Sub::Name'                => '0.04',
63   'Data::Dumper::Concise'    => '1.000',
64   'Scope::Guard'             => '0.03',
65   'Context::Preserve'        => '0.01',
66   'Try::Tiny'                => '0.04',
67   'namespace::clean'         => '0.14',
68   'Math::BigInt'             => '1.89',
69   'Math::Base36'             => '0.07',
70 };
71
72 # this is so we can order requires alphabetically
73 # copies are needed for author requires injection
74 my $reqs = {
75   build_requires => { %$build_requires },
76   requires => { %$runtime_requires },
77   test_requires => { %$test_requires },
78 };
79
80
81 # require extra modules for testing if we're in a checkout
82 my $optdep_msg;
83 if ($Module::Install::AUTHOR) {
84   if ($args->{skip_author_deps}) {
85     $optdep_msg = <<'EOW';
86
87 ******************************************************************************
88 ******************************************************************************
89 ***                                                                        ***
90 *** IGNORING AUTHOR MODE: no optional test dependencies will be forced.    ***
91 ***                                                                        ***
92 *** If you are using this checkout with the intention of submitting a DBIC ***
93 *** patch, you are *STRONGLY ENCOURAGED* to install all dependencies, so   ***
94 *** that every possible unit-test will run.                                ***
95 ***                                                                        ***
96 ******************************************************************************
97 ******************************************************************************
98
99 EOW
100   }
101   else {
102     $optdep_msg = <<'EOW';
103
104 ******************************************************************************
105 ******************************************************************************
106 ***                                                                        ***
107 *** AUTHOR MODE: all optional test dependencies converted to hard requires ***
108 ***      ( to disabled re-run Makefile.PL with --skip_author_deps )        ***
109 ***                                                                        ***
110 ******************************************************************************
111 ******************************************************************************
112
113 EOW
114
115     require DBIx::Class::Optional::Dependencies;
116     $reqs->{test_requires} = {
117       %{$reqs->{test_requires}},
118       map { %$_ } (values %{DBIx::Class::Optional::Dependencies->req_group_list}),
119     };
120   }
121 }
122
123 # compose final req list, for alphabetical ordering
124 my %final_req;
125 for my $rtype (keys %$reqs) {
126   for my $mod (keys %{$reqs->{$rtype}} ) {
127
128     # sanity check req duplications
129     if ($final_req{$mod}) {
130       die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n";
131     }
132
133     $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ],
134   }
135 }
136
137 # actual require
138 for my $mod (sort keys %final_req) {
139   my ($rtype, $ver) = @{$final_req{$mod}};
140   no strict 'refs';
141   $rtype->($mod, $ver);
142 }
143
144 # output twice since the deplist is > 70 lines
145 warn $optdep_msg if $Module::Install::AUTHOR;
146 auto_install();
147 warn $optdep_msg if $Module::Install::AUTHOR;
148
149 # re-create various autogenerated documentation bits
150 if ($Module::Install::AUTHOR) {
151
152   print "Regenerating README\n";
153   system('pod2text lib/DBIx/Class.pm > README');
154
155   if (-f 'MANIFEST') {
156     print "Removing MANIFEST\n";
157     unlink 'MANIFEST';
158   }
159
160   print "Regenerating Optional/Dependencies.pod\n";
161   require DBIx::Class::Optional::Dependencies;
162   DBIx::Class::Optional::Dependencies->_gen_pod;
163
164   # FIXME Disabled due to unsolved issues, ask theorbtwo
165   #  require Module::Install::Pod::Inherit;
166   #  PodInherit();
167 }
168
169
170 tests_recursive (qw|
171     t
172 |);
173
174 # temporary(?) until I get around to fix M::I wrt xt/
175 # needs Module::Install::AuthorTests
176 eval {
177   recursive_author_tests (qw/xt/);
178   1;
179 } || do {
180   unless ($args->{skip_author_deps}) {
181     my $err = $@;
182     eval { require Module::Install::AuthorTests }
183       || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode (or supply --skip_author_deps):\n\n$@\n";
184     die $@;
185   }
186 };
187
188
189 install_script (qw|
190     script/dbicadmin
191 |);
192
193
194 ### Mangle makefile - read the comments for more info
195 #
196 postamble <<"EOP";
197
198 # This will add an extra dep-spec for the distdir target,
199 # which `make` will fold together in a first-come first-serve
200 # fashion. What we do here is essentially adding extra
201 # commands to execute once the distdir is assembled (via
202 # create_distdir), but before control is returned to a higher
203 # calling rule.
204 distdir : dbicadmin_pod_inject
205
206 # The pod self-injection code is in fact a hidden option in
207 # dbicadmin itself
208 dbicadmin_pod_inject :
209 \tcd \$(DISTVNAME) && \$(ABSPERL) -Ilib script/dbicadmin --selfinject-pod
210
211 # Regenerate manifest before running create_distdir.
212 create_distdir : manifest
213
214 EOP
215
216 homepage 'http://www.dbix-class.org/';
217 resources 'IRC'         => 'irc://irc.perl.org/#dbix-class';
218 resources 'license'     => 'http://dev.perl.org/licenses/';
219 resources 'repository'  => 'git://git.shadowcat.co.uk/dbsrgits/DBIx-Class.git';
220 resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class';
221
222 # Deprecated/internal modules need no exposure
223 no_index directory => $_ for (qw|
224   lib/DBIx/Class/Admin
225   lib/DBIx/Class/SQLAHacks
226   lib/DBIx/Class/PK/Auto
227   lib/DBIx/Class/CDBICompat
228 |);
229 no_index package => $_ for (qw/
230   DBIx::Class::SQLAHacks DBIx::Class::Storage::DBIHacks
231 /);
232
233
234 WriteAll();
235
236 # Re-write META.yml to _exclude_ all forced requires (we do not want to ship this)
237 # We are also not using M::I::AuthorRequires as this will be an extra dep, and
238 # deps in Makefile.PL suck (no autoinstall)
239 if ($Module::Install::AUTHOR && ! $args->{skip_author_deps} ) {
240
241   # FIXME test_requires is not yet part of META
242   my %original_build_requires = ( %$build_requires, %$test_requires );
243   my @all_build_requires = @{delete Meta->{values}{build_requires}};
244   my %removed_build_requires;
245
246   for (@all_build_requires) {
247     if ($original_build_requires{$_->[0]}) {
248       push @{Meta->{values}{build_requires}}, $_;
249     }
250     else {
251       $removed_build_requires{$_->[0]} = $_->[1]
252         unless $_->[0] eq 'ExtUtils::MakeMaker';
253     }
254   }
255
256   print "Regenerating META with author requires excluded\n";
257   Meta->write;
258
259   # test that we really took things away (just in case)
260   my $meta = do { local @ARGV = 'META.yml'; local $/; <> };
261   for (keys %removed_build_requires) {
262     delete $removed_build_requires{$_}
263       unless $meta =~ /^ \s+ $_: \s+ $removed_build_requires{$_} \s* $/mx
264   }
265
266   if (keys %removed_build_requires) {
267     die join ("\n",
268       "\n\nFATAL FAIL! It looks like some author dependencies made it to the META.yml:",
269       "(most likely a broken Module::Install)\n",
270       map { "\t$_" } (keys %removed_build_requires)
271     ) . "\n\n";
272   }
273 }