Need latest SQLA for proper order_by in Ordered.pm
[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.49;
15 requires 'SQL::Abstract::Limit'     => 0.13;
16 requires 'Class::C3'                => 0.20;
17 requires 'Class::C3::Componentised' => 0;
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.08002;
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 'namespace::clean'         => 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 'DBD::SQLite'    => 1.14;
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 CDBI modules for testing if we're in a checkout
48
49 my %force_requires_if_author = (
50   'DBIx::ContextualFetch'     => 0,
51   'Class::Trigger'            => 0,
52   'Time::Piece'               => 0,
53   'Clone'                     => 0,
54   'Test::Pod::Coverage'       => 0,
55   'Test::Memory::Cycle'       => 0,
56   'SQL::Translator'           => 0.09004,
57 );
58
59 if ($Module::Install::AUTHOR) {
60
61   foreach my $module (keys %force_requires_if_author) {
62     requires ($module => $force_requires_if_author{$module});
63   }
64
65   system('pod2text lib/DBIx/Class.pm > README');
66 }
67
68 auto_provides;
69
70 auto_install;
71
72 # Have all prerequisites, check DBD::SQLite sanity
73 if (! $ENV{DBICTEST_NO_SQLITE_CHECK} ) {
74
75   my $pid = fork();
76   if (not defined $pid) {
77       die "Unable to fork(): $!";
78   }
79   elsif (! $pid) {
80
81       # Win32 does not have real fork()s so a segfault will bring
82       # everything down. Warn about it.
83       if ($^O eq 'MSWin32') {
84         print <<'EOW';
85
86 ######################################################################
87 #                                                                    #
88 # A short stress-testing of DBD::SQLite will follow. If you have a   #
89 # buggy library this might very well be the last text you will see   #
90 # before the installation silently terminates. If this happens it    #
91 # would mean that you are running a buggy version of DBD::SQLite     #
92 # known to randomly segfault on errors. Even if you have the latest  #
93 # CPAN module version, the system sqlite3 dynamic library might have #
94 # been compiled against an older buggy sqlite3 dev library (oddly    #
95 # DBD::SQLite will prefer the system library against the one bundled #
96 # with it). You are strongly advised to resolve this issue before    #
97 # proceeding.                                                        #
98 #                                                                    #
99 # If this happens to you (this text is the last thing you see), and  #
100 # you just want to install this module without worrying about the    #
101 # tests (which will almost certainly fail) - set the environment     #
102 # variable DBICTEST_NO_SQLITE_CHECK to a true value and try again.   #
103 #                                                                    #
104 ######################################################################
105
106 EOW
107       }
108
109       require DBI;
110       for (1 .. 100) {
111           my $dbh;
112           $dbh = DBI->connect ('dbi:SQLite::memory:', undef, undef, {
113               AutoCommit => 1,
114               RaiseError => 0,
115               PrintError => 0,
116           })
117               or die "Unable to connect to database: $@";
118           $dbh->do ('CREATE TABLE name_with_no_columns');   # a subtle syntax error
119           $dbh->do ('COMMIT');                              # followed by commit
120           $dbh->disconnect;
121       }
122
123       exit 0;
124   }
125   else {
126       eval {
127           local $SIG{ALRM} = sub { die "timeout\n" };
128           alarm 5;
129           wait();
130           alarm 0;
131       };
132       my $exception = $@;
133
134       my $sig = $? & 127;
135
136 # make sure process actually dies
137       $exception && kill POSIX::SIGKILL(), $pid;
138
139       if ($exception || $sig == POSIX::SIGSEGV() || $sig == POSIX::SIGABRT()
140         || $sig == 7) { # 7 == SIGBUS, haven't seen it but just in case
141           warn (<<EOE);
142
143 ############################### WARNING #################################
144 #                                                                       #
145 # You are running a buggy version of DBD::SQLite known to randomly      #
146 # segfault on errors.  Even if you have the latest CPAN module version, #
147 # the sqlite3 dynamic library on this system might have been compiled   #
148 # against an older buggy sqlite3 dev library (oddly DBD::SQLite will    #
149 # prefer the system library against the one bundled with it). You are   #
150 # strongly advised to resolve this issue before proceeding.             #
151 #                                                                       #
152 #########################################################################
153
154 EOE
155           my $ans = prompt (
156             "The test suite of this module is almost certain to fail.\n"
157             . 'Do you really want to continue?',
158             'no',
159           );
160           exit 0 unless ($ans =~ /^y(es)?$/i);
161       }
162   }
163 }
164
165
166 WriteAll();
167
168
169 if ($Module::Install::AUTHOR) {
170   # Need to do this _after_ WriteAll else it looses track of them
171   Meta->{values}{build_requires} = [ grep {
172     my $ok = 1;
173     foreach my $module (keys %force_requires_if_author) {
174       if ($_->[0] =~ /$module/) {
175         $ok = 0;
176         last;
177       }
178     }
179     $ok;
180   } @{Meta->{values}{build_requires}} ];
181
182   my @scalar_keys = Module::Install::Metadata::Meta_TupleKeys();
183   my $cr = Module::Install::Metadata->can("Meta_TupleKeys");
184   {
185     no warnings 'redefine';
186     *Module::Install::Metadata::Meta_TupleKeys = sub {
187       return $cr->(@_), 'resources';
188     };
189   }
190   Meta->{values}{resources} = [ 
191     [ 'MailingList', 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class' ],
192     [ 'IRC', 'irc://irc.perl.org/#dbix-class' ],
193     [ 'license', 'http://dev.perl.org/licenses/' ],
194     [ 'repository', 'http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/' ],
195   ];
196   Meta->write;
197 }