use 5.006; #from ExtUtils::MakeMaker 6.48 and DBI 1.43 use strict; use ExtUtils::MakeMaker; use Config; # Some dependencies need to be more aggressive on Windows sub WINLIKE () { return 1 if $^O eq 'MSWin32'; return 1 if $^O eq 'cygwin'; return ''; } # Make setting optional MakeMaker parameters more readable sub OPTIONAL { return () unless $ExtUtils::MakeMaker::VERSION ge shift; return @_; } # Are we upgrading from a critically out of date version? eval { require DBD::SQLite; if ( $DBD::SQLite::VERSION < 1.0 ) { print <catdir( $sqlite_base, 'lib' ); $sqlite_inc = File::Spec->catdir( $sqlite_base, 'include' ); } if ( $force_local = (grep(/USE_LOCAL_SQLITE=.*/, @ARGV))[0] ) { $force_local =~ /=(.*)/; $force_local = "$1" ? 1 : 0; if ( $force_local ) { # Keep these from making into CFLAGS/LDFLAGS undef $sqlite_lib; undef $sqlite_inc; } } # Now check for a compatible sqlite3 unless ( $force_local ) { my ($dir, $file, $fh, $version); print "Checking installed SQLite version...\n" if $ENV{AUTOMATED_TESTING}; if ( $sqlite_inc ) { open($fh, '< ' , File::Spec->catfile($sqlite_inc, 'sqlite3.h')) or die "Error opening sqlite3.h in $sqlite_inc: $!"; while ( defined($_ = <$fh>) ) { if (/\#define\s+SQLITE_VERSION_NUMBER\s+(\d+)/) { $version = $1; last; } } close($fh); } else { # Go hunting for the file (Matt: Add more dirs here as you see fit) foreach $dir ( [ qw(usr include) ], [ qw(usr local include) ] ) { $file = File::Spec->catfile('', @$dir, 'sqlite3.h'); next unless (-f $file); open($fh, "<", $file) or die "Error opening $file: $!"; while ( defined($_ = <$fh>) ) { if (/\#define\s+SQLITE_VERSION_NUMBER\s+(\d+)/) { $version = $1; last; } } close($fh); last if $version; } } unless ( $version && ($version >= 3006000) ) { warn "SQLite version must be at least 3.6.0. No header file at that\n"; warn "version or higher was found. Using the local version instead.\n"; $force_local = 1; undef $sqlite_lib; undef $sqlite_inc; } else { print "Looks good\n" if $ENV{AUTOMATED_TESTING}; } } } # Use always the bundled one. # XXX: ... and this message should be more informative. $force_local = 1; print "We're using the bundled sqlite library.\n" if $ENV{AUTOMATED_TESTING}; @ARGV = grep( ! /SQLITE_LOCATION|USE_LOCAL_SQLITE/, @ARGV ); ##################################################################### # Prepare Compiler Options my @CC_LIBS = (); if ( $sqlite_lib ) { push @CC_LIBS, "-L$sqlite_lib"; } unless ( $force_local ) { push @CC_LIBS, '-lsqlite3'; } my @CC_INC = ( '-I.', '-I$(DBI_INSTARCH_DIR)', ); if ( $sqlite_inc ) { push @INC, "-I$sqlite_inc"; } my @CC_DEFINE = ( '-DSQLITE_CORE', '-DSQLITE_ENABLE_FTS3', '-DNDEBUG=1', "-DSQLITE_PTR_SZ=$Config{ptrsize}" ); if ( $Config{d_usleep} || $Config{osname} =~ m/linux/ ) { push @CC_DEFINE, '-DHAVE_USLEEP=1'; } unless ( $Config{usethreads} ) { push @CC_DEFINE, '-DTHREADSAFE=0'; } my @CC_OPTIONS = ( INC => join( ' ', @CC_INC ), DEFINE => join( ' ', @CC_DEFINE ), ( @CC_LIBS ? ( LIBS => join( ' ', @CC_LIBS ) ) : () ), ); ##################################################################### # Hand off to ExtUtils::MakeMaker WriteMakefile( NAME => 'DBD::SQLite', ABSTRACT => 'Self Contained SQLite RDBMS in a DBI Driver', VERSION_FROM => 'lib/DBD/SQLite.pm', PREREQ_PM => { 'DBI' => '1.43', 'Test::More' => '0.42', }, OPTIONAL( '6.48', MIN_PERL_VERSION => '5.006', ), OPTIONAL( '6.31', LICENSE => 'perl', ), OPTIONAL( '6.11', AUTHOR => 'Adam Kennedy ', # Maintainer ), OPTIONAL( '6.46', META_MERGE => { configure_requires => { 'ExtUtils::MakeMaker' => '6.48', 'File::Spec' => (WINLIKE ? '3.27' : '0.82'), 'DBI' => '1.43', }, resources => { license => 'http://dev.perl.org/licenses/', bugtracker => 'http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBD-SQLite', repository => 'http://svn.ali.as/cpan/trunk/DBD-SQLite', }, }, ), OBJECT => ( $force_local ? '$(O_FILES)' : 'SQLite.o dbdimp.o' ), OPTIMIZE => '-O2', clean => { FILES => 'SQLite.xsi config.h tv.log', }, PL_FILES => {}, EXE_FILES => [], @CC_OPTIONS, ); package MY; sub postamble { require DBI; require DBI::DBD; eval { DBI::DBD::dbd_postamble(@_) }; } sub libscan { my ($self, $path) = @_; return if $path =~ /\.pl$/; ($path =~ m/\~$/) ? undef : $path; }