--- DBD-SQLite2-0.33/Makefile.PL.BAD 2005-08-06 09:05:23.000000000 -0500 +++ DBD-SQLite2-0.33/Makefile.PL 2005-08-06 09:27:08.000000000 -0500 @@ -7,12 +7,79 @@ use Config; use strict; +# 2005/8/6, by tcallawa@redhat.com +# +# Determine if we are going to use the provided SQLite2 code, or an +# already-installed copy. To this end, look for two command line +# parameters: +# +# USE_LOCAL_SQLITE -- If non-false, force use of the installed version +# SQLITE_LOCATION -- If passed, look for headers and libs under this root +# +# In absense of either of those, expect SQLite 2.X.X libs and headers in the +# common places known to Perl or the C compiler. +require File::Spec; +my ($force_local, $sqlite_base, $sqlite_lib, $sqlite_inc); +if ($sqlite_base = (grep(/SQLITE_LOCATION=.*/, @ARGV))[0]) { + $sqlite_base =~ /=(.*)/; + $sqlite_base = $1; + $sqlite_lib = File::Spec->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) { + undef $sqlite_lib; # Keep these from making into CFLAGS/LDFLAGS + undef $sqlite_inc; + } +} + +# Now, check for sqlite2 +unless ($force_local) { + my ($dir, $file, $fh, $found); + print "Checking for SQLite2...\n"; + if ($sqlite_inc) { + open($fh, '< ' . File::Spec->catfile($sqlite_inc, 'sqlite.h')) + or die "Error opening sqlite.h in $sqlite_inc: $!"; + while (defined($_ = <$fh>)) { + $found = 1; + } + close($fh); + } else { + # Go hunting for the file + for $dir ([ qw(usr include) ], [ qw(usr local include) ]) { + $file = File::Spec->catfile('', @$dir, 'sqlite.h'); + next unless (-f $file); + open($fh, "< $file") or die "Error opening $file: $!"; + while (defined($_ = <$fh>)) { + $found = 1; + } + close($fh); + last if $found; + } + } + unless ($found) { + warn "No SQLite 2 header file was found. Using the local version instead.\n"; + $force_local = 1; + undef $sqlite_lib; + undef $sqlite_inc; + } else { + print "Looks good\n"; + } +} + +@ARGV = grep(! /SQLITE_LOCATION|USE_LOCAL_SQLITE/, @ARGV); + WriteMakefile( 'NAME' => 'DBD::SQLite2', 'VERSION_FROM' => 'lib/DBD/SQLite2.pm', # finds $VERSION 'PREREQ_PM' => {DBI => 1.21}, # e.g., Module::Name => 1.1 - 'OBJECT' => '$(O_FILES)', - 'INC' => '-I$(DBI_INSTARCH_DIR)', + 'OBJECT' => ($force_local) ? '$(O_FILES)' : 'SQLite2.o dbdimp.o', + 'INC' => '-I. -I$(DBI_INSTARCH_DIR)' . + (($sqlite_inc) ? " -I$sqlite_inc" : ''), + $force_local ? () : ('LIBS' => '-lsqlite'), + $sqlite_lib ? ('dynamic_lib' => { OTHERLDFLAGS => "-L$sqlite_lib" }) : (), 'OPTIMIZE' => "-O2", 'DEFINE' => "-DNDEBUG=1 -DSQLITE_PTR_SZ=$Config{ptrsize}" . ($Config{d_usleep} ? " -DHAVE_USLEEP=1" : ""),