[DBD::Pg] Attempt to output some compiler information in case DBD::Pg fails to load at all, as can happen when we have multiple conflicting libpq versions, leading to messages like this: lo_import_with_oid: referenced symbol not found

dbdpg-commits-gENoVmVU/[email protected] Wed, 22 Aug 2012 22:47:15 -0400
Newsgroups gmane.comp.db.postgresql.dbdpg.cvs
Message-ID <[email protected]>
Committed by Greg Sabino Mullane <greg-O9fzpki4YnJWk0Htik3J/[email protected]>

Attempt to output some compiler information in case DBD::Pg fails to load at all,
as can happen when we have multiple conflicting libpq versions, leading to
messages like this: lo_import_with_oid: referenced symbol not found

---
 t/00basic.t |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/t/00basic.t b/t/00basic.t
index 7169a9d..493f121 100644
--- a/t/00basic.t
+++ b/t/00basic.t
@@ -10,8 +10,27 @@ use Test::More tests => 3;
 select(($|=1,select(STDERR),$|=1)[1]);
 
 BEGIN {
+
 	use_ok ('DBI') or BAIL_OUT 'Cannot continue without DBI';
-	use_ok ('DBD::Pg') or BAIL_OUT 'Cannot continue without DBD::Pg';
+
+	## If we cannot load DBD::Pg, output some compiler information for debugging:
+	if (! use_ok ('DBD::Pg')) {
+		my $file = 'Makefile';
+		if (! -e $file) {
+			$file = '../Makefile';
+		}
+		my $fh;
+		if (open $fh, '<', $file) {
+			{ local $/; $_ = <$fh>; }
+			close $fh;
+			for my $keyword (qw/ CCFLAGS INC LIBS /) {
+				if (/^#\s+$keyword => (.+)/m) {
+					diag "$keyword: $1";
+				}
+			}
+		}
+		BAIL_OUT 'Cannot continue without DBD::Pg';
+	}
 }
 use DBD::Pg;
 like ($DBD::Pg::VERSION, qr/^v?\d+\.\d+\.\d+(?:_\d+)?$/, qq{Found DBD::Pg::VERSION as "$DBD::Pg::VERSION"});
-- 
1.7.1