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