Factor out the Makefile.PL into easily digestable snippets
[dbsrgits/DBIx-Class.git] / Makefile.PL
1 use strict;
2 use warnings;
3
4 use 5.008001;
5 use inc::Module::Install 1.00;
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 name     'DBIx-Class';
18 perl_version '5.008001';
19 all_from 'lib/DBIx/Class.pm';
20
21 tests_recursive (qw|
22     t
23 |);
24
25 install_script (qw|
26     script/dbicadmin
27 |);
28
29 homepage 'http://www.dbix-class.org/';
30 resources 'IRC'         => 'irc://irc.perl.org/#dbix-class';
31 resources 'license'     => 'http://dev.perl.org/licenses/';
32 resources 'repository'  => 'git://git.shadowcat.co.uk/dbsrgits/DBIx-Class.git';
33 resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class';
34 resources 'bugtracker'  => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class';
35
36 ###
37 ### DO NOT ADD OPTIONAL DEPENDENCIES HERE, EVEN AS recommends()
38 ### All of them *MUST* go to DBIx::Class::Optional::Dependencies
39 ###
40 my $runtime_requires = {
41   # FIXME - temporary, needs throwing out for something more efficient
42   'Data::Compare'            => '1.22',
43
44   # DBI itself should be capable of installation and execution in pure-perl
45   # mode. However it has never been tested yet, so consider XS for the time
46   # being
47   'DBI'                      => '1.57',
48
49   # XS (or XS-dependent) libs
50   'Sub::Name'                => '0.04',
51
52   # pure-perl (FatPack-able) libs
53   'Class::Accessor::Grouped' => '0.10002',
54   'Class::C3::Componentised' => '1.0009',
55   'Class::Inspector'         => '1.24',
56   'Config::Any'              => '0.20',
57   'Context::Preserve'        => '0.01',
58   'Data::Dumper::Concise'    => '2.020',
59   'Data::Page'               => '2.00',
60   'Hash::Merge'              => '0.12',
61   'MRO::Compat'              => '0.09',
62   'Module::Find'             => '0.06',
63   'namespace::clean'         => '0.20',
64   'Path::Class'              => '0.18',
65   'Scope::Guard'             => '0.03',
66   'SQL::Abstract'            => '1.72',
67   'Try::Tiny'                => '0.04',
68
69   # dual-life corelibs needing a specific bugfixed version
70   'File::Path'               => '2.07',
71 };
72
73 my $build_requires = {
74   # needed for testing only, not for operation
75   # we will move away from this dep eventually, perhaps to DBD::CSV or something
76   'DBD::SQLite'              => '1.29',
77 };
78
79 my $test_requires = {
80   'File::Temp'               => '0.22',
81   'Test::Exception'          => '0.31',
82   'Test::Warn'               => '0.21',
83   'Test::More'               => '0.94',
84   # not sure if this is necessary at all, ask schwern some day
85   'Test::Builder'            => '0.94',
86
87   # this is already a dep of n::c, but just in case - used by t/55namespaces_cleaned.t
88   # remove and do a manual glob-collection if n::c is no longer a dep
89   'Package::Stash'           => '0.28',
90 };
91
92 # Bail out on parallel testing
93 if (
94   ($ENV{HARNESS_OPTIONS}||'') =~ / (?: ^ | \: ) j(\d+) /x
95     and
96   $1 > 1
97 ) { die <<EOP }
98
99 ******************************************************************************
100 ******************************************************************************
101 ***                                                                        ***
102 ***      PARALLEL TESTING DETECTED ( \$ENV{HARNESS_OPTIONS} = 'j$1' )        ***
103 ***                                                                        ***
104 *** DBIC tests WILL FAIL. It is harder to make them parallel-friendly than ***
105 *** it should be (though work is underway). In the meantime you will have  ***
106 *** to adjust your environment and re-run the installation. Sorry!         ***
107 ***                                                                        ***
108 ******************************************************************************
109 ******************************************************************************
110
111 EOP
112
113 # this is so we can order requires alphabetically
114 # copies are needed for potential author requires injection
115 my $reqs = {
116   build_requires => { %$build_requires },
117   requires => { %$runtime_requires },
118   test_requires => { %$test_requires },
119 };
120
121 if ($Module::Install::AUTHOR) {
122   # get options here, make $args available to all snippets
123   require Getopt::Long;
124   my $getopt = Getopt::Long::Parser->new(
125     config => [qw/gnu_getopt bundling_override no_ignore_case pass_through/]
126   );
127   my $args = {
128     skip_author_deps => undef,
129   };
130   $getopt->getoptions($args, 'skip_author_deps');
131   if (@ARGV) {
132     warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
133   }
134
135   require File::Spec;
136   # string-eval, not do(), because we need to provide the
137   # $reqs and $*_requires lexicals to the included file
138   # (some includes *do* modify $reqs above)
139   for (sort glob ( File::Spec->catfile('maint', 'Makefile.PL.inc', '*') ) ) {
140     eval scalar do { local (@ARGV, $/) = $_; <> }
141       or die ($@ || $!);
142   }
143 }
144 else {
145   # make sure this Makefile can not be used to make a dist
146   # (without the author includes there are no sanity checks)
147   postamble <<EOP;
148 .PHONY: nonauthor_stop_distdir_creation
149 create_distdir: nonauthor_stop_distdir_creation
150 nonauthor_stop_distdir_creation:
151 \t\$(NOECHO) \$(ECHO) Creation of dists in non-author mode is not allowed
152 \t\$(NOECHO) \$(FALSE)
153 EOP
154 }
155
156 # compose final req list, for alphabetical ordering
157 my %final_req;
158 for my $rtype (keys %$reqs) {
159   for my $mod (keys %{$reqs->{$rtype}} ) {
160
161     # sanity check req duplications
162     if ($final_req{$mod}) {
163       die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n";
164     }
165
166     $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ],
167   }
168 }
169
170 # actual require
171 for my $mod (sort keys %final_req) {
172   my ($rtype, $ver) = @{$final_req{$mod}};
173   no strict 'refs';
174   $rtype->($mod, $ver);
175 }
176
177 # author-mode or not - this is where we show a list of missing deps
178 # IFF we are running interactively
179 auto_install();
180
181 WriteAll();