mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
Cleaning up the layout
This commit is contained in:
parent
d3c816b701
commit
19672c1627
1 changed files with 88 additions and 89 deletions
177
Makefile.PL
177
Makefile.PL
|
@ -1,19 +1,18 @@
|
||||||
use ExtUtils::MakeMaker;
|
use ExtUtils::MakeMaker;
|
||||||
eval {
|
eval {
|
||||||
require DBI;
|
require DBI;
|
||||||
require DBI::DBD;
|
require DBI::DBD;
|
||||||
die "Your DBI Version is too old - DBD::SQLite requires at least 1.21"
|
unless ( $DBI::VERSION >= 1.21 ) {
|
||||||
unless $DBI::VERSION >= 1.21;
|
die "Your DBI Version is too old - DBD::SQLite requires at least 1.21";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if ($@) {
|
warn $@ if $@;
|
||||||
warn $@;
|
|
||||||
}
|
|
||||||
use Config;
|
use Config;
|
||||||
use strict;
|
use strict;
|
||||||
eval {
|
eval {
|
||||||
require DBD::SQLite;
|
require DBD::SQLite;
|
||||||
if ($DBD::SQLite::VERSION < 1.0) {
|
if ( $DBD::SQLite::VERSION < 1.0 ) {
|
||||||
print <<EOT;
|
print <<EOT;
|
||||||
|
|
||||||
**** WARNING **** WARNING **** WARNING **** WARNING **** WARNING ****
|
**** WARNING **** WARNING **** WARNING **** WARNING **** WARNING ****
|
||||||
|
|
||||||
|
@ -32,11 +31,11 @@ this version against an old SQLite database WILL lead to database
|
||||||
corruption.
|
corruption.
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
if (prompt("Continue?", "N") !~ /^y/i) {
|
if ( prompt("Continue?", "N") !~ /^y/i ) {
|
||||||
print "Exiting\n";
|
print "Exiting\n";
|
||||||
exit -1;
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
# 2005/6/19, by rjray@blackperl.com
|
# 2005/6/19, by rjray@blackperl.com
|
||||||
|
@ -51,96 +50,96 @@ EOT
|
||||||
# common places known to Perl or the C compiler.
|
# common places known to Perl or the C compiler.
|
||||||
require File::Spec;
|
require File::Spec;
|
||||||
my ($force_local, $sqlite_base, $sqlite_lib, $sqlite_inc);
|
my ($force_local, $sqlite_base, $sqlite_lib, $sqlite_inc);
|
||||||
if ($sqlite_base = (grep(/SQLITE_LOCATION=.*/, @ARGV))[0]) {
|
if ( $sqlite_base = (grep(/SQLITE_LOCATION=.*/, @ARGV))[0] ) {
|
||||||
$sqlite_base =~ /=(.*)/;
|
$sqlite_base =~ /=(.*)/;
|
||||||
$sqlite_base = $1;
|
$sqlite_base = $1;
|
||||||
$sqlite_lib = File::Spec->catdir($sqlite_base, 'lib');
|
$sqlite_lib = File::Spec->catdir($sqlite_base, 'lib');
|
||||||
$sqlite_inc = File::Spec->catdir($sqlite_base, 'include');
|
$sqlite_inc = File::Spec->catdir($sqlite_base, 'include');
|
||||||
}
|
}
|
||||||
if ($force_local = (grep(/USE_LOCAL_SQLITE=.*/, @ARGV))[0]) {
|
if ( $force_local = (grep(/USE_LOCAL_SQLITE=.*/, @ARGV))[0] ) {
|
||||||
$force_local =~ /=(.*)/;
|
$force_local =~ /=(.*)/;
|
||||||
$force_local = "$1" ? 1 : 0;
|
$force_local = "$1" ? 1 : 0;
|
||||||
if ($force_local) {
|
if ( $force_local ) {
|
||||||
undef $sqlite_lib; # Keep these from making into CFLAGS/LDFLAGS
|
# Keep these from making into CFLAGS/LDFLAGS
|
||||||
undef $sqlite_inc;
|
undef $sqlite_lib;
|
||||||
}
|
undef $sqlite_inc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Now, check for a compatible sqlite3
|
# Now check for a compatible sqlite3
|
||||||
unless ($force_local) {
|
unless ($force_local) {
|
||||||
my ($dir, $file, $fh, $version);
|
my ($dir, $file, $fh, $version);
|
||||||
print "Checking installed SQLite version...\n";
|
print "Checking installed SQLite version...\n";
|
||||||
if ($sqlite_inc) {
|
if ( $sqlite_inc ) {
|
||||||
open($fh, '< ' . File::Spec->catfile($sqlite_inc, 'sqlite3.h'))
|
open($fh, '< ' . File::Spec->catfile($sqlite_inc, 'sqlite3.h'))
|
||||||
or die "Error opening sqlite3.h in $sqlite_inc: $!";
|
or die "Error opening sqlite3.h in $sqlite_inc: $!";
|
||||||
while (defined($_ = <$fh>)) {
|
while ( defined($_ = <$fh>) ) {
|
||||||
if (/\#define\s+SQLITE_VERSION_NUMBER\s+(\d+)/) {
|
if (/\#define\s+SQLITE_VERSION_NUMBER\s+(\d+)/) {
|
||||||
$version = $1;
|
$version = $1;
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close($fh);
|
close($fh);
|
||||||
} else {
|
} else {
|
||||||
# Go hunting for the file (Matt: Add more dirs here as you see fit)
|
# Go hunting for the file (Matt: Add more dirs here as you see fit)
|
||||||
for $dir ([ qw(usr include) ], [ qw(usr local include) ]) {
|
for $dir ([ qw(usr include) ], [ qw(usr local include) ]) {
|
||||||
$file = File::Spec->catfile('', @$dir, 'sqlite3.h');
|
$file = File::Spec->catfile('', @$dir, 'sqlite3.h');
|
||||||
next unless (-f $file);
|
next unless (-f $file);
|
||||||
open($fh, "< $file") or die "Error opening $file: $!";
|
open($fh, "< $file") or die "Error opening $file: $!";
|
||||||
while (defined($_ = <$fh>)) {
|
while ( defined($_ = <$fh>) ) {
|
||||||
if (/\#define\s+SQLITE_VERSION_NUMBER\s+(\d+)/) {
|
if (/\#define\s+SQLITE_VERSION_NUMBER\s+(\d+)/) {
|
||||||
$version = $1;
|
$version = $1;
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close($fh);
|
close($fh);
|
||||||
last if $version;
|
last if $version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unless ($version && ($version >= 3003009)) {
|
unless ( $version && ($version >= 3003009) ) {
|
||||||
warn "SQLite version must be at least 3.3.9. No header file at that\n";
|
warn "SQLite version must be at least 3.3.9. No header file at that\n";
|
||||||
warn "version or higher was found. Using the local version instead.\n";
|
warn "version or higher was found. Using the local version instead.\n";
|
||||||
$force_local = 1;
|
$force_local = 1;
|
||||||
undef $sqlite_lib;
|
undef $sqlite_lib;
|
||||||
undef $sqlite_inc;
|
undef $sqlite_inc;
|
||||||
} else {
|
} else {
|
||||||
print "Looks good\n";
|
print "Looks good\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ARGV = grep(! /SQLITE_LOCATION|USE_LOCAL_SQLITE/, @ARGV);
|
@ARGV = grep( ! /SQLITE_LOCATION|USE_LOCAL_SQLITE/, @ARGV );
|
||||||
|
|
||||||
my $nlid = $DBI::VERSION > 1.42 ? '' : '-Dno_last_insert_id';
|
my $nlid = $DBI::VERSION > 1.42 ? '' : '-Dno_last_insert_id';
|
||||||
|
|
||||||
my $libs = '';
|
my $libs = '';
|
||||||
$libs .= "-L$sqlite_lib " if ($sqlite_lib);
|
$libs .= "-L$sqlite_lib " if $sqlite_lib;
|
||||||
$libs .= "-lsqlite3 " unless ($force_local);
|
$libs .= "-lsqlite3 " unless $force_local;
|
||||||
|
|
||||||
WriteMakefile(
|
WriteMakefile(
|
||||||
'NAME' => 'DBD::SQLite',
|
'NAME' => 'DBD::SQLite',
|
||||||
'VERSION_FROM' => 'lib/DBD/SQLite.pm', # finds $VERSION
|
'VERSION_FROM' => 'lib/DBD/SQLite.pm',
|
||||||
'PREREQ_PM' => {DBI => 1.21}, # e.g., Module::Name => 1.1
|
'PREREQ_PM' => { DBI => 1.21 },
|
||||||
'OBJECT' => ($force_local) ? '$(O_FILES)' : 'SQLite.o dbdimp.o',
|
'OBJECT' => ( $force_local ? '$(O_FILES)' : 'SQLite.o dbdimp.o' ),
|
||||||
'INC' => '-I. -I$(DBI_INSTARCH_DIR)' .
|
$libs ? ('LIBS' => $libs) : (),
|
||||||
(($sqlite_inc) ? " -I$sqlite_inc" : ''),
|
'OPTIMIZE' => "-O2",
|
||||||
$libs ? ('LIBS' => $libs) : (),
|
'clean' => { FILES => 'SQLite.xsi config.h tv.log output' },
|
||||||
'OPTIMIZE' => "-O2",
|
'PL_FILES' => {},
|
||||||
'DEFINE' => "-DSQLITE_CORE -DSQLITE_ENABLE_FTS2 -DNDEBUG=1 -DSQLITE_PTR_SZ=$Config{ptrsize}" .
|
'EXE_FILES' => [],
|
||||||
( ($Config{d_usleep} ||
|
'INC' => '-I. -I$(DBI_INSTARCH_DIR)' . ($sqlite_inc ? " -I$sqlite_inc" : ''),
|
||||||
$Config{osname} =~ m/linux/) ?
|
'DEFINE' => "-DSQLITE_CORE -DSQLITE_ENABLE_FTS2 -DNDEBUG=1 -DSQLITE_PTR_SZ=$Config{ptrsize}" .
|
||||||
" -DHAVE_USLEEP=1" : "" ) .
|
(($Config{d_usleep} || $Config{osname} =~ m/linux/) ? " -DHAVE_USLEEP=1" : "" ) .
|
||||||
($DBI::VERSION > 1.42 ? '' : ' -Dno_last_insert_id') .
|
($DBI::VERSION > 1.42 ? '' : ' -Dno_last_insert_id') .
|
||||||
($Config{usethreads} ? '' : ' -DTHREADSAFE=0'),
|
($Config{usethreads} ? '' : ' -DTHREADSAFE=0'),
|
||||||
'clean' => { FILES => 'SQLite.xsi config.h tv.log output' },
|
|
||||||
'PL_FILES' => {},
|
|
||||||
'EXE_FILES' => [],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
package MY;
|
package MY;
|
||||||
|
|
||||||
sub postamble {
|
sub postamble {
|
||||||
eval { DBI::DBD::dbd_postamble(@_) };
|
eval { DBI::DBD::dbd_postamble(@_) };
|
||||||
}
|
}
|
||||||
|
|
||||||
sub libscan {
|
sub libscan {
|
||||||
my ($self, $path) = @_;
|
my ($self, $path) = @_;
|
||||||
return if $path =~ /\.pl$/;
|
return if $path =~ /\.pl$/;
|
||||||
($path =~ m/\~$/) ? undef : $path;
|
($path =~ m/\~$/) ? undef : $path;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue