DBD-Firebird
view release on metacpan or search on metacpan
* fix DBP_FILL_INTEGER
* Note other authors in the AUTHORS section
* drop inc/ from .gitignore
* skip vim swap files
* ignore *.bs and *.xsi regardless of the directory
* move test routines in a package (TestFirebird)
* Build-time generated DBD::FirebirdEmbedded
+ factor-out most of Makefile.PL in inc/FirebirdMaker.pm
+ enable FirebirdEmbedded only if libfbembed.so is available
+ really prevent multiple debugs by dbi_arch_dir
+ compile embedded dbdimp.c with -DEMBEDDED
+ t/cleanup: keep the test configuration file
+ create_test_database: cater for host-less databases (e.g. embedded)
+ rely on the ib_embedded dbh attribute for embedded detection
+ remove generated embedded tests on realclean
+ add test for the ib_embedded dbh attribute
+ print some info about libfbembed availability
+ support DBD_FIREBIRD_REQUIRE_EMBEDDED env. variable
* create_test_database: set test database forced writes off
* drop sleeping in ithreads test
* drop use_libfbembed usage
* diagnostics on database creation/drop
* move decoding of status into ib_error_decode
* implement DBD::Firebird->create_database
* add DPB_FILL_STRING_LEN macro for when we know the length
* use the driver instead of isql for creating the test database
* implement DBD::Firebird->gfix
* generic create_test_database
Makefile.PL view on Meta::CPAN
use 5.008;
use Getopt::Long;
use File::Spec;
use File::Basename;
use ExtUtils::MakeMaker 5.16, qw(prompt &WriteMakefile $Verbose);
use Config;
# Globals vars
our $EMBEDDED = 0;
BEGIN {
# Theory of operation:
# we copy this Makefile.PL to embed/ and set $EMBEDDED to 1 there
# this way we have to maintain one code base with special cases for
# the embedded module build
# See create_embedded_Makefile_PL below
unless ($EMBEDDED) {
unshift @INC, 'inc';
require FirebirdMaker;
FirebirdMaker->import;
}
}
my $interactive;
my $help;
my $os = $^O;
GetOptions(
interactive => \$interactive,
help => \$help,
) unless $EMBEDDED;
if ($help) {
help_message();
exit;
}
my $module_name = $EMBEDDED ? 'DBD::FirebirdEmbedded' : 'DBD::Firebird';
print "Configuring $module_name (on $os)\n";
$FB::libfbembed_available = 0;
# We set FIREBIRD_HOME from the first found of:
# 1. Environment variable
# 2. Helper subs (search Firebird in the known locations)
unless ($EMBEDDED) {
# 1. Environment variables
$FB::HOME = $ENV{FIREBIRD_HOME};
$FB::INC = $ENV{FIREBIRD_INCLUDE};
$FB::LIB = $ENV{FIREBIRD_LIB};
if ($FB::HOME) {
# 2. Subdirectory of FIREBIRD_HOME
if ($os eq 'darwin') {
$FB::INC ||= (grep -d, (
Makefile.PL view on Meta::CPAN
$FB::LIB = '/Library/Frameworks/Firebird.framework/Libraries';
}
else {
locate_firebird();
}
}
detect_firebird_api_version();
}
my $client_lib = ( $EMBEDDED and $FB::API_VER < 30 ) ? 'fbembed' : 'fbclient';
if ($interactive) {
# Interactive mode setup
welcome_msg();
prompt_for_settings();
}
else {
print "\n";
print 'FIREBIRD_HOME : ', $FB::HOME || '(none)', "\n";
print 'FIREBIRD_INCLUDE: ', $FB::INC || '(none)', "\n";
print 'FIREBIRD_LIB : ', $FB::LIB || '(none)', "\n";
print 'Client library : ', $client_lib,"\n";
print "\n";
save_test_parameters() unless $EMBEDDED;
}
do {
eval {
require DBI::DBD;
};
if ($@) {
print "Could not load DBI::DBD - is the DBI module installed?\n";
exit 0;
}
$MY::postamble ||= DBI::DBD::dbd_postamble();
## Prevent duplicate debug info as dbd_postamble also calls this
local *STDOUT;
$FB::dbi_arch_dir ||= DBI::DBD::dbd_dbi_arch_dir();
} unless $EMBEDDED;
my $cflags = $Config{q{ccflags}}||'';
$cflags .= " $ENV{CFLAGS}" if $ENV{CFLAGS};
if ($Config{cc} =~ /gcc/) {
$cflags = "-Wall -fno-strict-aliasing $cflags";
}
my @inc;
for ( $FB::INC, $FB::dbi_arch_dir ) { push @inc, qq(-I"$_") if $_ }
my %MakeParams = (
NAME => $module_name,
VERSION_FROM => $EMBEDDED
? 'FirebirdEmbedded.pm'
: 'Firebird.pm', # finds $VERSION
C => ['dbdimp.c'],
H => [ 'dbdimp.h', $EMBEDDED ? 'FirebirdEmbedded.h' : 'Firebird.h' ],
CCFLAGS => $cflags,
( $EMBEDDED ? ( DEFINE => '-DEMBEDDED' ) : () ),
INC => join( ' ', @inc ),
OBJECT => join( ' ',
$EMBEDDED ? "FirebirdEmbedded.o" : "Firebird.o", "dbdimp.o" ),
LIBS => [''],
OPTIMIZE => $Config{optimize},
XSPROTOARG => '-noprototypes',
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz' },
clean => {
FILES =>
qq(*.xsi *.old t/*.old *~ t/*~ trace.txt t/trace.txt lib/DBD/Firebird/*~ lib/DBD/Firebird/*.old lib/Bundle/DBD/*~ lib/Bundle/DBD/*.old dll.* fb_init fb_sem fb_trace_* dbd-fb-testdb.fdb)
},
realclean => { FILES => qq($test_conf $test_mark t/*.sql embed t/embed-*.t) },
AUTHOR => 'Edwin Pratomo (edpratomo@users.sourceforge.net)',
Makefile.PL view on Meta::CPAN
$MakeParams{LDDLFLAGS} = $Config{lddlflags};
$MakeParams{LIBS} = "-L$FB::LIB -l$client_lib ";
}
last SWITCH;
};
carp "DBD::Firebird is not supported on platform $os.\n";
exit 1;
}
unless ($EMBEDDED) {
if ($FB::libfbembed_available or $FB::API_VER >= 30) {
print "Found libfbembed, will build DBD::FirebirdEmbed too.\n";
create_embedded_files();
}
else {
print
"libfbembed not found and API version is $FB::API_VER, building of DBD::FirebirdEmbed skipped.\n";
# make sure there is no embedded build involved
my $mfpl = File::Spec->catfile( 'embed', 'Makefile.PL' );
unlink $mfpl if -e $mfpl;
}
}
# And last but not least write the Makefile
WriteMakefile1(%MakeParams);
closing_msg()
if !$EMBEDDED
and !$interactive
and ( !defined $ENV{DBI_PASS} and !defined $ENV{ISC_PASSWORD} );
exit 0;
#- end of Makefile.PL
else if ((kl==14) && strEQ(key, "ib_enable_utf8"))
result = boolSV(imp_dbh->ib_enable_utf8);
else if ((kl==13) && strEQ(key, "ib_dateformat"))
result = newSVpvn(imp_dbh->dateformat, strlen(imp_dbh->dateformat));
else if ((kl==13) && strEQ(key, "ib_timeformat"))
result = newSVpvn(imp_dbh->timeformat, strlen(imp_dbh->timeformat));
else if ((kl==18) && strEQ(key, "ib_timestampformat"))
result = newSVpvn(imp_dbh->timestampformat,
strlen(imp_dbh->timestampformat));
else if ((kl==11) && strEQ(key, "ib_embedded"))
#ifdef EMBEDDED
result = &PL_sv_yes;
#else
result = &PL_sv_no;
#endif
if (result == NULL)
return Nullsv;
else
{
if ((result == &PL_sv_yes) || (result == &PL_sv_no))
inc/FirebirdMaker.pm view on Meta::CPAN
for my $dir ( split(/ /, $Config{libpth} ), $FB::LIB||() ) {
if ( -e File::Spec->catfile( $dir, 'libfbembed.so' ) ) {
$FB::libfbembed_available = 1;
print "libfbembed.so found in $dir\n";
last;
}
}
die "libfbembed.so not found\n"
if $ENV{DBD_FIREBIRD_REQUIRE_EMBEDDED}
and not $FB::libfbembed_available
and $FB::API_VER < 30;
return;
}
=head2 alternative_locations
Search lib and inc in alternative locations.
inc/FirebirdMaker.pm view on Meta::CPAN
my $dir = "embed";
unless (-d $dir) {
mkdir($dir) or die "Error creating directory $dir: $!\n";
}
# Makefile.PL
copy_mangled(
'Makefile.PL' => {
last => sub { $_[0] =~ /^exit 0/ },
mangle => sub { $_[0] =~ s/(?<=^our \$EMBEDDED = )0/1/ },
}
);
# Simple copies
for my $f (qw( dbdimp.h )) {
copy_mangled($f);
}
copy_mangled(
'Firebird.h' => {
name => 'FirebirdEmbedded.h',
( run in 0.904 second using v1.01-cache-2.11-cpan-71847e10f99 )