Bump SQLA and CAG dependencies
[dbsrgits/DBIx-Class.git] / Makefile.PL
1 use inc::Module::Install 0.67;
2 use strict;
3 use warnings;
4 use POSIX ();
5
6 use 5.006001; # delete this line if you want to send patches for earlier.
7
8 name     'DBIx-Class';
9 perl_version '5.006001';
10 all_from 'lib/DBIx/Class.pm';
11
12 requires 'Data::Page'               => 2.00;
13 requires 'Scalar::Util'             => 0;
14 requires 'SQL::Abstract'            => 1.51;
15 requires 'SQL::Abstract::Limit'     => 0.13;
16 requires 'MRO::Compat'              => 0;
17 requires 'Class::C3::Componentised' => 1.0004;
18 requires 'Storable'                 => 0;
19 requires 'Carp::Clan'               => 0;
20 requires 'DBI'                      => 1.40;
21 requires 'Module::Find'             => 0;
22 requires 'Class::Inspector'         => 0;
23 requires 'Class::Accessor::Grouped' => 0.08003;
24 requires 'JSON::Any'                => 1.17;
25 requires 'Scope::Guard'             => 0.03;
26 requires 'Path::Class'              => 0;
27 requires 'List::Util'               => 1.19;
28 requires 'Sub::Name'                => 0.04;
29 requires 'MRO::Compat'              => 0.09;
30
31 # Perl 5.8.0 doesn't have utf8::is_utf8()
32 requires 'Encode'                   => 0 if ($] <= 5.008000);  
33
34 # configure_requires so the sanity check below can run
35 configure_requires 'DBD::SQLite'    => 1.14;
36
37 test_requires 'Test::Builder'       => 0.33;
38 test_requires 'Test::Warn'          => 0.11;
39 test_requires 'Test::Exception'     => 0;
40 test_requires 'Test::Deep'          => 0;
41
42 recommends 'SQL::Translator'        => 0.09004;
43
44 install_script 'script/dbicadmin';
45
46 tests_recursive 't';
47
48 # re-build README and require extra modules for testing if we're in a checkout
49
50 my %force_requires_if_author = (
51   'Test::Pod::Coverage'       => 1.04,
52   'SQL::Translator'           => 0.09004,
53
54   # CDBI-compat related
55   'DBIx::ContextualFetch'     => 0,
56   'Class::DBI::Plugin::DeepAbstractSearch' => 0,
57   'Class::Trigger'            => 0,
58   'Time::Piece'               => 0,
59   'Clone'                     => 0,
60
61   # t/52cycle.t
62   'Test::Memory::Cycle'       => 0,
63
64   # t/60core.t
65   'DateTime::Format::MySQL'   => 0,
66
67   # t/93storage_replication.t
68   'Moose',                    => 0,
69   'MooseX::AttributeHelpers'  => 0.12,
70
71   # t/96_is_deteministic_value.t
72   'DateTime::Format::Strptime' => 0,
73 );
74
75 if ($Module::Install::AUTHOR) {
76
77   foreach my $module (keys %force_requires_if_author) {
78     requires ($module => $force_requires_if_author{$module});
79   }
80
81   system('pod2text lib/DBIx/Class.pm > README');
82 }
83
84 auto_provides;
85
86 if ($Module::Install::AUTHOR) {
87   warn <<'EOW';
88 ******************************************************************************
89 ******************************************************************************
90 ***                                                                        ***
91 *** AUTHOR MODE: all optional test dependencies converted to hard requires ***
92 ***                                                                        ***
93 ******************************************************************************
94 ******************************************************************************
95
96 EOW
97 }
98 auto_install;
99
100 # Have all prerequisites, check DBD::SQLite sanity
101 if (! $ENV{DBICTEST_NO_SQLITE_CHECK} ) {
102
103   my $pid = fork();
104   if (not defined $pid) {
105       die "Unable to fork(): $!";
106   }
107   elsif (! $pid) {
108
109       # Win32 does not have real fork()s so a segfault will bring
110       # everything down. Warn about it.
111       if ($^O eq 'MSWin32') {
112         print <<'EOW';
113
114 ######################################################################
115 #                                                                    #
116 # A short stress-testing of DBD::SQLite will follow. If you have a   #
117 # buggy library this might very well be the last text you will see   #
118 # before the installation silently terminates. If this happens it    #
119 # would mean that you are running a buggy version of DBD::SQLite     #
120 # known to randomly segfault on errors. Even if you have the latest  #
121 # CPAN module version, the system sqlite3 dynamic library might have #
122 # been compiled against an older buggy sqlite3 dev library (oddly    #
123 # DBD::SQLite will prefer the system library against the one bundled #
124 # with it). You are strongly advised to resolve this issue before    #
125 # proceeding.                                                        #
126 #                                                                    #
127 # If this happens to you (this text is the last thing you see), and  #
128 # you just want to install this module without worrying about the    #
129 # tests (which will almost certainly fail) - set the environment     #
130 # variable DBICTEST_NO_SQLITE_CHECK to a true value and try again.   #
131 #                                                                    #
132 ######################################################################
133
134 EOW
135       }
136
137       require DBI;
138       for (1 .. 100) {
139           my $dbh;
140           $dbh = DBI->connect ('dbi:SQLite::memory:', undef, undef, {
141               AutoCommit => 1,
142               RaiseError => 0,
143               PrintError => 0,
144           })
145               or die "Unable to connect to database: $@";
146           $dbh->do ('CREATE TABLE name_with_no_columns');   # a subtle syntax error
147           $dbh->do ('COMMIT');                              # followed by commit
148           $dbh->disconnect;
149       }
150
151       exit 0;
152   }
153   else {
154       eval {
155           local $SIG{ALRM} = sub { die "timeout\n" };
156           alarm 5;
157           wait();
158           alarm 0;
159       };
160       my $exception = $@;
161
162       my $sig = $? & 127;
163
164 # make sure process actually dies
165       $exception && kill POSIX::SIGKILL(), $pid;
166
167       if ($exception || $sig == POSIX::SIGSEGV() || $sig == POSIX::SIGABRT()
168         || $sig == 7) { # 7 == SIGBUS, haven't seen it but just in case
169           warn (<<EOE);
170
171 ############################### WARNING #################################
172 #                                                                       #
173 # You are running a buggy version of DBD::SQLite known to randomly      #
174 # segfault on errors.  Even if you have the latest CPAN module version, #
175 # the sqlite3 dynamic library on this system might have been compiled   #
176 # against an older buggy sqlite3 dev library (oddly DBD::SQLite will    #
177 # prefer the system library against the one bundled with it). You are   #
178 # strongly advised to resolve this issue before proceeding.             #
179 #                                                                       #
180 #########################################################################
181
182 EOE
183           my $ans = prompt (
184             "The test suite of this module is almost certain to fail.\n"
185             . 'Do you really want to continue?',
186             'no',
187           );
188           exit 0 unless ($ans =~ /^y(es)?$/i);
189       }
190   }
191 }
192
193
194 WriteAll();
195
196
197 if ($Module::Install::AUTHOR) {
198   # Need to do this _after_ WriteAll else it looses track of them
199   Meta->{values}{build_requires} = [ grep {
200     my $ok = 1;
201     foreach my $module (keys %force_requires_if_author) {
202       if ($_->[0] =~ /$module/) {
203         $ok = 0;
204         last;
205       }
206     }
207     $ok;
208   } @{Meta->{values}{build_requires}} ];
209
210   my @scalar_keys = Module::Install::Metadata::Meta_TupleKeys();
211   my $cr = Module::Install::Metadata->can("Meta_TupleKeys");
212   {
213     no warnings 'redefine';
214     *Module::Install::Metadata::Meta_TupleKeys = sub {
215       return $cr->(@_), 'resources';
216     };
217   }
218   Meta->{values}{resources} = [ 
219     [ 'MailingList', 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class' ],
220     [ 'IRC', 'irc://irc.perl.org/#dbix-class' ],
221     [ 'license', 'http://dev.perl.org/licenses/' ],
222     [ 'repository', 'http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/' ],
223   ];
224   Meta->write;
225 }
226