| 1 | 1 | package Affix::Platform::BSD v1.4.0 { | |||||||||||||||||||||||||||
| 2 | 1 | ▶ | use v5.40; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use parent 'Affix::Platform::Unix'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use parent 'Exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | our @EXPORT_OK = qw[find_library]; | |||||||||||||||||||||||||||
| 6 | 1 | our %EXPORT_TAGS = ( all => \@EXPORT_OK ); | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 0 | ▶ | sub find_library ( $name, $version //= '' ) { # TODO: actually feed version to diff methods | ||||||||||||||||||||||||||
|
Subroutine
find_library: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 9 | 0 | ▶ | if ( -f $name ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 10 | 0 | ▶ | $name = readlink $name if -l $name; # Handle symbolic links | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 11 | 0 | return $name # if is_elf($name); | |||||||||||||||||||||||||||
| 12 | } | ||||||||||||||||||||||||||||
| 13 | 0 | CORE::state $cache; | |||||||||||||||||||||||||||
| 14 | 0 | ▶ | return $cache->{$name}{$version} if defined $cache->{$name}{$version}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | 0 | my $regex = qr[-l\Q$name\E\.[^\s]+.+\s*=>\s*(.+)$]; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # ldconfig lives in different places per BSD (and NetBSD may not ship it | ||||||||||||||||||||||||||||
| 18 | # at all), so probe the common locations before giving up. | ||||||||||||||||||||||||||||
| 19 | 0 | my $ldconfig = ''; | |||||||||||||||||||||||||||
| 20 | 0 | for my $cmd (qw[/sbin/ldconfig /usr/sbin/ldconfig ldconfig]) { | |||||||||||||||||||||||||||
| 21 | 0 | my $out = `export LC_ALL 'C'; export LANG 'C'; $cmd -r 2>/dev/null`; | |||||||||||||||||||||||||||
| 22 | 0 | ▶ | if ( defined $out && $out =~ /\S/ ) { $ldconfig = $out; last; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $out and $out =~ /\S/u
MC/DC0%0/2
defined $out and $out =~ /\S/u
defined $out
$out =~ /\S/u
Truth table0%0/3
A and B
A= defined $outB= $out =~ /\S/u
| |||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my @found = grep {-e} map { -l $_ ? readlink($_) : $_ } map { $_ =~ $regex; defined $1 ? $1 : () } split /\n\s*/, $ldconfig; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | return $cache->{$name}{$version} = $found[0] if @found; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # No ldconfig (or it doesn't know this library) -- fall back to the | ||||||||||||||||||||||||||||
| 28 | # portable Unix probes (DynaLoader, gcc, ld). | ||||||||||||||||||||||||||||
| 29 | 0 | $cache->{$name}{$version} = Affix::Platform::Unix::find_library( $name, $version ); | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | }; | ||||||||||||||||||||||||||||
| 32 | 1 | 1; | |||||||||||||||||||||||||||