Subject: | Makefile.PL: if libct only exists under lib64, use it properly |
Here is a patch that fixes the finding of $libdir on a Linux system that has /usr/lib64/libct.so, but no /usr/lib/libct.so.
Without the fix, DBD-Sybase fails to build. In detail:
1) Makefile.PL, configure() searches for libct under /usr/lib and /usr/lib64, finding it under the latter only
2) $libdir here is both a global and the loop variable of the foreach (@libdir) loop; as a result, we set it to "lib64" in the 2nd iteration of the loop (and it takes effect in the call to checkLib() in the 2nd iteration) but as soon as we're out of the loop, it is set back to its global value ("lib")
3) As a result, we WriteMakefile(LIBS => "-L/usr/lib", ...), which is wrong (should be "-L/usr/lib64")
4) As a result, the build fails to find libct.so.
The patch fixes this. Please note it's a diff not against the 1.15 version, but against some of my earlier proposed patches (see 92196, 92159, 91298?).
==== //depot/QA/Toolbox/main.br/CPAN/DBD-Sybase/1.15/src/Makefile.PL#6 - /ns/build/users/ferencis/0toolbox/main.br/CPAN/DBD-Sybase/1.15/src/Makefile.PL ====
--- /tmp/tmp.16791.8 2014-01-24 16:43:33.000000000 +0000
+++ /ns/build/users/ferencis/0toolbox/main.br/CPAN/DBD-Sybase/1.15/src/Makefile.PL 2014-01-24 16:43:30.000000000 +0000
@@ -18,7 +18,6 @@
$LINKTYPE = 'dynamic';
$written_pwd_file = 'PWD';
-$libdir = 'lib';
my $file;
my $chained;
@@ -34,7 +33,7 @@
select(STDOUT);
$| = 1;
-configure();
+configure(); # sets most globals
configPwd();
@@ -139,24 +138,22 @@
}
}
- my $libfound = 0;
- my $libsub = '';
my @libdir = ( 'lib', 'lib64' );
if ($^O eq 'MSWin32') {
@libdir = ( 'dll' );
}
- foreach $libdir ( @libdir ) {
- if ( -d "$SYBASE/$libdir" ) {
- if ( checkLib($SYBASE) ) {
- $libfound = 1;
- $libsub = $libdir;
+ foreach my $libsub ( @libdir ) {
+ if ( -d "$SYBASE/$libsub" ) {
+ if ( checkLib("$SYBASE/$libsub") ) {
+ $libdir = $libsub;
+ last;
}
}
}
die "Can't find any Sybase libraries in " .
join(' or ', map "$SYBASE/$_", @libdir)
- unless $libfound;
+ unless defined $libdir;
my $inc_found = 0;
if ( -d "$SYBASE/include" && -f "$SYBASE/include/cspublic.h" ) {
@@ -174,7 +171,7 @@
die "Can't find the Client Library include files under $SYBASE"
unless ($inc_found);
- my $version = getLibVersion("$SYBASE/$libsub");
+ my $version = getLibVersion("$SYBASE/$libdir");
# if(!$version || $version lt '12') {
#print "FreeTDS or older Client Library. Enabling CS-Lib Callbacks\n";
@@ -187,10 +184,10 @@
if ( $^O eq 'MSWin32' ) {
if ($version ge '15') {
- $lib_string = "-L$SYBASE/$libsub -llibsybct.lib -llibsybcs.lib -llibsybtcl.lib -llibsybcomn.lib -llibsybintl.lib -llibsybblk.lib $attr{EXTRA_LIBS} -lm";
+ $lib_string = "-L$SYBASE/$libdir -llibsybct.lib -llibsybcs.lib -llibsybtcl.lib -llibsybcomn.lib -llibsybintl.lib -llibsybblk.lib $attr{EXTRA_LIBS} -lm";
}
else {
- $lib_string = "-L$SYBASE/$libsub -llibct.lib -llibcs.lib -llibtcl.lib -llibcomn.lib -llibintl.lib -llibblk.lib $attr{EXTRA_LIBS} -lm";
+ $lib_string = "-L$SYBASE/$libdir -llibct.lib -llibcs.lib -llibtcl.lib -llibcomn.lib -llibintl.lib -llibblk.lib $attr{EXTRA_LIBS} -lm";
}
}
elsif ( $^O eq 'VMS' ) {
@@ -412,7 +409,7 @@
sub checkLib {
my $dir = shift;
- opendir( DIR, "$dir/$libdir" ) || die "Can't access $dir/$libdir: $!";
+ opendir( DIR, $dir ) || die "Can't access $dir: $!";
my @files = grep( /libct|libsybct/i, readdir(DIR) );
closedir(DIR);
if ( grep( /libsybct/, @files ) ) {