Makefile.PL 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Net::ZooKeeper - Perl extension for Apache ZooKeeper
  2. #
  3. # Licensed to the Apache Software Foundation (ASF) under one
  4. # or more contributor license agreements. See the NOTICE file
  5. # distributed with this work for additional information
  6. # regarding copyright ownership. The ASF licenses this file
  7. # to you under the Apache License, Version 2.0 (the
  8. # "License"); you may not use this file except in compliance
  9. # with the License. You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. use 5.008_008;
  19. use Config;
  20. use ExtUtils::MakeMaker;
  21. use Getopt::Long;
  22. my $ZOO_MAJOR_VERSION = 3;
  23. my $ZOO_REQUIRED_VERSION = qr{^$ZOO_MAJOR_VERSION\.\d+.\d+$}ismx;
  24. my @zk_inc_paths;
  25. my @zk_lib_paths;
  26. GetOptions(
  27. 'zookeeper-include=s' => \@zk_inc_paths,
  28. 'zookeeper-lib=s' => \@zk_lib_paths
  29. );
  30. my $zk_inc_paths = join(' ', map("-I$_", @zk_inc_paths));
  31. my $zk_lib_paths = join(' ', map("-L$_", @zk_lib_paths));
  32. $zk_inc_paths .= ' ' unless ($zk_inc_paths eq '');
  33. $zk_lib_paths .= ' ' unless ($zk_lib_paths eq '');
  34. my $cc = $Config{'cc'};
  35. my $check_file = 'build/check_zk_version';
  36. my $check_out = qx($cc $zk_inc_paths $zk_lib_paths -I. -o $check_file $check_file.c 2>&1);
  37. if ($?) {
  38. if ($check_out =~ /zookeeper_version\.h/) {
  39. die("Could not determine ZooKeeper version:\n\n$check_out");
  40. }
  41. else {
  42. ## keep in sync with build/check_zk_version.h
  43. die("Net::ZooKeeper requires at least ZooKeeper version 3.1.1\n");
  44. }
  45. }
  46. chomp(my $zk_ver = qx($check_file));
  47. if ($? >> 8 != 0) {
  48. die "Couldn't check zookeeper version: $zk_ver: $r";
  49. }
  50. elsif ($zk_ver !~ $ZOO_REQUIRED_VERSION) {
  51. warn "Net::ZooKeeper requires ZooKeeper 3.x, found $zk_ver!";
  52. }
  53. WriteMakefile(
  54. 'INC' => "$zk_inc_paths-I.",
  55. 'LIBS' => [ "$zk_lib_paths-lzookeeper_mt" ],
  56. 'NAME' => 'Net::ZooKeeper',
  57. 'VERSION_FROM' => 'ZooKeeper.pm',
  58. 'clean' => { 'FILES' => 'build/check_zk_version.o' }
  59. );