line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::pkgconf; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
719332
|
use strict; |
|
3
|
|
|
|
|
19
|
|
|
3
|
|
|
|
|
89
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
70
|
|
5
|
3
|
|
|
3
|
|
2338
|
use JSON::PP (); |
|
3
|
|
|
|
|
42230
|
|
|
3
|
|
|
|
|
86
|
|
6
|
3
|
|
|
3
|
|
24
|
use File::Spec; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
64
|
|
7
|
3
|
|
|
3
|
|
1643
|
use File::ShareDir (); |
|
3
|
|
|
|
|
72688
|
|
|
3
|
|
|
|
|
1464
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Alien::pkgconf - Discover or download and install pkgconf + libpkgconf |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Alien::pkgconf; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $cflags = Alien::pkgconf->cflags; |
20
|
|
|
|
|
|
|
my $libs = Alien::pkgconf->libs; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
This module provides you with the information that you need to invoke |
25
|
|
|
|
|
|
|
C or link against C. It isn't intended to be |
26
|
|
|
|
|
|
|
used directly, but rather to provide the necessary package by a CPAN |
27
|
|
|
|
|
|
|
module that needs C, such as L. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _dist_dir |
32
|
|
|
|
|
|
|
{ |
33
|
6
|
|
|
6
|
|
7039
|
File::Spec->catdir(File::ShareDir::dist_dir('Alien-pkgconf'), @_); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _dist_file |
37
|
|
|
|
|
|
|
{ |
38
|
2
|
|
|
2
|
|
10
|
File::Spec->catfile(File::ShareDir::dist_dir('Alien-pkgconf'), @_); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $config; |
42
|
|
|
|
|
|
|
sub _config |
43
|
|
|
|
|
|
|
{ |
44
|
9
|
|
66
|
9
|
|
748
|
$config ||= do { |
45
|
2
|
|
|
|
|
9
|
my $filename = _dist_file('status.json'); |
46
|
2
|
|
|
|
|
273
|
my $fh; |
47
|
2
|
|
|
|
|
82
|
open $fh, '<', $filename; |
48
|
2
|
|
|
|
|
8
|
my $json = JSON::PP::decode_json(do { local $/; <$fh> }); |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
88
|
|
49
|
2
|
|
|
|
|
5099
|
close $fh; |
50
|
2
|
|
|
|
|
30
|
$json; |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 METHODS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 cflags |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $cflags = Alien::pkgconf->cflags; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
The compiler flags for compiling against C. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub cflags |
65
|
|
|
|
|
|
|
{ |
66
|
1
|
|
|
1
|
1
|
7697
|
my($class) = @_; |
67
|
|
|
|
|
|
|
$class->install_type eq 'share' |
68
|
|
|
|
|
|
|
# may induce duplicates :/ |
69
|
1
|
|
|
|
|
9
|
? "-I@{[ _dist_dir 'include', 'pkgconf' ]} @{[ _config->{cflags} ]}" |
|
1
|
|
|
|
|
130
|
|
70
|
1
|
50
|
|
|
|
67
|
: _config->{cflags}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 libs |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $libs = Alien::pkgconf->libs; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
The linker flags for linking against C. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub libs |
82
|
|
|
|
|
|
|
{ |
83
|
2
|
|
|
2
|
1
|
527890
|
my($class) = @_; |
84
|
|
|
|
|
|
|
$class->install_type eq 'share' |
85
|
|
|
|
|
|
|
# may induce duplicates :/ |
86
|
2
|
|
|
|
|
41
|
? "-L@{[ _dist_dir 'lib' ]} @{[ _config->{libs} ]}" |
|
2
|
|
|
|
|
524
|
|
87
|
2
|
50
|
|
|
|
37
|
: _config->{libs}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 dynamic_libs |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my($dll) = Alien::pkgconf->dynamic_libs; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The C<.so>, C<.dll> or C<.dynlib> shared or dynamic library |
95
|
|
|
|
|
|
|
which can be used via FFI. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub dynamic_libs |
100
|
|
|
|
|
|
|
{ |
101
|
0
|
|
|
0
|
1
|
0
|
my($class) = @_; |
102
|
|
|
|
|
|
|
$class->install_type eq 'share' |
103
|
|
|
|
|
|
|
? (_dist_file('dll', _config->{dll})) |
104
|
0
|
0
|
|
|
|
0
|
: (_config->{dll}); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 version |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my $version = Alien::pkgconf->version; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The C version. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub version |
116
|
|
|
|
|
|
|
{ |
117
|
0
|
|
|
0
|
1
|
0
|
_config->{version}; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 bin_dir |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my($dir) = Alien::pkgconf->bin_dir; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
The directory where you can find C. If it is not |
125
|
|
|
|
|
|
|
already in the C. Adding this to C should make |
126
|
|
|
|
|
|
|
tools that require C work. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub bin_dir |
131
|
|
|
|
|
|
|
{ |
132
|
2
|
|
|
2
|
1
|
676
|
my($class) = @_; |
133
|
2
|
50
|
|
|
|
10
|
$class->install_type eq 'share' |
134
|
|
|
|
|
|
|
? (_dist_dir 'bin') |
135
|
|
|
|
|
|
|
: (); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 install_type |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
my $type = Alien::pkgconf->install_type; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
The type of install, should be either C or C. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub install_type |
147
|
|
|
|
|
|
|
{ |
148
|
5
|
|
|
5
|
1
|
49
|
_config->{install_type}; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 HELPERS |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 pkgconf |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
%{pkgconf} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
The name of the C binary. This is usually just C. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub alien_helper { |
162
|
|
|
|
|
|
|
return { |
163
|
1
|
|
|
1
|
|
7
|
pkgconf => sub { 'pkgconf' }, |
164
|
|
|
|
|
|
|
} |
165
|
1
|
|
|
1
|
0
|
95
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
1; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 SEE ALSO |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=over 4 |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item L |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=back |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 PLATFORM NOTES |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 Solaris |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
You may need to have the GNU version of nm installed, which comes |
182
|
|
|
|
|
|
|
with GNU binutils. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 ACKNOWLEDGMENTS |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Thanks to the C developers for their efforts: |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
L |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 AUTHOR |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Graham Ollis |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Contributors: |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Thibault Duponchelle (tib) |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This software is copyright (c) 2016 Graham Ollis. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
This is free software; you may redistribute it and/or modify it under |
203
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=cut |
206
|
|
|
|
|
|
|
|