line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ExtUtils::PkgConfig; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
193704
|
use strict; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
118
|
|
4
|
5
|
|
|
5
|
|
15
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
99
|
|
5
|
5
|
|
|
5
|
|
60873
|
use PkgConfig::LibPkgConf::Client; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use PkgConfig::LibPkgConf::Util (); |
7
|
|
|
|
|
|
|
use Carp qw( croak ); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: simplistic interface to pkgconf via libpkgconf (similar to pkg-config) |
10
|
|
|
|
|
|
|
our $VERSION = '1.15'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _find |
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
PkgConfig::LibPkgConf::Client->new->find($_[0]); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub find |
18
|
|
|
|
|
|
|
{ |
19
|
|
|
|
|
|
|
my(undef, @pkg_candidates) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my @pkgs_found; |
22
|
|
|
|
|
|
|
my @error_messages; |
23
|
|
|
|
|
|
|
my $first_package; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
foreach my $candidate (@pkg_candidates) |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
my $package = _find($candidate); |
28
|
|
|
|
|
|
|
if($package) |
29
|
|
|
|
|
|
|
{ |
30
|
|
|
|
|
|
|
push @pkgs_found, $candidate; |
31
|
|
|
|
|
|
|
$first_package ||= $package; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else |
34
|
|
|
|
|
|
|
{ |
35
|
|
|
|
|
|
|
push @error_messages, "Package $candidate not found"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
if(!@pkgs_found) |
40
|
|
|
|
|
|
|
{ |
41
|
|
|
|
|
|
|
foreach my $message (@error_messages) { |
42
|
|
|
|
|
|
|
carp $message; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
if(@pkg_candidates > 1) |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
croak "*** can not find package for any of (@{[ join ', ', @pkg_candidates ]})\n" |
48
|
|
|
|
|
|
|
. "*** check that one of them is properly installed and available in PKG_CONFIG_PATH\n"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
else |
51
|
|
|
|
|
|
|
{ |
52
|
|
|
|
|
|
|
croak "*** can not find package $pkg_candidates[0]\n" |
53
|
|
|
|
|
|
|
. "*** check that it is properly installed and available in PKG_CONFIG_PATH\n"; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my %data = ( |
58
|
|
|
|
|
|
|
pkg => $pkgs_found[0], |
59
|
|
|
|
|
|
|
modversion => $first_package->version, |
60
|
|
|
|
|
|
|
cflags => $first_package->cflags, |
61
|
|
|
|
|
|
|
libs => $first_package->libs, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
%data; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub modversion |
68
|
|
|
|
|
|
|
{ |
69
|
|
|
|
|
|
|
my(undef, $modulename) = @_; |
70
|
|
|
|
|
|
|
my $package = _find($modulename); |
71
|
|
|
|
|
|
|
defined $package ? $package->version : undef; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub cflags |
75
|
|
|
|
|
|
|
{ |
76
|
|
|
|
|
|
|
my(undef, $modulename) = @_; |
77
|
|
|
|
|
|
|
my $package = _find($modulename); |
78
|
|
|
|
|
|
|
defined $package ? $package->cflags : undef; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub libs |
82
|
|
|
|
|
|
|
{ |
83
|
|
|
|
|
|
|
my(undef, $modulename) = @_; |
84
|
|
|
|
|
|
|
my $package = _find($modulename); |
85
|
|
|
|
|
|
|
defined $package ? $package->libs : undef; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub static_libs |
89
|
|
|
|
|
|
|
{ |
90
|
|
|
|
|
|
|
my(undef, $modulename) = @_; |
91
|
|
|
|
|
|
|
my $package = _find($modulename); |
92
|
|
|
|
|
|
|
defined $package ? $package->libs_static : undef; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _compare_version |
96
|
|
|
|
|
|
|
{ |
97
|
|
|
|
|
|
|
PkgConfig::LibPkgConf::Util::compare_version(@_); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub atleast_version |
101
|
|
|
|
|
|
|
{ |
102
|
|
|
|
|
|
|
my(undef, $modulename, $version) = @_; |
103
|
|
|
|
|
|
|
my $package = _find($modulename); |
104
|
|
|
|
|
|
|
$package && (_compare_version($version, $package->version) <= 0 ) |
105
|
|
|
|
|
|
|
? 1 : undef; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub exact_version |
109
|
|
|
|
|
|
|
{ |
110
|
|
|
|
|
|
|
my(undef, $modulename, $version) = @_; |
111
|
|
|
|
|
|
|
my $package = _find($modulename); |
112
|
|
|
|
|
|
|
$package && (_compare_version($version, $package->version) == 0 ) |
113
|
|
|
|
|
|
|
? 1 : undef; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub max_version |
117
|
|
|
|
|
|
|
{ |
118
|
|
|
|
|
|
|
my(undef, $modulename, $version) = @_; |
119
|
|
|
|
|
|
|
my $package = _find($modulename); |
120
|
|
|
|
|
|
|
$package && (_compare_version($version, $package->version) >= 0 ) |
121
|
|
|
|
|
|
|
? 1 : undef; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub _escape |
125
|
|
|
|
|
|
|
{ |
126
|
|
|
|
|
|
|
my($fragment) = "$_[0]"; |
127
|
|
|
|
|
|
|
$fragment =~ s/(\s)/\\$1/g; |
128
|
|
|
|
|
|
|
$fragment; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub cflags_only_I |
132
|
|
|
|
|
|
|
{ |
133
|
|
|
|
|
|
|
my(undef, $modulename) = @_; |
134
|
|
|
|
|
|
|
my $package = _find($modulename); |
135
|
|
|
|
|
|
|
$package ? join(' ', map { _escape $_ } grep { $_->type eq 'I' } $package->list_cflags) . ' ' : undef; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub cflags_only_other |
139
|
|
|
|
|
|
|
{ |
140
|
|
|
|
|
|
|
my(undef, $modulename) = @_; |
141
|
|
|
|
|
|
|
my $package = _find($modulename); |
142
|
|
|
|
|
|
|
$package ? join(' ', map { _escape $_ } grep { $_->type ne 'I' } $package->list_cflags) . ' ' : undef; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub libs_only_L |
146
|
|
|
|
|
|
|
{ |
147
|
|
|
|
|
|
|
my(undef, $modulename) = @_; |
148
|
|
|
|
|
|
|
my $package = _find($modulename); |
149
|
|
|
|
|
|
|
$package ? join(' ', map { _escape $_ } grep { $_->type eq 'L' } $package->list_libs) . ' ' : undef; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub libs_only_l |
153
|
|
|
|
|
|
|
{ |
154
|
|
|
|
|
|
|
my(undef, $modulename) = @_; |
155
|
|
|
|
|
|
|
my $package = _find($modulename); |
156
|
|
|
|
|
|
|
$package ? join(' ', map { _escape $_ } grep { $_->type eq 'l' } $package->list_libs) . ' ' : undef; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub libs_only_other |
160
|
|
|
|
|
|
|
{ |
161
|
|
|
|
|
|
|
my(undef, $modulename) = @_; |
162
|
|
|
|
|
|
|
my $package = _find($modulename); |
163
|
|
|
|
|
|
|
$package ? join(' ', map { _escape $_ } grep { $_->type ne 'L' && $_->type ne 'l' } $package->list_libs) . ' ' : undef; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub variable |
167
|
|
|
|
|
|
|
{ |
168
|
|
|
|
|
|
|
my(undef, $modulename, $key) = @_; |
169
|
|
|
|
|
|
|
my $package = _find($modulename); |
170
|
|
|
|
|
|
|
my $value; |
171
|
|
|
|
|
|
|
$value = $package->variable($key) if $package; |
172
|
|
|
|
|
|
|
$value; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# the "create_version_macros" and "write_version_macros" and the documentation |
176
|
|
|
|
|
|
|
# below are distributed under this license: |
177
|
|
|
|
|
|
|
# |
178
|
|
|
|
|
|
|
# Copyright (c) 2003-2004, 2012-2013 by the gtk2-perl team (see the file |
179
|
|
|
|
|
|
|
# AUTHORS) |
180
|
|
|
|
|
|
|
# |
181
|
|
|
|
|
|
|
# This library is free software; you can redistribute it and/or |
182
|
|
|
|
|
|
|
# modify it under the terms of the GNU Library General Public |
183
|
|
|
|
|
|
|
# License as published by the Free Software Foundation; either |
184
|
|
|
|
|
|
|
# version 2 of the License, or (at your option) any later version. |
185
|
|
|
|
|
|
|
# |
186
|
|
|
|
|
|
|
# This library is distributed in the hope that it will be useful, |
187
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
188
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
189
|
|
|
|
|
|
|
# Library General Public License for more details. |
190
|
|
|
|
|
|
|
# |
191
|
|
|
|
|
|
|
# You should have received a copy of the GNU Library General Public |
192
|
|
|
|
|
|
|
# License along with this library; if not, write to the |
193
|
|
|
|
|
|
|
# Free Software Foundation, Inc., |
194
|
|
|
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub create_version_macros { |
197
|
|
|
|
|
|
|
my (undef, $pkg, $stem) = @_; |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
if( $pkg && $stem ) { |
200
|
|
|
|
|
|
|
my %data = ExtUtils::PkgConfig->find ($pkg); |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
if( %data ) { |
203
|
|
|
|
|
|
|
my @modversion = split /\./, $data{modversion}; |
204
|
|
|
|
|
|
|
$modversion[1] = 0 unless defined $modversion[1]; |
205
|
|
|
|
|
|
|
$modversion[2] = 0 unless defined $modversion[2]; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# If a version part contains non-numeric characters, |
208
|
|
|
|
|
|
|
# see if it at least starts with numbers and use those. |
209
|
|
|
|
|
|
|
# This is needed for versions like '2.0b2'. |
210
|
|
|
|
|
|
|
# foreach ( @modversion ) { |
211
|
|
|
|
|
|
|
# if (/\D/ && /^(\d+)/) { |
212
|
|
|
|
|
|
|
# $_ = $1; |
213
|
|
|
|
|
|
|
# } |
214
|
|
|
|
|
|
|
# } |
215
|
|
|
|
|
|
|
@modversion = |
216
|
|
|
|
|
|
|
map { /\D/ && /^(\d+)/ ? $1 : $_ } @modversion; |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
return <<__EOD__; |
219
|
|
|
|
|
|
|
#define $stem\_MAJOR_VERSION ($modversion[0]) |
220
|
|
|
|
|
|
|
#define $stem\_MINOR_VERSION ($modversion[1]) |
221
|
|
|
|
|
|
|
#define $stem\_MICRO_VERSION ($modversion[2]) |
222
|
|
|
|
|
|
|
#define $stem\_CHECK_VERSION(major,minor,micro) \\ |
223
|
|
|
|
|
|
|
($stem\_MAJOR_VERSION > (major) || \\ |
224
|
|
|
|
|
|
|
($stem\_MAJOR_VERSION == (major) && $stem\_MINOR_VERSION > (minor)) || \\ |
225
|
|
|
|
|
|
|
($stem\_MAJOR_VERSION == (major) && $stem\_MINOR_VERSION == (minor) && $stem\_MICRO_VERSION >= (micro))) |
226
|
|
|
|
|
|
|
__EOD__ |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
return undef; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub write_version_macros { |
234
|
|
|
|
|
|
|
my (undef, $file, @pkgs) = @_; |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
open FILE, ">$file" or croak "*** can not open file $file for writing\n"; |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
for (my $i = 0; $i < @pkgs; $i += 2) { |
239
|
|
|
|
|
|
|
my $macros = ExtUtils::PkgConfig->create_version_macros ($pkgs[$i], $pkgs[$i+1]); |
240
|
|
|
|
|
|
|
if( defined $macros ) { |
241
|
|
|
|
|
|
|
print FILE $macros; |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
close FILE or croak "*** can not close file $file\n"; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
1; |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
__END__ |