Author: turnstep
Date: Wed Jul 18 11:45:28 2007
New Revision: 9765

Modified:
   DBD-Pg/trunk/Changes
   DBD-Pg/trunk/Makefile.PL
   DBD-Pg/trunk/TODO

Log:
Catch lack of libpq library early and refuse to proceed.
Clean up Makefile.PL a little bit.
Better output for POSTGRES_* ENV vars.


Modified: DBD-Pg/trunk/Changes
==============================================================================
--- DBD-Pg/trunk/Changes        (original)
+++ DBD-Pg/trunk/Changes        Wed Jul 18 11:45:28 2007
@@ -1,6 +1,7 @@
 ('GSM' is Greg Sabino Mullane, [EMAIL PROTECTED])
 
 1.50
+       - Complain loudly and fail to proceed if Makefile.PL finds no -lpq [GSM]
        - Fix META.yml file. (CPAN bug #25759) [GSM]
        - Force column names to respect utf8-ness. Per report from Ch Lamprect. 
[GSM]
        - Add support for asynchronous queries. [GSM]

Modified: DBD-Pg/trunk/Makefile.PL
==============================================================================
--- DBD-Pg/trunk/Makefile.PL    (original)
+++ DBD-Pg/trunk/Makefile.PL    Wed Jul 18 11:45:28 2007
@@ -3,11 +3,12 @@
 use ExtUtils::MakeMaker;
 use Config;
 use strict;
+use warnings;
 use 5.006001;
 use DBI 1.45;
 use DBI::DBD;
 
-my $VERSION = "1.50";
+my $VERSION = '1.50';
 
 my $lib;
 BEGIN {
@@ -27,7 +28,6 @@
 }
 
 print "Configuring DBD::Pg $VERSION\n";
-print "Remember to actually read the README file!\n";
 
 my $POSTGRES_INCLUDE;
 my $POSTGRES_LIB;
@@ -39,7 +39,7 @@
 my $p = App::Info::Handler::Prompt->new;
 my $pg = App::Info::RDBMS::PostgreSQL->new(on_unknown => $p);
 my ($major_ver, $minor_ver, $patch, $conf) = map {$pg->$_} qw/major_version 
minor_version patch_version configure/;
-my $serverversion = sprintf("%d%.02d%.02d", $major_ver, $minor_ver, $patch);
+my $serverversion = sprintf '%d%.02d%.02d', $major_ver, $minor_ver, $patch;
 my $defaultport = $conf =~ /with-pgport=(\d+)/ ? $1 : 5432;
 
 if ((!$ENV{POSTGRES_INCLUDE} or !$ENV{POSTGRES_LIB}) and !$ENV{POSTGRES_HOME}) 
{
@@ -54,10 +54,14 @@
 }
 
 my $os = $^O;
-print "OS: $os\n";
 print "PostgreSQL version: $serverversion (default port: $defaultport)\n";
-print "POSTGRES_INCLUDE: $ENV{POSTGRES_INCLUDE}\n";
-print "POSTGRES_LIB: $ENV{POSTGRES_LIB}\n";
+my $showhome = $ENV{POSTGRES_HOME} || '(not set)';
+print "POSTGRES_HOME: $showhome\n";
+my $showinc = $ENV{POSTGRES_INCLUDE} || '(not set)';
+print "POSTGRES_INCLUDE: $showinc\n";
+my $showlib = $ENV{POSTGRES_LIB} || '(not set)';
+print "POSTGRES_LIB: $showlib\n";
+print "OS: $os\n";
 
 if ($serverversion < 1) {
        die "Could not determine the PostgreSQL library version.\n".
@@ -68,7 +72,7 @@
 
 if ($os =~ /Win32/) {
        for ($POSTGRES_INCLUDE, $POSTGRES_LIB) {
-               $_ = qq{"$_"} if index($_,'"');
+               $_ = qq{"$_"} if index $_,'"';
        }
 }
 
@@ -97,23 +101,23 @@
 
 if ($ENV{DBDPG_GCCDEBUG}) {
        warn "Enabling many compiler options\n";
-       $comp_opts .= " -Wchar-subscripts -Wcomment";
-       $comp_opts .= " -Wformat=2"; ## does 
-Wformat,-Wformat-y2k,-Wformat-nonliteral,-Wformat-security
-       $comp_opts .= " -Wnonnull";
-       $comp_opts .= " -Wuninitialized -Winit-self"; ## latter requires the 
former
-       $comp_opts .= " -Wimplicit"; ## does -Wimplicit-int and 
-Wimplicit-function-declaration
-       $comp_opts .= " -Wmain -Wmissing-braces -Wparentheses -Wsequence-point 
-Wreturn-type -Wswitch -Wswitch-enum -Wtrigraphs";
-       $comp_opts .= " -Wunused"; ## contains -Wunused- 
function,label,parameter,variable,value
-       $comp_opts .= " -Wunknown-pragmas -Wstrict-aliasing";
-       $comp_opts .= " -Wall"; ## all of above, but we enumerate anyway
-       $comp_opts .= " -Wextra -Wdeclaration-after-statement -Wendif-labels 
-Wpointer-arith";
-       $comp_opts .= " -Wbad-function-cast -Wcast-qual -Wcast-align 
-Wconversion -Wsign-compare -Waggregate-return";
-       $comp_opts .= " -Wmissing-prototypes -Wmissing-declarations 
-Wmissing-format-attribute -Wpacked -Winline -Winvalid-pch";
-       $comp_opts .= " -Wdisabled-optimization"; ## Not terribly useful
-       $comp_opts .= " -Wnested-externs"; ## Does not like Perl__notused (from 
DBIXS;)
+       $comp_opts .= ' -Wchar-subscripts -Wcomment';
+       $comp_opts .= ' -Wformat=2'; ## does 
-Wformat,-Wformat-y2k,-Wformat-nonliteral,-Wformat-security
+       $comp_opts .= ' -Wnonnull';
+       $comp_opts .= ' -Wuninitialized -Winit-self'; ## latter requires the 
former
+       $comp_opts .= ' -Wimplicit'; ## does -Wimplicit-int and 
-Wimplicit-function-declaration
+       $comp_opts .= ' -Wmain -Wmissing-braces -Wparentheses -Wsequence-point 
-Wreturn-type -Wswitch -Wswitch-enum -Wtrigraphs';
+       $comp_opts .= ' -Wunused'; ## contains -Wunused- 
function,label,parameter,variable,value
+       $comp_opts .= ' -Wunknown-pragmas -Wstrict-aliasing';
+       $comp_opts .= ' -Wall'; ## all of above, but we enumerate anyway
+       $comp_opts .= ' -Wextra -Wdeclaration-after-statement -Wendif-labels 
-Wpointer-arith';
+       $comp_opts .= ' -Wbad-function-cast -Wcast-qual -Wcast-align 
-Wconversion -Wsign-compare -Waggregate-return';
+       $comp_opts .= ' -Wmissing-prototypes -Wmissing-declarations 
-Wmissing-format-attribute -Wpacked -Winline -Winvalid-pch';
+       $comp_opts .= ' -Wdisabled-optimization'; ## Not terribly useful
+       $comp_opts .= ' -Wnested-externs'; ## Does not like Perl__notused (from 
DBIXS;)
 }
 
-my %opts = 
+my %opts =
        (
         NAME           => 'DBD::Pg',
         VERSION_FROM   => 'Pg.pm',
@@ -152,15 +156,36 @@
 }
 
 sub MY::postamble {
-       my $string = &dbd_postamble;
+       my $string = dbd_postamble;
        ## Evil, evil stuff - but we really want to suppress the "duplicate 
function" message!
        $string =~ s/dependancy/dependency/g; ## why not, while we are here
        $string =~ s#(BASEEXT\)/g)#$1; s/^do\\\(/dontdo\\\(/#;
        return $string;
 }
 
-WriteMakefile(%opts);
+my $output = WriteMakefile(%opts);
+
+if (!exists $output->{EXTRALIBS} or $output->{EXTRALIBS} !~ /\-lpq/) {
+       warn qq{
+==========================================================
+
+WARNING! No libpq libraries were detected!
+
+You need to install the postgresql-libs package for your system, 
+or set the POSTGRES_LIB environment variable to the correct place.
+
+Removing $output->{MAKEFILE}
+
+===========================================================
+
+};
+
+       ## Do not let make proceed
+       unlink $output->{MAKEFILE};
+
+       exit 1;
+}
 
-exit(0);
+exit 0;
 
 # end of Makefile.PL

Modified: DBD-Pg/trunk/TODO
==============================================================================
--- DBD-Pg/trunk/TODO   (original)
+++ DBD-Pg/trunk/TODO   Wed Jul 18 11:45:28 2007
@@ -1,7 +1,6 @@
 TODO: 
 
 - Play nicely with standard_confirming_strings (CPAN bug #27538)
-- Catch no -lpq when compiling early and complain loudly.
 - Use WITH HOLD for cursor work
 - Start testing with a thread-enabled Perl.
 - Add array OID types

Reply via email to