Browse Source

ZOOKEEPER-1034. perl bindings should automatically find the zookeeper c-client headers (nicholas harteau via mahadev)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1157698 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar 13 years ago
parent
commit
1ebe43dabf

+ 3 - 0
CHANGES.txt

@@ -387,6 +387,9 @@ IMPROVEMENTS:
   ZOOKEEPER-1104. CLONE - In QuorumTest, use the same "for ( .. try { break }
   catch { } )" pattern in testFollowersStartAfterLeaders as in testSessionMove. 
   (Eugene Koontz via mahadev)
+ 
+  ZOOKEEPER-1034. perl bindings should automatically find the zookeeper
+  c-client headers (nicholas harteau via mahadev)
 
 NEW FEATURES:
   ZOOKEEPER-729. Java client API to recursively delete a subtree.

+ 4 - 0
src/contrib/zkperl/Changes

@@ -59,3 +59,7 @@ Revision history
 0.35  Jul 15, 2009
         - support multiple include and library locations
 
+0.36  Mar 27, 2011
+        - Fix zookeeper version check, but only warn since we haven't been enforcing it in a while
+        - Look for zookeeper includes in some sane places by default
+

+ 13 - 2
src/contrib/zkperl/Makefile.PL

@@ -22,6 +22,9 @@ use Config;
 use ExtUtils::MakeMaker;
 use Getopt::Long;
 
+my $ZOO_MAJOR_VERSION = 3;
+my $ZOO_REQUIRED_VERSION = qr{^$ZOO_MAJOR_VERSION\.\d+.\d+$}ismx;
+
 my @zk_inc_paths;
 my @zk_lib_paths;
 
@@ -39,8 +42,7 @@ $zk_lib_paths .= ' ' unless ($zk_lib_paths eq '');
 my $cc = $Config{'cc'};
 my $check_file = 'build/check_zk_version';
 
-my $check_out =
-    qx($cc -c $zk_inc_paths -I. -c $check_file.c -o $check_file.o 2>&1);
+my $check_out = qx($cc $zk_inc_paths $zk_lib_paths -I. -o $check_file $check_file.c 2>&1);
 
 if ($?) {
     if ($check_out =~ /zookeeper_version\.h/) {
@@ -52,6 +54,15 @@ if ($?) {
     }
 }
 
+chomp(my $zk_ver = qx($check_file));
+
+if ($? >> 8 != 0) {
+  die "Couldn't check zookeeper version: $zk_ver: $r";
+}
+elsif ($zk_ver !~ $ZOO_REQUIRED_VERSION) {
+  warn "Net::ZooKeeper requires ZooKeeper 3.x, found $zk_ver!";
+}
+
 WriteMakefile(
     'INC'          => "$zk_inc_paths-I.",
     'LIBS'         => [ "$zk_lib_paths-lzookeeper_mt" ],

+ 10 - 4
src/contrib/zkperl/README

@@ -10,15 +10,21 @@ http://hadoop.apache.org/zookeeper/
 
 INSTALLATION
 
-To install this module type the following:
+To install this module type the following, first install the
+zookeeper C client, then:
 
-    perl Makefile.PL \
-        --zookeeper-include=/path/to/zookeeper/client/include \
-        --zookeeper-lib=/path/to/zookeeper/client/lib
+    perl Makefile.PL
     make
     ZK_TEST_HOSTS=host:port,... make test
     make install
 
+If the C headers and library are installed in non-standard
+locations, specify them as arguments to Makefile.PL:
+    
+    perl Makefile.PL \
+        --zookeeper-include=/path/to/zookeeper/client/include \
+        --zookeeper-lib=/path/to/zookeeper/client/lib
+
 The path supplied to the --zookeeper-include option should
 identify the directory that contains the zookeeper.h and other
 ZooKeeper C include files.

+ 1 - 1
src/contrib/zkperl/ZooKeeper.pm

@@ -26,7 +26,7 @@ package Net::ZooKeeper;
 require Exporter;
 require XSLoader;
 
-our $VERSION = '0.35';
+our $VERSION = '0.36';
 
 our @ISA = qw(Exporter);
 

+ 1 - 1
src/contrib/zkperl/ZooKeeper.xs

@@ -28,7 +28,7 @@
 #include <limits.h>                     /* CHAR_BIT */
 #include <sys/time.h>                   /* gettimeofday() */
 
-#include "zookeeper.h"
+#include <zookeeper/zookeeper.h>
 
 #include "build/check_zk_version.h"
 

+ 6 - 2
src/contrib/zkperl/build/check_zk_version.c

@@ -17,9 +17,13 @@
  * limitations under the License.
  */
 
-#include "zookeeper_version.h"
+#include <stdio.h>
+#include <zookeeper/zookeeper_version.h>
 
 #include "check_zk_version.h"
 
-int main() {}
+int main() {
+  printf("%d.%d.%d\n", ZOO_MAJOR_VERSION, ZOO_MINOR_VERSION, ZOO_PATCH_VERSION);
+  return 0;
+}