| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Alien::libzookeeper; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 126955 | use 5.006; | 
|  | 1 |  |  |  |  | 5 |  | 
| 4 | 1 |  |  | 1 |  | 5 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 22 |  | 
| 5 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 31 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 1 |  |  | 1 |  | 590 | use parent 'Alien::Base'; | 
|  | 1 |  |  |  |  | 298 |  | 
|  | 1 |  |  |  |  | 7 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | =head1 NAME | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | Alien::libzookeeper - libzookeeper, with alien | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | =head1 VERSION | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | Version 0.04 | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | =cut | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | our $VERSION = '0.04'; | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | use Alien::libzookeeper; | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | Alien::libzookeeper->libs; | 
| 27 |  |  |  |  |  |  | Alien::libzookeeper->libs_static; | 
| 28 |  |  |  |  |  |  | Alien::libzookeeper->cflags; | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | # Or a more realistic example; in your makefile: | 
| 31 |  |  |  |  |  |  | use Config; | 
| 32 |  |  |  |  |  |  | my $zk_libs        = Alien::libzookeeper->libs; | 
| 33 |  |  |  |  |  |  | my $zk_libs_static = Alien::libzookeeper->libs_static; | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | my $lddflags = $Config{lddlflags} // ''; | 
| 36 |  |  |  |  |  |  | $lddlflags  .= ' '; | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | my $libext = $Config{lib_ext}; | 
| 39 |  |  |  |  |  |  | if ( $libs_static =~ /libzookeeper\.\Q$libext\E/ ) { | 
| 40 |  |  |  |  |  |  | # We can statically link against libzookeeper. | 
| 41 |  |  |  |  |  |  | # To link statically, we need to pass arguments to `ld`, not to the C | 
| 42 |  |  |  |  |  |  | # compiler, and we need to drop the dynamic version from the arguments: | 
| 43 |  |  |  |  |  |  | $_ =~ s/-lzookeeper\b// for $zk_libs, $zk_libs_static; | 
| 44 |  |  |  |  |  |  | $lddlflags .= ' ' . $zk_libs_static; | 
| 45 |  |  |  |  |  |  | } | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | WriteMakefile( | 
| 48 |  |  |  |  |  |  | INC       => Alien::libzookeeper->cflags, | 
| 49 |  |  |  |  |  |  | LIBS      => [ $zk_libs ], | 
| 50 |  |  |  |  |  |  | LDDLFLAGS => [ $lddlflags ], | 
| 51 |  |  |  |  |  |  | ... | 
| 52 |  |  |  |  |  |  | ); | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | C is an C interface to C. | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | Turns out that C is pretty hard to get hold of!  It's source is | 
| 59 |  |  |  |  |  |  | shipped as part of ZooKeeper, so in some systems you need to install ZooKeeper | 
| 60 |  |  |  |  |  |  | -- and all the Java stack it needs -- just to get the C shared library. | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | In other systems, you can get it from package managers just fine, but it doesn't | 
| 63 |  |  |  |  |  |  | have a C meta file, and so finding it ends up requiring writing and | 
| 64 |  |  |  |  |  |  | running C. | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | And in some systems (Alpine, Arch-Linux) there's just no way to get the library. | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | And even if you got it -- it might be called C instead! | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | This module tries very hard to get a working C:  It checks pkg-config, | 
| 71 |  |  |  |  |  |  | it checks by compiling code, and if there's nothing in the system that we can use, | 
| 72 |  |  |  |  |  |  | it builds version 3.5.6 from source. | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | =head1 NOTES | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | The built-from-source version comes with some caveats! | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | First, we use version 3.5.6 because that's the last official release that | 
| 79 |  |  |  |  |  |  | can be built from source without needing Java; see L | 
| 80 |  |  |  |  |  |  | for details. | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | Second, we patch a bug fixed upstream in the 3.6.x releases that lead | 
| 83 |  |  |  |  |  |  | to segfaults on connection errors; see L | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | Third, we patch its C with some missing make targets; | 
| 86 |  |  |  |  |  |  | see L. | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | Fourth, we patch its C to change how it generates the | 
| 89 |  |  |  |  |  |  | statically-linked C; see L | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | Fifth, we patch its build process to generate a C meta | 
| 92 |  |  |  |  |  |  | file; see L | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | Hopefully as the above get addressed, there will be less and less | 
| 95 |  |  |  |  |  |  | cases where this module ends up building the library itself; | 
| 96 |  |  |  |  |  |  | or at least we'll be able to get rid of some of these patches! | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =head1 AUTHOR | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | B Fraser, C<<  >> | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | =head1 BUGS | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | Please report any bugs or feature requests to C, or through | 
| 105 |  |  |  |  |  |  | the web interface at L.  I will be notified, and then you'll | 
| 106 |  |  |  |  |  |  | automatically be notified of progress on your bug as I make changes. | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | =head1 LICENSE AND COPYRIGHT | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | This software is Copyright (c) 2020 by B Fraser. | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | This is free software, licensed under: | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | The Artistic License 2.0 (GPL Compatible) | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | =cut | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | 1; # End of Alien::libzookeeper |