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