| 1 | package Alien::libmaxminddb; | ||||||||||
| 2 | |||||||||||
| 3 | # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later | ||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use 5.014; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | our $VERSION = 2.005; | |||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use File::Spec qw(); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use JSON::PP qw(); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | sub cflags { | ||||||||
|
Subroutine
cflags: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 15 | 1 | my $class = shift; | |||||||||
| 16 | |||||||||||
| 17 | 1 | return $class->config->{cflags}; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 1 | ▶ | sub libs { | ||||||||
|
Subroutine
libs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 21 | 1 | my $class = shift; | |||||||||
| 22 | |||||||||||
| 23 | 1 | return $class->config->{libs}; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 1 | ▶ | sub version { | ||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 27 | 1 | my $class = shift; | |||||||||
| 28 | |||||||||||
| 29 | 1 | return $class->config->{version}; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 1 | ▶ | sub install_type { | ||||||||
|
Subroutine
install_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 33 | 1 | my $class = shift; | |||||||||
| 34 | |||||||||||
| 35 | 1 | return $class->config->{install_type}; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 4 | ▶ | sub config { | ||||||||
|
Subroutine
config: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 39 | 4 | my $class = shift; | |||||||||
| 40 | |||||||||||
| 41 | 4 | state $config = $class->_config; | |||||||||
| 42 | 4 | return $config; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 1 | ▶ | sub dynamic_libs { | ||||||||
|
Subroutine
dynamic_libs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 46 | 1 | my $class = shift; | |||||||||
| 47 | |||||||||||
| 48 | 1 | return; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 1 | ▶ | sub bin_dir { | ||||||||
|
Subroutine
bin_dir: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 52 | 1 | my $class = shift; | |||||||||
| 53 | |||||||||||
| 54 | 1 | return; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 3 | ▶ | sub _dist_dir_with_subdir { | ||||||||
|
Subroutine
_dist_dir_with_subdir: called CC=3 SCAR=11.0
| |||||||||||
| 58 | 3 | my ($class, $subdir) = @_; | |||||||||
| 59 | |||||||||||
| 60 | 3 | my $dist = $class; | |||||||||
| 61 | 3 | $dist =~ s/::/-/g; | |||||||||
| 62 | |||||||||||
| 63 | 3 | my $search_dir = File::Spec->catdir(qw(auto share dist), $dist, $subdir); | |||||||||
| 64 | 3 | for my $inc (@INC) { | |||||||||
| 65 | 6 | my $dir = File::Spec->catdir($inc, $search_dir); | |||||||||
| 66 | 6 | ▶ | if (-d $dir) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 3 | return $dir; | |||||||||
| 68 | } | ||||||||||
| 69 | } | ||||||||||
| 70 | 0 | die "unable to find dist share directory for $dist"; | |||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | 1 | ▶ | sub _config { | ||||||||
|
Subroutine
_config: called CC=3 SCAR=11.0
| |||||||||||
| 74 | 1 | my $class = shift; | |||||||||
| 75 | |||||||||||
| 76 | 1 | my $alien_dir = $class->_dist_dir_with_subdir('_alien'); | |||||||||
| 77 | |||||||||||
| 78 | 1 | my $json_file = File::Spec->catfile($alien_dir, 'alien.json'); | |||||||||
| 79 | 1 | ▶ | open my $in, '<', $json_file | ||||||||
|
Branch: 1 branch
| |||||||||||
| 80 | or die "Cannot read $json_file"; | ||||||||||
| 81 | 1 | my $json = do { local $/; <$in> }; | |||||||||
| 82 | 1 | close $in; | |||||||||
| 83 | |||||||||||
| 84 | 1 | my $config = JSON::PP::decode_json($json); | |||||||||
| 85 | |||||||||||
| 86 | 1 | ▶ | if ($config->{install_type} eq 'share') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | 1 | my $inc_dir = $class->_dist_dir_with_subdir('include'); | |||||||||
| 88 | 1 | $config->{cflags} = join ' ', "-I$inc_dir", $config->{cflags}; | |||||||||
| 89 | 1 | my $lib_dir = $class->_dist_dir_with_subdir('lib'); | |||||||||
| 90 | 1 | $config->{libs} = join ' ', "-L$lib_dir", $config->{libs}; | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | 1 | return $config; | |||||||||
| 94 | } | ||||||||||
| 95 | |||||||||||
| 96 | 1 | 1; | |||||||||
| 97 | __END__ | ||||||||||