line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::AutoConf; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
277975
|
use warnings; |
|
5
|
|
|
|
|
37
|
|
|
5
|
|
|
|
|
170
|
|
4
|
5
|
|
|
5
|
|
41
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
120
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
21
|
use base 'Exporter'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
863
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT = ('$LIBEXT', '$EXEEXT'); |
9
|
|
|
|
|
|
|
|
10
|
4
|
50
|
|
4
|
|
32
|
use constant QUOTE => do { $^O eq "MSWin32" ? q["] : q['] }; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
458
|
|
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
35
|
use Config; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
188
|
|
13
|
4
|
|
|
4
|
|
34
|
use Carp qw/croak/; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
229
|
|
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
3045
|
use File::Temp qw/tempfile/; |
|
4
|
|
|
|
|
86336
|
|
|
4
|
|
|
|
|
254
|
|
16
|
4
|
|
|
4
|
|
34
|
use File::Basename; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
422
|
|
17
|
4
|
|
|
4
|
|
29
|
use File::Spec; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
90
|
|
18
|
4
|
|
|
4
|
|
1879
|
use Text::ParseWords qw//; |
|
4
|
|
|
|
|
5360
|
|
|
4
|
|
|
|
|
132
|
|
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
4
|
|
2074
|
use Capture::Tiny qw/capture/; |
|
4
|
|
|
|
|
25073
|
|
|
4
|
|
|
|
|
75287
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# in core since 5.7.3 |
23
|
4
|
|
|
4
|
|
33
|
eval "use Scalar::Util qw/looks_like_number/;"; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
165
|
|
24
|
|
|
|
|
|
|
__PACKAGE__->can("looks_like_number") or eval <<'EOP'; |
25
|
|
|
|
|
|
|
=begin private |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 looks_like_number |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=end private |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# from PP part of Params::Util |
34
|
|
|
|
|
|
|
sub looks_like_number { |
35
|
|
|
|
|
|
|
local $_ = shift; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# checks from perlfaq4 |
38
|
|
|
|
|
|
|
return 0 if !defined($_); |
39
|
|
|
|
|
|
|
if (ref($_)) { |
40
|
|
|
|
|
|
|
return overload::Overloaded($_) ? defined(0 + $_) : 0; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
return 1 if (/^[+-]?[0-9]+$/); # is a +/- integer |
43
|
|
|
|
|
|
|
return 1 if (/^([+-]?)(?=[0-9]|\.[0-9])[0-9]*(\.[0-9]*)?([Ee]([+-]?[0-9]+))?$/); # a C float |
44
|
|
|
|
|
|
|
return 1 if ($] >= 5.008 and /^(Inf(inity)?|NaN)$/i) or ($] >= 5.006001 and /^Inf$/i); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
0; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
EOP |
49
|
|
|
|
|
|
|
|
50
|
4
|
|
|
4
|
|
1901
|
eval "use File::Slurper qw/read_binary/;"; |
|
4
|
|
|
|
|
56321
|
|
|
4
|
|
|
|
|
169
|
|
51
|
|
|
|
|
|
|
__PACKAGE__->can("read_binary") or eval <<'EOP'; |
52
|
|
|
|
|
|
|
=begin private |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 read_file |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=end private |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub read_binary { |
61
|
|
|
|
|
|
|
my $fn = shift; |
62
|
|
|
|
|
|
|
local $@ = ""; |
63
|
|
|
|
|
|
|
open( my $fh, "<", $fn ) or croak "Error opening $fn: $!"; |
64
|
|
|
|
|
|
|
my $fc = <$fh>; |
65
|
|
|
|
|
|
|
close($fh) or croak "I/O error closing $fn: $!"; |
66
|
|
|
|
|
|
|
return $fc; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
EOP |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# PA-RISC1.1-thread-multi |
71
|
|
|
|
|
|
|
my %special_dlext = ( |
72
|
|
|
|
|
|
|
darwin => ".dylib", |
73
|
|
|
|
|
|
|
MSWin32 => ".dll", |
74
|
|
|
|
|
|
|
($Config{archname} =~ m/PA-RISC/i ? ("hpux" => ".sl") : ()), |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
our ($LIBEXT, $EXEEXT); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
defined $LIBEXT |
80
|
|
|
|
|
|
|
or $LIBEXT = |
81
|
|
|
|
|
|
|
defined $Config{so} ? "." . $Config{so} |
82
|
|
|
|
|
|
|
: defined $special_dlext{$^O} ? $special_dlext{$^O} |
83
|
|
|
|
|
|
|
: ".so"; |
84
|
|
|
|
|
|
|
defined $EXEEXT |
85
|
|
|
|
|
|
|
or $EXEEXT = ($^O eq "MSWin32") ? ".exe" : ""; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=encoding UTF-8 |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 NAME |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Config::AutoConf - A module to implement some of AutoConf macros in pure perl. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
our $VERSION = '0.319'; |
96
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 ABSTRACT |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
With this module I pretend to simulate some of the tasks AutoConf |
101
|
|
|
|
|
|
|
macros do. To detect a command, to detect a library, etc. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SYNOPSIS |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
use Config::AutoConf; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Config::AutoConf->check_prog("agrep"); |
108
|
|
|
|
|
|
|
my $grep = Config::AutoConf->check_progs("agrep", "egrep", "grep"); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Config::AutoConf->check_header("ncurses.h"); |
111
|
|
|
|
|
|
|
my $curses = Config::AutoConf->check_headers("ncurses.h","curses.h"); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Config::AutoConf->check_prog_awk; |
114
|
|
|
|
|
|
|
Config::AutoConf->check_prog_egrep; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Config::AutoConf->check_cc(); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Config::AutoConf->check_lib("ncurses", "tgoto"); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Config::AutoConf->check_file("/etc/passwd"); # -f && -r |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 DESCRIPTION |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Config::AutoConf is intended to provide the same opportunities to Perl |
125
|
|
|
|
|
|
|
developers as L |
126
|
|
|
|
|
|
|
does for Shell developers. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
As Perl is the second most deployed language (mind: every Unix comes |
129
|
|
|
|
|
|
|
with Perl, several mini-computers have Perl and even lot's of Windows |
130
|
|
|
|
|
|
|
machines run Perl software - which requires deployed Perl there, too), |
131
|
|
|
|
|
|
|
this gives wider support than Shell based probes. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The API is leaned against GNU Autoconf, but we try to make the API |
134
|
|
|
|
|
|
|
(especially optional arguments) more Perl'ish than m4 abilities allow |
135
|
|
|
|
|
|
|
to the original. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
my $glob_instance; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 new |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This function instantiates a new instance of Config::AutoConf, e.g. to |
146
|
|
|
|
|
|
|
configure child components. The constructor adds also values set via |
147
|
|
|
|
|
|
|
environment variable C. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub new |
152
|
|
|
|
|
|
|
{ |
153
|
9
|
|
|
9
|
1
|
3278
|
my $class = shift; |
154
|
9
|
50
|
|
|
|
39
|
ref $class and $class = ref $class; |
155
|
9
|
|
|
|
|
70
|
my %args = @_; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
my %flags = map { |
158
|
0
|
|
|
|
|
0
|
my ($k, $v) = split("=", $_, 2); |
159
|
0
|
0
|
|
|
|
0
|
defined $v or $v = 1; |
160
|
0
|
|
|
|
|
0
|
($k, $v) |
161
|
9
|
50
|
|
|
|
46
|
} split(":", $ENV{PERL5_AC_OPTS}) if ($ENV{PERL5_AC_OPTS}); |
162
|
|
|
|
|
|
|
|
163
|
9
|
|
|
|
|
402
|
my %instance = ( |
164
|
|
|
|
|
|
|
msg_prefix => 'configure: ', |
165
|
|
|
|
|
|
|
lang => "C", |
166
|
|
|
|
|
|
|
lang_stack => [], |
167
|
|
|
|
|
|
|
lang_supported => { |
168
|
|
|
|
|
|
|
"C" => $class->can("check_prog_cc"), |
169
|
|
|
|
|
|
|
}, |
170
|
|
|
|
|
|
|
cache => {}, |
171
|
|
|
|
|
|
|
defines => {}, |
172
|
|
|
|
|
|
|
extra_libs => [], |
173
|
|
|
|
|
|
|
extra_lib_dirs => [], |
174
|
|
|
|
|
|
|
extra_include_dirs => [], |
175
|
|
|
|
|
|
|
extra_preprocess_flags => [], |
176
|
|
|
|
|
|
|
extra_compile_flags => { |
177
|
|
|
|
|
|
|
"C" => [], |
178
|
|
|
|
|
|
|
}, |
179
|
|
|
|
|
|
|
extra_link_flags => [], |
180
|
|
|
|
|
|
|
logfile => "config.log", |
181
|
|
|
|
|
|
|
c_ac_flags => {%flags}, |
182
|
|
|
|
|
|
|
%args |
183
|
|
|
|
|
|
|
); |
184
|
9
|
|
|
|
|
101
|
bless(\%instance, $class); |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 METHODS |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head2 check_file |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
This function checks if a file exists in the system and is readable by |
192
|
|
|
|
|
|
|
the user. Returns a boolean. You can use '-f $file && -r $file' so you |
193
|
|
|
|
|
|
|
don't need to use a function call. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub check_file |
198
|
|
|
|
|
|
|
{ |
199
|
0
|
|
|
0
|
1
|
0
|
my $self = shift->_get_instance(); |
200
|
0
|
|
|
|
|
0
|
my $file = shift; |
201
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
0
|
my $cache_name = $self->_cache_name("file", $file); |
203
|
|
|
|
|
|
|
$self->check_cached( |
204
|
|
|
|
|
|
|
$cache_name, |
205
|
|
|
|
|
|
|
"for $file", |
206
|
|
|
|
|
|
|
sub { |
207
|
0
|
0
|
|
0
|
|
0
|
-f $file && -r $file; |
208
|
|
|
|
|
|
|
} |
209
|
0
|
|
|
|
|
0
|
); |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 check_files |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
This function checks if a set of files exist in the system and are |
215
|
|
|
|
|
|
|
readable by the user. Returns a boolean. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub check_files |
220
|
|
|
|
|
|
|
{ |
221
|
0
|
|
|
0
|
1
|
0
|
my $self = shift->_get_instance(); |
222
|
|
|
|
|
|
|
|
223
|
0
|
|
|
|
|
0
|
for (@_) |
224
|
|
|
|
|
|
|
{ |
225
|
0
|
0
|
|
|
|
0
|
return 0 unless $self->check_file($_); |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
0
|
|
|
|
|
0
|
1; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
184
|
50
|
|
184
|
|
651
|
sub _quote_shell_arg { scalar Text::ParseWords::shellwords($_[0]) > 1 ? QUOTE . $_[0] . QUOTE : $_[0] } |
232
|
|
|
|
|
|
|
|
233
|
165
|
|
|
165
|
|
273
|
sub _sanitize_prog { shift; _quote_shell_arg shift } |
|
165
|
|
|
|
|
304
|
|
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub _append_prog_args |
236
|
|
|
|
|
|
|
{ |
237
|
0
|
|
|
0
|
|
0
|
shift; |
238
|
0
|
|
|
|
|
0
|
join " ", map { _quote_shell_arg $_ } @_; |
|
0
|
|
|
|
|
0
|
|
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
my @exe_exts = ($^O eq "MSWin32" ? qw(.exe .com .bat .cmd) : ("")); |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 check_prog( $prog, \@dirlist?, \%options? ) |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
This function checks for a program with the supplied name. In success |
246
|
|
|
|
|
|
|
returns the full path for the executable; |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
An optional array reference containing a list of directories to be searched |
249
|
|
|
|
|
|
|
instead of $PATH is gracefully honored. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
252
|
|
|
|
|
|
|
to I or I are executed, respectively. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=cut |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub check_prog |
257
|
|
|
|
|
|
|
{ |
258
|
20
|
|
|
20
|
1
|
137
|
my $self = shift->_get_instance(); |
259
|
|
|
|
|
|
|
# sanitize ac_prog |
260
|
20
|
|
|
|
|
42
|
my $ac_prog = _sanitize(shift @_); |
261
|
|
|
|
|
|
|
|
262
|
20
|
|
|
|
|
38
|
my $options = {}; |
263
|
20
|
50
|
33
|
|
|
47
|
scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_; |
264
|
|
|
|
|
|
|
|
265
|
20
|
|
|
|
|
31
|
my @dirlist; |
266
|
20
|
50
|
66
|
|
|
67
|
@_ and scalar @_ > 1 and @dirlist = @_; |
267
|
20
|
50
|
66
|
|
|
91
|
@_ and scalar @_ == 1 and ref $_[0] eq "ARRAY" and @dirlist = @{$_[0]}; |
|
17
|
|
66
|
|
|
60
|
|
268
|
20
|
100
|
|
|
|
87
|
@dirlist or @dirlist = split(/$Config{path_sep}/, $ENV{PATH}); |
269
|
|
|
|
|
|
|
|
270
|
20
|
|
|
|
|
42
|
for my $p (@dirlist) |
271
|
|
|
|
|
|
|
{ |
272
|
165
|
|
|
|
|
262
|
for my $e (@exe_exts) |
273
|
|
|
|
|
|
|
{ |
274
|
165
|
|
|
|
|
1518
|
my $cmd = $self->_sanitize_prog(File::Spec->catfile($p, $ac_prog . $e)); |
275
|
165
|
100
|
|
|
|
11060
|
my $is_executable = -x $cmd and -f $cmd; |
276
|
|
|
|
|
|
|
$is_executable |
277
|
|
|
|
|
|
|
and $options->{action_on_true} |
278
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
279
|
165
|
50
|
66
|
|
|
476
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
280
|
165
|
100
|
|
|
|
460
|
$is_executable and return $cmd; |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
$options->{action_on_false} |
285
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
286
|
15
|
50
|
33
|
|
|
43
|
and $options->{action_on_false}->(); |
287
|
|
|
|
|
|
|
|
288
|
15
|
|
|
|
|
58
|
return; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head2 check_progs(progs, [dirlist]) |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
This function takes a list of program names. Returns the full path for |
294
|
|
|
|
|
|
|
the first found on the system. Returns undef if none was found. |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
An optional array reference containing a list of directories to be searched |
297
|
|
|
|
|
|
|
instead of $PATH is gracefully honored. |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
300
|
|
|
|
|
|
|
to I or I are executed, respectively. The |
301
|
|
|
|
|
|
|
name of the I<$prog> to check and the found full path are passed as first |
302
|
|
|
|
|
|
|
and second argument to the I callback. |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=cut |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
sub check_progs |
307
|
|
|
|
|
|
|
{ |
308
|
7
|
|
|
7
|
1
|
16
|
my $self = shift->_get_instance(); |
309
|
|
|
|
|
|
|
|
310
|
7
|
|
|
|
|
15
|
my $options = {}; |
311
|
7
|
50
|
66
|
|
|
35
|
scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_; |
312
|
|
|
|
|
|
|
|
313
|
7
|
|
|
|
|
12
|
my @dirlist; |
314
|
7
|
50
|
66
|
|
|
23
|
scalar @_ > 1 and ref $_[-1] eq "ARRAY" and @dirlist = @{pop @_}; |
|
0
|
|
|
|
|
0
|
|
315
|
7
|
50
|
|
|
|
116
|
@dirlist or @dirlist = split(/$Config{path_sep}/, $ENV{PATH}); |
316
|
|
|
|
|
|
|
|
317
|
7
|
|
|
|
|
31
|
my @progs = @_; |
318
|
7
|
|
|
|
|
15
|
foreach my $prog (@progs) |
319
|
|
|
|
|
|
|
{ |
320
|
17
|
50
|
|
|
|
36
|
defined $prog or next; |
321
|
|
|
|
|
|
|
|
322
|
17
|
|
|
|
|
45
|
my $ans = $self->check_prog($prog, \@dirlist); |
323
|
|
|
|
|
|
|
$ans |
324
|
|
|
|
|
|
|
and $options->{action_on_true} |
325
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
326
|
17
|
50
|
66
|
|
|
47
|
and $options->{action_if_true}->($prog, $ans); |
|
|
|
33
|
|
|
|
|
327
|
|
|
|
|
|
|
|
328
|
17
|
100
|
|
|
|
58
|
$ans and return $ans; |
329
|
|
|
|
|
|
|
} |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
$options->{action_on_false} |
332
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
333
|
3
|
50
|
33
|
|
|
12
|
and $options->{action_on_false}->(); |
334
|
|
|
|
|
|
|
|
335
|
3
|
|
|
|
|
15
|
return; |
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=head2 check_prog_yacc |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
From the L documentation, |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
If `bison' is found, set [...] `bison -y'. |
343
|
|
|
|
|
|
|
Otherwise, if `byacc' is found, set [...] `byacc'. |
344
|
|
|
|
|
|
|
Otherwise set [...] `yacc'. The result of this test can be influenced |
345
|
|
|
|
|
|
|
by setting the variable YACC or the cache variable ac_cv_prog_YACC. |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
Returns the full path, if found. |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
=cut |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
sub check_prog_yacc |
352
|
|
|
|
|
|
|
{ |
353
|
3
|
|
|
3
|
1
|
1889
|
my $self = shift->_get_instance(); |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
# my ($self, $cache_name, $message, $check_sub) = @_; |
356
|
|
|
|
|
|
|
|
357
|
3
|
|
|
|
|
7
|
my $cache_name = $self->_cache_name("prog", "YACC"); |
358
|
|
|
|
|
|
|
$self->check_cached( |
359
|
|
|
|
|
|
|
$cache_name, |
360
|
|
|
|
|
|
|
"for yacc", |
361
|
|
|
|
|
|
|
sub { |
362
|
2
|
100
|
|
2
|
|
9
|
defined $ENV{YACC} and return $ENV{YACC}; |
363
|
1
|
|
|
|
|
4
|
my $binary = $self->check_progs(qw/bison byacc yacc/); |
364
|
1
|
50
|
33
|
|
|
5
|
defined $binary |
365
|
|
|
|
|
|
|
and $binary =~ /bison(?:\.(?:exe|com|bat|cmd))?$/ |
366
|
|
|
|
|
|
|
and $binary = $self->_append_prog_args($binary, "-y"); |
367
|
1
|
|
|
|
|
4
|
return $binary; |
368
|
|
|
|
|
|
|
} |
369
|
3
|
|
|
|
|
58
|
); |
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
=head2 check_prog_awk |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
From the L documentation, |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
Check for `gawk', `mawk', `nawk', and `awk', in that order, and |
377
|
|
|
|
|
|
|
set output [...] to the first one that is found. It tries |
378
|
|
|
|
|
|
|
`gawk' first because that is reported to be the best implementation. |
379
|
|
|
|
|
|
|
The result can be overridden by setting the variable AWK or the |
380
|
|
|
|
|
|
|
cache variable ac_cv_prog_AWK. |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
Note that it returns the full path, if found. |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
=cut |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
sub check_prog_awk |
387
|
|
|
|
|
|
|
{ |
388
|
3
|
|
|
3
|
1
|
1138
|
my $self = shift->_get_instance(); |
389
|
3
|
|
|
|
|
9
|
my $cache_name = $self->_cache_name("prog", "AWK"); |
390
|
3
|
100
|
|
2
|
|
17
|
$self->check_cached($cache_name, "for awk", sub { $ENV{AWK} || $self->check_progs(qw/gawk mawk nawk awk/) }); |
|
2
|
|
|
|
|
14
|
|
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
=head2 check_prog_egrep |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
From the L documentation, |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
Check for `grep -E' and `egrep', in that order, and [...] output |
398
|
|
|
|
|
|
|
[...] the first one that is found. The result can be overridden by |
399
|
|
|
|
|
|
|
setting the EGREP variable and is cached in the ac_cv_path_EGREP |
400
|
|
|
|
|
|
|
variable. |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
Note that it returns the full path, if found. |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
=cut |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
sub check_prog_egrep |
407
|
|
|
|
|
|
|
{ |
408
|
3
|
|
|
3
|
1
|
1802
|
my $self = shift->_get_instance(); |
409
|
|
|
|
|
|
|
|
410
|
3
|
|
|
|
|
10
|
my $cache_name = $self->_cache_name("prog", "EGREP"); |
411
|
|
|
|
|
|
|
$self->check_cached( |
412
|
|
|
|
|
|
|
$cache_name, |
413
|
|
|
|
|
|
|
"for egrep", |
414
|
|
|
|
|
|
|
sub { |
415
|
2
|
100
|
|
2
|
|
8
|
defined $ENV{EGREP} and return $ENV{EGREP}; |
416
|
1
|
|
|
|
|
3
|
my $grep; |
417
|
1
|
50
|
|
|
|
4
|
$grep = $self->check_progs("egrep") and return $grep; |
418
|
|
|
|
|
|
|
|
419
|
0
|
0
|
|
|
|
0
|
if ($grep = $self->check_prog("grep")) |
420
|
|
|
|
|
|
|
{ |
421
|
|
|
|
|
|
|
# check_run - Capture::Tiny, Open3 ... ftw! |
422
|
0
|
|
|
|
|
0
|
my $ans = `echo a | ($grep -E '(a|b)') 2>/dev/null`; |
423
|
0
|
|
|
|
|
0
|
chomp $ans; |
424
|
0
|
0
|
|
|
|
0
|
$ans eq "a" and return $self->_append_prog_args($grep, "-E"); |
425
|
|
|
|
|
|
|
} |
426
|
|
|
|
|
|
|
} |
427
|
3
|
|
|
|
|
59
|
); |
428
|
|
|
|
|
|
|
} |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
=head2 check_prog_lex |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
From the L documentation, |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
If flex is found, set output [...] to ‘flex’ and [...] to -lfl, if that |
435
|
|
|
|
|
|
|
library is in a standard place. Otherwise set output [...] to ‘lex’ and |
436
|
|
|
|
|
|
|
[...] to -ll, if found. If [...] packages [...] ship the generated |
437
|
|
|
|
|
|
|
file.yy.c alongside the source file.l, this [...] allows users without a |
438
|
|
|
|
|
|
|
lexer generator to still build the package even if the timestamp for |
439
|
|
|
|
|
|
|
file.l is inadvertently changed. |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
Note that it returns the full path, if found. |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
The structure $self->{lex} is set with attributes |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
prog => $LEX |
446
|
|
|
|
|
|
|
lib => $LEXLIB |
447
|
|
|
|
|
|
|
root => $lex_root |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
=cut |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
sub check_prog_lex |
452
|
|
|
|
|
|
|
{ |
453
|
1
|
|
|
1
|
1
|
523
|
my $self = shift->_get_instance; |
454
|
1
|
|
|
|
|
4
|
my $cache_name = $self->_cache_name("prog", "LEX"); |
455
|
1
|
50
|
|
1
|
|
6
|
my $lex = $self->check_cached($cache_name, "for lex", sub { $ENV{LEX} || $self->check_progs(qw/flex lex/) }); |
|
1
|
|
|
|
|
7
|
|
456
|
1
|
50
|
|
|
|
7
|
if ($lex) |
457
|
|
|
|
|
|
|
{ |
458
|
0
|
0
|
|
|
|
0
|
defined $self->{lex}->{prog} or $self->{lex}->{prog} = $lex; |
459
|
|
|
|
|
|
|
my $lex_root_var = $self->check_cached( |
460
|
|
|
|
|
|
|
"ac_cv_prog_lex_root", |
461
|
|
|
|
|
|
|
"for lex output file root", |
462
|
|
|
|
|
|
|
sub { |
463
|
0
|
|
|
0
|
|
0
|
my ($fh, $filename) = tempfile( |
464
|
|
|
|
|
|
|
"testXXXXXX", |
465
|
|
|
|
|
|
|
SUFFIX => '.l', |
466
|
|
|
|
|
|
|
UNLINK => 0 |
467
|
|
|
|
|
|
|
); |
468
|
0
|
|
|
|
|
0
|
my $src = <<'EOLEX'; |
469
|
|
|
|
|
|
|
%% |
470
|
|
|
|
|
|
|
a { ECHO; } |
471
|
|
|
|
|
|
|
b { REJECT; } |
472
|
|
|
|
|
|
|
c { yymore (); } |
473
|
|
|
|
|
|
|
d { yyless (1); } |
474
|
|
|
|
|
|
|
e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument. */ |
475
|
|
|
|
|
|
|
yyless ((input () != 0)); } |
476
|
|
|
|
|
|
|
f { unput (yytext[0]); } |
477
|
|
|
|
|
|
|
. { BEGIN INITIAL; } |
478
|
|
|
|
|
|
|
%% |
479
|
|
|
|
|
|
|
#ifdef YYTEXT_POINTER |
480
|
|
|
|
|
|
|
extern char *yytext; |
481
|
|
|
|
|
|
|
#endif |
482
|
|
|
|
|
|
|
int |
483
|
|
|
|
|
|
|
main (void) |
484
|
|
|
|
|
|
|
{ |
485
|
|
|
|
|
|
|
return ! yylex () + ! yywrap (); |
486
|
|
|
|
|
|
|
} |
487
|
|
|
|
|
|
|
EOLEX |
488
|
|
|
|
|
|
|
|
489
|
0
|
|
|
|
|
0
|
print {$fh} $src; |
|
0
|
|
|
|
|
0
|
|
490
|
0
|
|
|
|
|
0
|
close $fh; |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
my ($stdout, $stderr, $exit) = |
493
|
0
|
|
|
|
|
0
|
capture { system($lex, $filename); }; |
|
0
|
|
|
|
|
0
|
|
494
|
0
|
|
|
|
|
0
|
chomp $stdout; |
495
|
0
|
|
|
|
|
0
|
unlink $filename; |
496
|
0
|
0
|
|
|
|
0
|
-f "lex.yy.c" and return "lex.yy"; |
497
|
0
|
0
|
|
|
|
0
|
-f "lexyy.c" and return "lexyy"; |
498
|
0
|
|
|
|
|
0
|
$self->msg_error("cannot find output from $lex; giving up"); |
499
|
|
|
|
|
|
|
} |
500
|
0
|
|
|
|
|
0
|
); |
501
|
0
|
0
|
|
|
|
0
|
defined $self->{lex}->{root} or $self->{lex}->{root} = $lex_root_var; |
502
|
|
|
|
|
|
|
|
503
|
0
|
|
|
|
|
0
|
my $conftest = read_binary($lex_root_var . ".c"); |
504
|
0
|
|
|
|
|
0
|
unlink $lex_root_var . ".c"; |
505
|
|
|
|
|
|
|
|
506
|
0
|
|
|
|
|
0
|
$cache_name = $self->_cache_name("lib", "lex"); |
507
|
|
|
|
|
|
|
my $check_sub = sub { |
508
|
0
|
|
|
0
|
|
0
|
my @save_libs = @{$self->{extra_libs}}; |
|
0
|
|
|
|
|
0
|
|
509
|
0
|
|
|
|
|
0
|
my $have_lib = 0; |
510
|
0
|
|
|
|
|
0
|
foreach my $libstest (undef, qw(-lfl -ll)) |
511
|
|
|
|
|
|
|
{ |
512
|
|
|
|
|
|
|
# XXX would local work on array refs? can we omit @save_libs? |
513
|
0
|
|
|
|
|
0
|
$self->{extra_libs} = [@save_libs]; |
514
|
0
|
0
|
|
|
|
0
|
defined($libstest) and unshift(@{$self->{extra_libs}}, $libstest); |
|
0
|
|
|
|
|
0
|
|
515
|
0
|
0
|
0
|
|
|
0
|
$self->link_if_else($conftest) |
|
|
0
|
|
|
|
|
|
516
|
|
|
|
|
|
|
and ($have_lib = defined($libstest) ? $libstest : "none required") |
517
|
|
|
|
|
|
|
and last; |
518
|
|
|
|
|
|
|
} |
519
|
0
|
|
|
|
|
0
|
$self->{extra_libs} = [@save_libs]; |
520
|
|
|
|
|
|
|
|
521
|
0
|
0
|
|
|
|
0
|
if ($have_lib) |
522
|
|
|
|
|
|
|
{ |
523
|
0
|
|
|
|
|
0
|
$self->define_var(_have_lib_define_name("lex"), $have_lib, "defined when lex library is available"); |
524
|
|
|
|
|
|
|
} |
525
|
|
|
|
|
|
|
else |
526
|
|
|
|
|
|
|
{ |
527
|
0
|
|
|
|
|
0
|
$self->define_var(_have_lib_define_name("lex"), undef, "defined when lex library is available"); |
528
|
|
|
|
|
|
|
} |
529
|
0
|
|
|
|
|
0
|
return $have_lib; |
530
|
0
|
|
|
|
|
0
|
}; |
531
|
|
|
|
|
|
|
|
532
|
0
|
|
|
|
|
0
|
my $lex_lib = $self->check_cached($cache_name, "lex library", $check_sub); |
533
|
0
|
0
|
|
|
|
0
|
defined $self->{lex}->{lib} or $self->{lex}->{lib} = $lex_lib; |
534
|
|
|
|
|
|
|
} |
535
|
|
|
|
|
|
|
|
536
|
1
|
|
|
|
|
4
|
$lex; |
537
|
|
|
|
|
|
|
} |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=head2 check_prog_sed |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
From the L documentation, |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
Set output variable [...] to a Sed implementation that conforms to Posix |
544
|
|
|
|
|
|
|
and does not have arbitrary length limits. Report an error if no |
545
|
|
|
|
|
|
|
acceptable Sed is found. See Limitations of Usual Tools, for more |
546
|
|
|
|
|
|
|
information about portability problems with Sed. |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
The result of this test can be overridden by setting the SED variable and |
549
|
|
|
|
|
|
|
is cached in the ac_cv_path_SED variable. |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
Note that it returns the full path, if found. |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
=cut |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
sub check_prog_sed |
556
|
|
|
|
|
|
|
{ |
557
|
3
|
|
|
3
|
1
|
1951
|
my $self = shift->_get_instance(); |
558
|
3
|
|
|
|
|
24
|
my $cache_name = $self->_cache_name("prog", "SED"); |
559
|
3
|
100
|
|
2
|
|
18
|
$self->check_cached($cache_name, "for sed", sub { $ENV{SED} || $self->check_progs(qw/gsed sed/) }); |
|
2
|
|
|
|
|
10
|
|
560
|
|
|
|
|
|
|
} |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
=head2 check_prog_pkg_config |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
Checks for C program. No additional tests are made for it ... |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
=cut |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
sub check_prog_pkg_config |
569
|
|
|
|
|
|
|
{ |
570
|
1
|
|
|
1
|
1
|
405
|
my $self = shift->_get_instance(); |
571
|
1
|
|
|
|
|
3
|
my $cache_name = $self->_cache_name("prog", "PKG_CONFIG"); |
572
|
1
|
|
|
1
|
|
10
|
$self->check_cached($cache_name, "for pkg-config", sub { $self->check_prog("pkg-config") }); |
|
1
|
|
|
|
|
5
|
|
573
|
|
|
|
|
|
|
} |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
=head2 check_prog_cc |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
Determine a C compiler to use. Currently the probe is delegated to L. |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=cut |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
sub check_prog_cc |
582
|
|
|
|
|
|
|
{ |
583
|
6
|
|
|
6
|
1
|
18
|
my $self = shift->_get_instance(); |
584
|
6
|
|
|
|
|
18
|
my $cache_name = $self->_cache_name("prog", "CC"); |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
$self->check_cached( |
587
|
|
|
|
|
|
|
$cache_name, |
588
|
|
|
|
|
|
|
"for cc", |
589
|
|
|
|
|
|
|
sub { |
590
|
6
|
|
|
6
|
|
20
|
$self->{lang_supported}->{C} = undef; |
591
|
6
|
|
|
2
|
|
967
|
eval "use ExtUtils::CBuilder;"; |
|
2
|
|
|
2
|
|
1002
|
|
|
2
|
|
|
|
|
115517
|
|
|
2
|
|
|
|
|
50
|
|
|
2
|
|
|
|
|
32
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
64
|
|
592
|
6
|
50
|
|
|
|
32
|
$@ and return; |
593
|
6
|
|
|
|
|
67
|
my $cb = ExtUtils::CBuilder->new(quiet => 1); |
594
|
6
|
50
|
|
|
|
123621
|
$cb->have_compiler or return; |
595
|
6
|
|
|
|
|
385324
|
$self->{lang_supported}->{C} = "ExtUtils::CBuilder"; |
596
|
6
|
|
|
|
|
250
|
$cb->{config}->{cc}; |
597
|
|
|
|
|
|
|
} |
598
|
6
|
|
|
|
|
80
|
); |
599
|
|
|
|
|
|
|
} |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
=head2 check_cc |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
(Deprecated) Old name of L. |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
=cut |
606
|
|
|
|
|
|
|
|
607
|
0
|
|
|
0
|
1
|
0
|
sub check_cc { shift->check_prog_cc(@_) } |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=head2 check_valid_compiler |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
This function checks for a valid compiler for the currently active language. |
612
|
|
|
|
|
|
|
At the very moment only C is understood (corresponding to your compiler |
613
|
|
|
|
|
|
|
default options, e.g. -std=gnu89). |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
=cut |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
sub check_valid_compiler |
618
|
|
|
|
|
|
|
{ |
619
|
0
|
|
|
0
|
1
|
0
|
my $self = shift->_get_instance; |
620
|
0
|
|
|
|
|
0
|
my $lang = $self->{lang}; |
621
|
0
|
0
|
|
|
|
0
|
$lang eq "C" or $self->msg_error("Language $lang is not supported"); |
622
|
0
|
|
|
|
|
0
|
$self->check_prog_cc; |
623
|
|
|
|
|
|
|
} |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
=head2 check_valid_compilers(;\@) |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
Checks for valid compilers for each given language. When unspecified |
628
|
|
|
|
|
|
|
defaults to C<[ "C" ]>. |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
=cut |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
sub check_valid_compilers |
633
|
|
|
|
|
|
|
{ |
634
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
635
|
0
|
|
|
|
|
0
|
for my $lang (@{$_[0]}) |
|
0
|
|
|
|
|
0
|
|
636
|
|
|
|
|
|
|
{ |
637
|
0
|
|
|
|
|
0
|
$self->push_lang($lang); |
638
|
0
|
|
|
|
|
0
|
my $supp = $self->check_valid_compiler; |
639
|
0
|
|
|
|
|
0
|
$self->pop_lang($lang); |
640
|
0
|
0
|
|
|
|
0
|
$supp or return 0; |
641
|
|
|
|
|
|
|
} |
642
|
|
|
|
|
|
|
|
643
|
0
|
|
|
|
|
0
|
1; |
644
|
|
|
|
|
|
|
} |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
=head2 msg_checking |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
Prints "Checking @_ ..." |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
=cut |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
sub msg_checking |
653
|
|
|
|
|
|
|
{ |
654
|
123
|
|
|
123
|
1
|
417
|
my $self = shift->_get_instance(); |
655
|
|
|
|
|
|
|
$self->{quiet} |
656
|
123
|
50
|
|
|
|
5215
|
or print "Checking " . join(" ", @_) . "... "; |
657
|
123
|
|
|
|
|
1707
|
$self->_add_log_entry("Checking " . join(" ", @_, "...")); |
658
|
123
|
|
|
|
|
306
|
return; |
659
|
|
|
|
|
|
|
} |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
=head2 msg_result |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
Prints result \n |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
=cut |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
my @_num_to_msg = qw/no yes/; |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
sub _neat |
670
|
|
|
|
|
|
|
{ |
671
|
268
|
100
|
|
268
|
|
1067
|
defined $_[0] or return ""; |
672
|
262
|
100
|
100
|
|
|
10180
|
looks_like_number($_[0]) and defined $_num_to_msg[$_[0]] and return $_num_to_msg[$_[0]]; |
673
|
100
|
|
|
|
|
2730
|
$_[0]; |
674
|
|
|
|
|
|
|
} |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
sub msg_result |
677
|
|
|
|
|
|
|
{ |
678
|
123
|
|
|
123
|
1
|
1873
|
my $self = shift->_get_instance(); |
679
|
|
|
|
|
|
|
$self->{quiet} |
680
|
123
|
50
|
|
|
|
992
|
or print join(" ", map { _neat $_ } @_), "\n"; |
|
134
|
|
|
|
|
606
|
|
681
|
123
|
|
|
|
|
1154
|
$self->_add_log_entry(join(" ", map { _neat $_ } @_), "\n"); |
|
134
|
|
|
|
|
548
|
|
682
|
123
|
|
|
|
|
314
|
return; |
683
|
|
|
|
|
|
|
} |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
=head2 msg_notice |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
Prints "configure: " @_ to stdout |
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
=cut |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
sub msg_notice |
692
|
|
|
|
|
|
|
{ |
693
|
0
|
|
|
0
|
1
|
0
|
my $self = shift->_get_instance(); |
694
|
|
|
|
|
|
|
$self->{quiet} |
695
|
0
|
0
|
|
|
|
0
|
or print $self->{msg_prefix} . join(" ", @_) . "\n"; |
696
|
0
|
|
|
|
|
0
|
$self->_add_log_entry($self->{msg_prefix} . join(" ", @_) . "\n"); |
697
|
0
|
|
|
|
|
0
|
return; |
698
|
|
|
|
|
|
|
} |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
=head2 msg_warn |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
Prints "configure: " @_ to stderr |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
=cut |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
sub msg_warn |
707
|
|
|
|
|
|
|
{ |
708
|
0
|
|
|
0
|
1
|
0
|
my $self = shift->_get_instance(); |
709
|
0
|
|
|
|
|
0
|
print STDERR $self->{msg_prefix} . join(" ", @_) . "\n"; |
710
|
0
|
|
|
|
|
0
|
$self->_add_log_entry("WARNING: " . $self->{msg_prefix} . join(" ", @_) . "\n"); |
711
|
0
|
|
|
|
|
0
|
return; |
712
|
|
|
|
|
|
|
} |
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
=head2 msg_error |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
Prints "configure: " @_ to stderr and exits with exit code 0 (tells |
717
|
|
|
|
|
|
|
toolchain to stop here and report unsupported environment) |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
=cut |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
sub msg_error |
722
|
|
|
|
|
|
|
{ |
723
|
0
|
|
|
0
|
1
|
0
|
my $self = shift->_get_instance(); |
724
|
0
|
|
|
|
|
0
|
print STDERR $self->{msg_prefix} . join(" ", @_) . "\n"; |
725
|
0
|
|
|
|
|
0
|
$self->_add_log_entry("ERROR: " . $self->{msg_prefix} . join(" ", @_) . "\n"); |
726
|
0
|
|
|
|
|
0
|
exit(0); # #toolchain agreement: prevents configure stage to finish |
727
|
|
|
|
|
|
|
} |
728
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
=head2 msg_failure |
730
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
Prints "configure: " @_ to stderr and exits with exit code 0 (tells |
732
|
|
|
|
|
|
|
toolchain to stop here and report unsupported environment). Additional |
733
|
|
|
|
|
|
|
details are provides in config.log (probably more information in a |
734
|
|
|
|
|
|
|
later stage). |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
=cut |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
sub msg_failure |
739
|
|
|
|
|
|
|
{ |
740
|
0
|
|
|
0
|
1
|
0
|
my $self = shift->_get_instance(); |
741
|
0
|
|
|
|
|
0
|
print STDERR $self->{msg_prefix} . join(" ", @_) . "\n"; |
742
|
0
|
|
|
|
|
0
|
$self->_add_log_entry("FAILURE: " . $self->{msg_prefix} . join(" ", @_) . "\n"); |
743
|
0
|
|
|
|
|
0
|
exit(0); # #toolchain agreement: prevents configure stage to finish |
744
|
|
|
|
|
|
|
} |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
=head2 define_var( $name, $value [, $comment ] ) |
747
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
Defines a check variable for later use in further checks or code to compile. |
749
|
|
|
|
|
|
|
Returns the value assigned value |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
=cut |
752
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
sub define_var |
754
|
|
|
|
|
|
|
{ |
755
|
90
|
|
|
90
|
1
|
426
|
my $self = shift->_get_instance(); |
756
|
90
|
|
|
|
|
380
|
my ($name, $value, $comment) = @_; |
757
|
|
|
|
|
|
|
|
758
|
90
|
50
|
|
|
|
403
|
defined($name) or croak("Need a name to add a define"); |
759
|
90
|
|
|
|
|
897
|
$self->{defines}->{$name} = [$value, $comment]; |
760
|
90
|
|
|
|
|
368
|
$value; |
761
|
|
|
|
|
|
|
} |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
=head2 write_config_h( [$target] ) |
764
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
Writes the defined constants into given target: |
766
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
Config::AutoConf->write_config_h( "config.h" ); |
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
=cut |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
sub write_config_h |
772
|
|
|
|
|
|
|
{ |
773
|
3
|
|
|
3
|
1
|
1363
|
my $self = shift->_get_instance(); |
774
|
3
|
|
|
|
|
11
|
my $tgt; |
775
|
|
|
|
|
|
|
|
776
|
3
|
50
|
|
|
|
186
|
defined($_[0]) |
|
|
100
|
|
|
|
|
|
777
|
|
|
|
|
|
|
? ( |
778
|
|
|
|
|
|
|
ref($_[0]) |
779
|
|
|
|
|
|
|
? $tgt = $_[0] |
780
|
|
|
|
|
|
|
: open($tgt, ">", $_[0]) |
781
|
|
|
|
|
|
|
) |
782
|
|
|
|
|
|
|
: open($tgt, ">", "config.h"); |
783
|
|
|
|
|
|
|
|
784
|
3
|
|
|
|
|
18
|
my $conf_h = <<'EOC'; |
785
|
|
|
|
|
|
|
/** |
786
|
|
|
|
|
|
|
* Generated from Config::AutoConf |
787
|
|
|
|
|
|
|
* |
788
|
|
|
|
|
|
|
* Do not edit this file, all modifications will be lost, |
789
|
|
|
|
|
|
|
* modify Makefile.PL or Build.PL instead. |
790
|
|
|
|
|
|
|
* |
791
|
|
|
|
|
|
|
* Inspired by GNU AutoConf. |
792
|
|
|
|
|
|
|
* |
793
|
|
|
|
|
|
|
* (c) 2011 Alberto Simoes & Jens Rehsack |
794
|
|
|
|
|
|
|
*/ |
795
|
|
|
|
|
|
|
#ifndef __CONFIG_H__ |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
EOC |
798
|
|
|
|
|
|
|
|
799
|
3
|
|
|
|
|
12
|
while (my ($defname, $defcnt) = each(%{$self->{defines}})) |
|
151
|
|
|
|
|
392
|
|
800
|
|
|
|
|
|
|
{ |
801
|
148
|
100
|
|
|
|
294
|
if ($defcnt->[0]) |
802
|
|
|
|
|
|
|
{ |
803
|
129
|
50
|
|
|
|
299
|
defined $defcnt->[1] and $conf_h .= "/* " . $defcnt->[1] . " */\n"; |
804
|
129
|
|
|
|
|
280
|
$conf_h .= join(" ", "#define", $defname, $defcnt->[0]) . "\n"; |
805
|
|
|
|
|
|
|
} |
806
|
|
|
|
|
|
|
else |
807
|
|
|
|
|
|
|
{ |
808
|
19
|
50
|
|
|
|
61
|
defined $defcnt->[1] and $conf_h .= "/* " . $defcnt->[1] . " */\n"; |
809
|
19
|
|
|
|
|
50
|
$conf_h .= "/* " . join(" ", "#undef", $defname) . " */\n\n"; |
810
|
|
|
|
|
|
|
} |
811
|
|
|
|
|
|
|
} |
812
|
3
|
|
|
|
|
11
|
$conf_h .= "#endif /* ?__CONFIG_H__ */\n"; |
813
|
|
|
|
|
|
|
|
814
|
3
|
|
|
|
|
7
|
print {$tgt} $conf_h; |
|
3
|
|
|
|
|
19
|
|
815
|
|
|
|
|
|
|
|
816
|
3
|
|
|
|
|
183
|
return; |
817
|
|
|
|
|
|
|
} |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
=head2 push_lang(lang [, implementor ]) |
820
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
Puts the current used language on the stack and uses specified language |
822
|
|
|
|
|
|
|
for subsequent operations until ending pop_lang call. |
823
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
=cut |
825
|
|
|
|
|
|
|
|
826
|
|
|
|
|
|
|
sub push_lang |
827
|
|
|
|
|
|
|
{ |
828
|
0
|
|
|
0
|
1
|
0
|
my $self = shift->_get_instance(); |
829
|
|
|
|
|
|
|
|
830
|
0
|
|
|
|
|
0
|
push @{$self->{lang_stack}}, [$self->{lang}]; |
|
0
|
|
|
|
|
0
|
|
831
|
|
|
|
|
|
|
|
832
|
0
|
|
|
|
|
0
|
$self->_set_language(@_); |
833
|
|
|
|
|
|
|
} |
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
=head2 pop_lang([ lang ]) |
836
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
Pops the currently used language from the stack and restores previously used |
838
|
|
|
|
|
|
|
language. If I specified, it's asserted that the current used language |
839
|
|
|
|
|
|
|
equals to specified language (helps finding control flow bugs). |
840
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
=cut |
842
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
sub pop_lang |
844
|
|
|
|
|
|
|
{ |
845
|
0
|
|
|
0
|
1
|
0
|
my $self = shift->_get_instance(); |
846
|
|
|
|
|
|
|
|
847
|
0
|
0
|
|
|
|
0
|
scalar(@{$self->{lang_stack}}) > 0 or croak("Language stack empty"); |
|
0
|
|
|
|
|
0
|
|
848
|
|
|
|
|
|
|
defined($_[0]) |
849
|
|
|
|
|
|
|
and $self->{lang} ne $_[0] |
850
|
0
|
0
|
0
|
|
|
0
|
and croak("pop_lang( $_[0] ) doesn't match language in use (" . $self->{lang} . ")"); |
851
|
|
|
|
|
|
|
|
852
|
0
|
|
|
|
|
0
|
$self->_set_language(@{pop @{$self->{lang_stack}}}); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
853
|
|
|
|
|
|
|
} |
854
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
=head2 lang_build_program( prologue, body ) |
856
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
Builds program for current chosen language. If no prologue is given |
858
|
|
|
|
|
|
|
(I), the default headers are used. If body is missing, default |
859
|
|
|
|
|
|
|
body is used. |
860
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
Typical call of |
862
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
Config::AutoConf->lang_build_program( "const char hw[] = \"Hello, World\\n\";", |
864
|
|
|
|
|
|
|
"fputs (hw, stdout);" ) |
865
|
|
|
|
|
|
|
|
866
|
|
|
|
|
|
|
will create |
867
|
|
|
|
|
|
|
|
868
|
|
|
|
|
|
|
const char hw[] = "Hello, World\n"; |
869
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
/* Override any gcc2 internal prototype to avoid an error. */ |
871
|
|
|
|
|
|
|
#ifdef __cplusplus |
872
|
|
|
|
|
|
|
extern "C" { |
873
|
|
|
|
|
|
|
#endif |
874
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
int |
876
|
|
|
|
|
|
|
main (int argc, char **argv) |
877
|
|
|
|
|
|
|
{ |
878
|
|
|
|
|
|
|
(void)argc; |
879
|
|
|
|
|
|
|
(void)argv; |
880
|
|
|
|
|
|
|
fputs (hw, stdout);; |
881
|
|
|
|
|
|
|
return 0; |
882
|
|
|
|
|
|
|
} |
883
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
#ifdef __cplusplus |
885
|
|
|
|
|
|
|
} |
886
|
|
|
|
|
|
|
#endif |
887
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
=cut |
889
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
sub lang_build_program |
891
|
|
|
|
|
|
|
{ |
892
|
177
|
|
|
177
|
1
|
2280
|
my ($self, $prologue, $body) = @_; |
893
|
177
|
50
|
|
|
|
940
|
ref $self or $self = $self->_get_instance(); |
894
|
|
|
|
|
|
|
|
895
|
177
|
50
|
|
|
|
768
|
defined($prologue) or $prologue = $self->_default_includes(); |
896
|
177
|
50
|
|
|
|
621
|
defined($body) or $body = ""; |
897
|
177
|
|
|
|
|
1843
|
$body = $self->_build_main($body); |
898
|
|
|
|
|
|
|
|
899
|
177
|
|
|
|
|
1773
|
$self->_fill_defines() . "\n$prologue\n\n$body\n"; |
900
|
|
|
|
|
|
|
} |
901
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
sub _lang_prologue_func |
903
|
|
|
|
|
|
|
{ |
904
|
14
|
|
|
14
|
|
50
|
my ($self, $prologue, $function) = @_; |
905
|
14
|
50
|
|
|
|
47
|
ref $self or $self = $self->_get_instance(); |
906
|
|
|
|
|
|
|
|
907
|
14
|
50
|
|
|
|
58
|
defined($prologue) or $prologue = $self->_default_includes(); |
908
|
14
|
|
|
|
|
157
|
$prologue .= <<"_ACEOF"; |
909
|
|
|
|
|
|
|
/* Override any GCC internal prototype to avoid an error. |
910
|
|
|
|
|
|
|
Use char because int might match the return type of a GCC |
911
|
|
|
|
|
|
|
builtin and then its argument prototype would still apply. */ |
912
|
|
|
|
|
|
|
#ifdef __cplusplus |
913
|
|
|
|
|
|
|
extern "C" { |
914
|
|
|
|
|
|
|
#endif |
915
|
|
|
|
|
|
|
char $function (); |
916
|
|
|
|
|
|
|
#ifdef __cplusplus |
917
|
|
|
|
|
|
|
} |
918
|
|
|
|
|
|
|
#endif |
919
|
|
|
|
|
|
|
_ACEOF |
920
|
|
|
|
|
|
|
|
921
|
14
|
|
|
|
|
90
|
return $prologue; |
922
|
|
|
|
|
|
|
} |
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
sub _lang_body_func |
925
|
|
|
|
|
|
|
{ |
926
|
13
|
|
|
13
|
|
39
|
my ($self, $function) = @_; |
927
|
13
|
50
|
|
|
|
52
|
ref $self or $self = $self->_get_instance(); |
928
|
|
|
|
|
|
|
|
929
|
13
|
|
|
|
|
51
|
my $func_call = "return $function ();"; |
930
|
13
|
|
|
|
|
68
|
return $func_call; |
931
|
|
|
|
|
|
|
} |
932
|
|
|
|
|
|
|
|
933
|
|
|
|
|
|
|
=head2 lang_call( [prologue], function ) |
934
|
|
|
|
|
|
|
|
935
|
|
|
|
|
|
|
Builds program which simply calls given function. |
936
|
|
|
|
|
|
|
When given, prologue is prepended otherwise, the default |
937
|
|
|
|
|
|
|
includes are used. |
938
|
|
|
|
|
|
|
|
939
|
|
|
|
|
|
|
=cut |
940
|
|
|
|
|
|
|
|
941
|
|
|
|
|
|
|
sub lang_call |
942
|
|
|
|
|
|
|
{ |
943
|
13
|
|
|
13
|
1
|
129
|
my ($self, $prologue, $function) = @_; |
944
|
13
|
50
|
|
|
|
66
|
ref $self or $self = $self->_get_instance(); |
945
|
|
|
|
|
|
|
|
946
|
13
|
|
|
|
|
80
|
return $self->lang_build_program($self->_lang_prologue_func($prologue, $function), $self->_lang_body_func($function),); |
947
|
|
|
|
|
|
|
} |
948
|
|
|
|
|
|
|
|
949
|
|
|
|
|
|
|
sub _lang_prologue_builtin |
950
|
|
|
|
|
|
|
{ |
951
|
0
|
|
|
0
|
|
0
|
my ($self, $prologue, $builtin) = @_; |
952
|
0
|
0
|
|
|
|
0
|
ref $self or $self = $self->_get_instance(); |
953
|
|
|
|
|
|
|
|
954
|
0
|
0
|
|
|
|
0
|
defined($prologue) or $prologue = $self->_default_includes(); |
955
|
0
|
|
|
|
|
0
|
$prologue .= <<"_ACEOF"; |
956
|
|
|
|
|
|
|
#if !defined(__has_builtin) |
957
|
|
|
|
|
|
|
#undef $builtin |
958
|
|
|
|
|
|
|
/* Declare this builtin with the same prototype as __builtin_$builtin. |
959
|
|
|
|
|
|
|
This removes a warning about conflicting types for built-in builtin $builtin */ |
960
|
|
|
|
|
|
|
__typeof__(__builtin_$builtin) $builtin; |
961
|
|
|
|
|
|
|
__typeof__(__builtin_$builtin) *f = $builtin; |
962
|
|
|
|
|
|
|
#endif |
963
|
|
|
|
|
|
|
_ACEOF |
964
|
|
|
|
|
|
|
} |
965
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
sub _lang_body_builtin |
967
|
|
|
|
|
|
|
{ |
968
|
1
|
|
|
1
|
|
5
|
my ($self, $builtin) = @_; |
969
|
1
|
50
|
|
|
|
10
|
ref $self or $self = $self->_get_instance(); |
970
|
|
|
|
|
|
|
|
971
|
1
|
|
|
|
|
6
|
my $body = <<"_ACEOF"; |
972
|
|
|
|
|
|
|
#if !defined(__has_builtin) |
973
|
|
|
|
|
|
|
return f != $builtin; |
974
|
|
|
|
|
|
|
#else |
975
|
|
|
|
|
|
|
return __has_builtin($builtin); |
976
|
|
|
|
|
|
|
#endif |
977
|
|
|
|
|
|
|
_ACEOF |
978
|
1
|
|
|
|
|
5
|
return $body; |
979
|
|
|
|
|
|
|
} |
980
|
|
|
|
|
|
|
|
981
|
|
|
|
|
|
|
=head2 lang_builtin( [prologue], builtin ) |
982
|
|
|
|
|
|
|
|
983
|
|
|
|
|
|
|
Builds program which simply proves whether a builtin is known to |
984
|
|
|
|
|
|
|
language compiler. |
985
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
=cut |
987
|
|
|
|
|
|
|
|
988
|
|
|
|
|
|
|
sub lang_builtin |
989
|
|
|
|
|
|
|
{ |
990
|
1
|
|
|
1
|
1
|
9
|
my ($self, $prologue, $builtin) = @_; |
991
|
1
|
50
|
|
|
|
5
|
ref $self or $self = $self->_get_instance(); |
992
|
|
|
|
|
|
|
|
993
|
1
|
|
|
|
|
15
|
return $self->lang_build_program($self->_lang_prologue_func($prologue, $builtin), $self->_lang_body_builtin($builtin),); |
994
|
|
|
|
|
|
|
} |
995
|
|
|
|
|
|
|
|
996
|
|
|
|
|
|
|
=head2 lang_build_bool_test (prologue, test, [@decls]) |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
Builds a static test which will fail to compile when test |
999
|
|
|
|
|
|
|
evaluates to false. If C<@decls> is given, it's prepended |
1000
|
|
|
|
|
|
|
before the test code at the variable definition place. |
1001
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
=cut |
1003
|
|
|
|
|
|
|
|
1004
|
|
|
|
|
|
|
sub lang_build_bool_test |
1005
|
|
|
|
|
|
|
{ |
1006
|
82
|
|
|
82
|
1
|
16449
|
my ($self, $prologue, $test, @decls) = @_; |
1007
|
82
|
50
|
|
|
|
633
|
ref $self or $self = $self->_get_instance(); |
1008
|
|
|
|
|
|
|
|
1009
|
82
|
50
|
|
|
|
374
|
defined($test) or $test = "1"; |
1010
|
82
|
|
|
|
|
401
|
my $test_code = <
|
1011
|
|
|
|
|
|
|
static int test_array [($test) ? 1 : -1 ]; |
1012
|
|
|
|
|
|
|
test_array [0] = 0 |
1013
|
|
|
|
|
|
|
ACEOF |
1014
|
82
|
100
|
|
|
|
414
|
if (@decls) |
1015
|
|
|
|
|
|
|
{ |
1016
|
42
|
|
|
|
|
245
|
$test_code = join("\n", @decls, $test_code); |
1017
|
|
|
|
|
|
|
} |
1018
|
82
|
|
|
|
|
1464
|
$self->lang_build_program($prologue, $test_code); |
1019
|
|
|
|
|
|
|
} |
1020
|
|
|
|
|
|
|
|
1021
|
|
|
|
|
|
|
=head2 push_includes |
1022
|
|
|
|
|
|
|
|
1023
|
|
|
|
|
|
|
Adds given list of directories to preprocessor/compiler |
1024
|
|
|
|
|
|
|
invocation. This is not proved to allow adding directories |
1025
|
|
|
|
|
|
|
which might be created during the build. |
1026
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
=cut |
1028
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
sub push_includes |
1030
|
|
|
|
|
|
|
{ |
1031
|
0
|
|
|
0
|
1
|
0
|
my ($self, @includes) = @_; |
1032
|
0
|
0
|
|
|
|
0
|
ref $self or $self = $self->_get_instance(); |
1033
|
|
|
|
|
|
|
|
1034
|
0
|
|
|
|
|
0
|
push(@{$self->{extra_include_dirs}}, @includes); |
|
0
|
|
|
|
|
0
|
|
1035
|
|
|
|
|
|
|
|
1036
|
0
|
|
|
|
|
0
|
return; |
1037
|
|
|
|
|
|
|
} |
1038
|
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
=head2 push_preprocess_flags |
1040
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
Adds given flags to the parameter list for preprocessor invocation. |
1042
|
|
|
|
|
|
|
|
1043
|
|
|
|
|
|
|
=cut |
1044
|
|
|
|
|
|
|
|
1045
|
|
|
|
|
|
|
sub push_preprocess_flags |
1046
|
|
|
|
|
|
|
{ |
1047
|
0
|
|
|
0
|
1
|
0
|
my ($self, @cpp_flags) = @_; |
1048
|
0
|
0
|
|
|
|
0
|
ref $self or $self = $self->_get_instance(); |
1049
|
|
|
|
|
|
|
|
1050
|
0
|
|
|
|
|
0
|
push(@{$self->{extra_preprocess_flags}}, @cpp_flags); |
|
0
|
|
|
|
|
0
|
|
1051
|
|
|
|
|
|
|
|
1052
|
0
|
|
|
|
|
0
|
return; |
1053
|
|
|
|
|
|
|
} |
1054
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
=head2 push_compiler_flags |
1056
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
Adds given flags to the parameter list for compiler invocation. |
1058
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
=cut |
1060
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
sub push_compiler_flags |
1062
|
|
|
|
|
|
|
{ |
1063
|
0
|
|
|
0
|
1
|
0
|
my ($self, @compiler_flags) = @_; |
1064
|
0
|
0
|
|
|
|
0
|
ref $self or $self = $self->_get_instance(); |
1065
|
0
|
|
|
|
|
0
|
my $lang = $self->{lang}; |
1066
|
|
|
|
|
|
|
|
1067
|
0
|
0
|
0
|
|
|
0
|
if (scalar(@compiler_flags) && (ref($compiler_flags[-1]) eq "HASH")) |
1068
|
|
|
|
|
|
|
{ |
1069
|
0
|
|
|
|
|
0
|
my $lang_opt = pop(@compiler_flags); |
1070
|
0
|
0
|
|
|
|
0
|
defined($lang_opt->{lang}) or croak("Missing lang attribute in language options"); |
1071
|
0
|
|
|
|
|
0
|
$lang = $lang_opt->{lang}; |
1072
|
0
|
0
|
|
|
|
0
|
defined($self->{lang_supported}->{$lang}) or croak("Unsupported language '$lang'"); |
1073
|
|
|
|
|
|
|
} |
1074
|
|
|
|
|
|
|
|
1075
|
0
|
|
|
|
|
0
|
push(@{$self->{extra_compile_flags}->{$lang}}, @compiler_flags); |
|
0
|
|
|
|
|
0
|
|
1076
|
|
|
|
|
|
|
|
1077
|
0
|
|
|
|
|
0
|
return; |
1078
|
|
|
|
|
|
|
} |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
=head2 push_libraries |
1081
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
Adds given list of libraries to the parameter list for linker invocation. |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
=cut |
1085
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
sub push_libraries |
1087
|
|
|
|
|
|
|
{ |
1088
|
0
|
|
|
0
|
1
|
0
|
my ($self, @libs) = @_; |
1089
|
0
|
0
|
|
|
|
0
|
ref $self or $self = $self->_get_instance(); |
1090
|
|
|
|
|
|
|
|
1091
|
0
|
|
|
|
|
0
|
push(@{$self->{extra_libs}}, @libs); |
|
0
|
|
|
|
|
0
|
|
1092
|
|
|
|
|
|
|
|
1093
|
0
|
|
|
|
|
0
|
return; |
1094
|
|
|
|
|
|
|
} |
1095
|
|
|
|
|
|
|
|
1096
|
|
|
|
|
|
|
=head2 push_library_paths |
1097
|
|
|
|
|
|
|
|
1098
|
|
|
|
|
|
|
Adds given list of library paths to the parameter list for linker invocation. |
1099
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
=cut |
1101
|
|
|
|
|
|
|
|
1102
|
|
|
|
|
|
|
sub push_library_paths |
1103
|
|
|
|
|
|
|
{ |
1104
|
0
|
|
|
0
|
1
|
0
|
my ($self, @libdirs) = @_; |
1105
|
0
|
0
|
|
|
|
0
|
ref $self or $self = $self->_get_instance(); |
1106
|
|
|
|
|
|
|
|
1107
|
0
|
|
|
|
|
0
|
push(@{$self->{extra_lib_dirs}}, @libdirs); |
|
0
|
|
|
|
|
0
|
|
1108
|
|
|
|
|
|
|
|
1109
|
0
|
|
|
|
|
0
|
return; |
1110
|
|
|
|
|
|
|
} |
1111
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
=head2 push_link_flags |
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
Adds given flags to the parameter list for linker invocation. |
1115
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
=cut |
1117
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
sub push_link_flags |
1119
|
|
|
|
|
|
|
{ |
1120
|
0
|
|
|
0
|
1
|
0
|
my ($self, @link_flags) = @_; |
1121
|
0
|
0
|
|
|
|
0
|
ref $self or $self = $self->_get_instance(); |
1122
|
|
|
|
|
|
|
|
1123
|
0
|
|
|
|
|
0
|
push(@{$self->{extra_link_flags}}, @link_flags); |
|
0
|
|
|
|
|
0
|
|
1124
|
|
|
|
|
|
|
|
1125
|
0
|
|
|
|
|
0
|
return; |
1126
|
|
|
|
|
|
|
} |
1127
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
=head2 compile_if_else( $src, \%options? ) |
1129
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
This function tries to compile specified code and returns a boolean value |
1131
|
|
|
|
|
|
|
containing check success state. |
1132
|
|
|
|
|
|
|
|
1133
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
1134
|
|
|
|
|
|
|
to I or I are executed, respectively. |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
=cut |
1137
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
sub compile_if_else |
1139
|
|
|
|
|
|
|
{ |
1140
|
162
|
|
|
162
|
1
|
684
|
my ($self, $src) = @_; |
1141
|
162
|
50
|
|
|
|
753
|
ref $self or $self = $self->_get_instance(); |
1142
|
|
|
|
|
|
|
|
1143
|
162
|
|
|
|
|
525
|
my $options = {}; |
1144
|
162
|
100
|
66
|
|
|
942
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
1145
|
|
|
|
|
|
|
|
1146
|
162
|
|
|
|
|
727
|
my $builder = $self->_get_builder(); |
1147
|
|
|
|
|
|
|
|
1148
|
162
|
|
|
|
|
1482058
|
my ($fh, $filename) = tempfile( |
1149
|
|
|
|
|
|
|
"testXXXXXX", |
1150
|
|
|
|
|
|
|
SUFFIX => '.c', |
1151
|
|
|
|
|
|
|
UNLINK => 0 |
1152
|
|
|
|
|
|
|
); |
1153
|
|
|
|
|
|
|
|
1154
|
162
|
|
|
|
|
96920
|
print {$fh} $src; |
|
162
|
|
|
|
|
1504
|
|
1155
|
162
|
|
|
|
|
6710
|
close $fh; |
1156
|
|
|
|
|
|
|
|
1157
|
162
|
|
|
|
|
660
|
my ($obj_file, $outbuf, $errbuf, $exception); |
1158
|
|
|
|
|
|
|
($outbuf, $errbuf) = capture |
1159
|
|
|
|
|
|
|
{ |
1160
|
162
|
|
|
162
|
|
222110
|
eval { |
1161
|
|
|
|
|
|
|
$obj_file = $builder->compile( |
1162
|
|
|
|
|
|
|
source => $filename, |
1163
|
|
|
|
|
|
|
include_dirs => $self->{extra_include_dirs}, |
1164
|
162
|
|
|
|
|
1833
|
extra_compiler_flags => $self->_get_extra_compiler_flags() |
1165
|
|
|
|
|
|
|
); |
1166
|
|
|
|
|
|
|
}; |
1167
|
|
|
|
|
|
|
|
1168
|
162
|
|
|
|
|
28443016
|
$exception = $@; |
1169
|
162
|
|
|
|
|
16248
|
}; |
1170
|
|
|
|
|
|
|
|
1171
|
162
|
|
|
|
|
284789
|
unlink $filename; |
1172
|
162
|
50
|
66
|
|
|
4386
|
$obj_file and !-f $obj_file and undef $obj_file; |
1173
|
162
|
100
|
|
|
|
4340
|
unlink $obj_file if $obj_file; |
1174
|
|
|
|
|
|
|
|
1175
|
162
|
100
|
66
|
|
|
2155
|
if ($exception || !$obj_file) |
1176
|
|
|
|
|
|
|
{ |
1177
|
72
|
50
|
|
|
|
2007
|
$self->_add_log_lines("compile stage failed" . ($exception ? " - " . $exception : "")); |
1178
|
72
|
50
|
|
|
|
526
|
$errbuf |
1179
|
|
|
|
|
|
|
and $self->_add_log_lines($errbuf); |
1180
|
72
|
|
|
|
|
1095
|
$self->_add_log_lines("failing program is:\n" . $src); |
1181
|
72
|
50
|
|
|
|
578
|
$outbuf |
1182
|
|
|
|
|
|
|
and $self->_add_log_lines("stdout was :\n" . $outbuf); |
1183
|
|
|
|
|
|
|
|
1184
|
|
|
|
|
|
|
$options->{action_on_false} |
1185
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
1186
|
72
|
50
|
33
|
|
|
826
|
and $options->{action_on_false}->(); |
1187
|
|
|
|
|
|
|
|
1188
|
72
|
|
|
|
|
1571
|
return 0; |
1189
|
|
|
|
|
|
|
} |
1190
|
|
|
|
|
|
|
|
1191
|
|
|
|
|
|
|
$options->{action_on_true} |
1192
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
1193
|
90
|
50
|
33
|
|
|
684
|
and $options->{action_on_true}->(); |
1194
|
|
|
|
|
|
|
|
1195
|
90
|
|
|
|
|
1711
|
1; |
1196
|
|
|
|
|
|
|
} |
1197
|
|
|
|
|
|
|
|
1198
|
|
|
|
|
|
|
=head2 link_if_else( $src, \%options? ) |
1199
|
|
|
|
|
|
|
|
1200
|
|
|
|
|
|
|
This function tries to compile and link specified code and returns a boolean |
1201
|
|
|
|
|
|
|
value containing check success state. |
1202
|
|
|
|
|
|
|
|
1203
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
1204
|
|
|
|
|
|
|
to I or I are executed, respectively. |
1205
|
|
|
|
|
|
|
|
1206
|
|
|
|
|
|
|
=cut |
1207
|
|
|
|
|
|
|
|
1208
|
|
|
|
|
|
|
sub link_if_else |
1209
|
|
|
|
|
|
|
{ |
1210
|
17
|
|
|
17
|
1
|
71
|
my ($self, $src) = @_; |
1211
|
17
|
50
|
|
|
|
65
|
ref $self or $self = $self->_get_instance(); |
1212
|
17
|
|
|
|
|
47
|
my $options = {}; |
1213
|
17
|
100
|
66
|
|
|
266
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
1214
|
|
|
|
|
|
|
|
1215
|
17
|
|
|
|
|
106
|
my $builder = $self->_get_builder(); |
1216
|
|
|
|
|
|
|
|
1217
|
17
|
|
|
|
|
151076
|
my ($fh, $filename) = tempfile( |
1218
|
|
|
|
|
|
|
"testXXXXXX", |
1219
|
|
|
|
|
|
|
SUFFIX => '.c', |
1220
|
|
|
|
|
|
|
UNLINK => 0 |
1221
|
|
|
|
|
|
|
); |
1222
|
|
|
|
|
|
|
|
1223
|
17
|
|
|
|
|
9733
|
print {$fh} $src; |
|
17
|
|
|
|
|
486
|
|
1224
|
17
|
|
|
|
|
619
|
close $fh; |
1225
|
|
|
|
|
|
|
|
1226
|
17
|
|
|
|
|
110
|
my ($obj_file, $outbuf, $errbuf, $exception); |
1227
|
|
|
|
|
|
|
($outbuf, $errbuf) = capture |
1228
|
|
|
|
|
|
|
{ |
1229
|
17
|
|
|
17
|
|
22360
|
eval { |
1230
|
|
|
|
|
|
|
$obj_file = $builder->compile( |
1231
|
|
|
|
|
|
|
source => $filename, |
1232
|
|
|
|
|
|
|
include_dirs => $self->{extra_include_dirs}, |
1233
|
17
|
|
|
|
|
268
|
extra_compiler_flags => $self->_get_extra_compiler_flags() |
1234
|
|
|
|
|
|
|
); |
1235
|
|
|
|
|
|
|
}; |
1236
|
|
|
|
|
|
|
|
1237
|
17
|
|
|
|
|
687477
|
$exception = $@; |
1238
|
17
|
|
|
|
|
1924
|
}; |
1239
|
|
|
|
|
|
|
|
1240
|
17
|
50
|
66
|
|
|
27278
|
$obj_file and !-f $obj_file and undef $obj_file; |
1241
|
|
|
|
|
|
|
|
1242
|
17
|
100
|
66
|
|
|
280
|
if ($exception || !$obj_file) |
1243
|
|
|
|
|
|
|
{ |
1244
|
1
|
50
|
|
|
|
53
|
$self->_add_log_lines("compile stage failed" . ($exception ? " - " . $exception : "")); |
1245
|
1
|
50
|
|
|
|
22
|
$errbuf |
1246
|
|
|
|
|
|
|
and $self->_add_log_lines($errbuf); |
1247
|
1
|
|
|
|
|
16
|
$self->_add_log_lines("failing program is:\n" . $src); |
1248
|
1
|
50
|
|
|
|
13
|
$outbuf |
1249
|
|
|
|
|
|
|
and $self->_add_log_lines("stdout was :\n" . $outbuf); |
1250
|
|
|
|
|
|
|
|
1251
|
1
|
|
|
|
|
43
|
unlink $filename; |
1252
|
1
|
50
|
|
|
|
15
|
unlink $obj_file if $obj_file; |
1253
|
|
|
|
|
|
|
|
1254
|
|
|
|
|
|
|
$options->{action_on_false} |
1255
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
1256
|
1
|
50
|
33
|
|
|
8
|
and $options->{action_on_false}->(); |
1257
|
|
|
|
|
|
|
|
1258
|
1
|
|
|
|
|
25
|
return 0; |
1259
|
|
|
|
|
|
|
} |
1260
|
|
|
|
|
|
|
|
1261
|
16
|
|
|
|
|
70
|
my $exe_file; |
1262
|
|
|
|
|
|
|
($outbuf, $errbuf) = capture |
1263
|
|
|
|
|
|
|
{ |
1264
|
16
|
|
|
16
|
|
27620
|
eval { |
1265
|
16
|
|
|
|
|
352
|
$exe_file = $builder->link_executable( |
1266
|
|
|
|
|
|
|
objects => $obj_file, |
1267
|
|
|
|
|
|
|
extra_linker_flags => $self->_get_extra_linker_flags() |
1268
|
|
|
|
|
|
|
); |
1269
|
|
|
|
|
|
|
}; |
1270
|
|
|
|
|
|
|
|
1271
|
16
|
|
|
|
|
674923
|
$exception = $@; |
1272
|
16
|
|
|
|
|
2460
|
}; |
1273
|
|
|
|
|
|
|
|
1274
|
16
|
50
|
66
|
|
|
25100
|
$exe_file and !-f $exe_file and undef $exe_file; |
1275
|
|
|
|
|
|
|
|
1276
|
16
|
|
|
|
|
831
|
unlink $filename; |
1277
|
16
|
50
|
|
|
|
694
|
unlink $obj_file if $obj_file; |
1278
|
16
|
100
|
|
|
|
1616
|
unlink $exe_file if $exe_file; |
1279
|
|
|
|
|
|
|
|
1280
|
16
|
100
|
66
|
|
|
328
|
if ($exception || !$exe_file) |
1281
|
|
|
|
|
|
|
{ |
1282
|
3
|
50
|
|
|
|
122
|
$self->_add_log_lines("link stage failed" . ($exception ? " - " . $exception : "")); |
1283
|
3
|
50
|
|
|
|
28
|
$errbuf |
1284
|
|
|
|
|
|
|
and $self->_add_log_lines($errbuf); |
1285
|
3
|
|
|
|
|
32
|
$self->_add_log_lines("failing program is:\n" . $src); |
1286
|
3
|
50
|
|
|
|
115
|
$outbuf |
1287
|
|
|
|
|
|
|
and $self->_add_log_lines("stdout was :\n" . $outbuf); |
1288
|
|
|
|
|
|
|
|
1289
|
|
|
|
|
|
|
$options->{action_on_false} |
1290
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
1291
|
3
|
100
|
66
|
|
|
55
|
and $options->{action_on_false}->(); |
1292
|
|
|
|
|
|
|
|
1293
|
3
|
|
|
|
|
83
|
return 0; |
1294
|
|
|
|
|
|
|
} |
1295
|
|
|
|
|
|
|
|
1296
|
|
|
|
|
|
|
$options->{action_on_true} |
1297
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
1298
|
13
|
100
|
66
|
|
|
315
|
and $options->{action_on_true}->(); |
1299
|
|
|
|
|
|
|
|
1300
|
13
|
|
|
|
|
464
|
1; |
1301
|
|
|
|
|
|
|
} |
1302
|
|
|
|
|
|
|
|
1303
|
|
|
|
|
|
|
=head2 check_cached( $cache-key, $check-title, \&check-call, \%options? ) |
1304
|
|
|
|
|
|
|
|
1305
|
|
|
|
|
|
|
Retrieves the result of a previous L invocation from |
1306
|
|
|
|
|
|
|
C, or (when called for the first time) populates the cache |
1307
|
|
|
|
|
|
|
by invoking C<\&check_call>. |
1308
|
|
|
|
|
|
|
|
1309
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
1310
|
|
|
|
|
|
|
to I or I are executed on B call |
1311
|
|
|
|
|
|
|
to check_cached (not just the first cache-populating invocation), respectively. |
1312
|
|
|
|
|
|
|
|
1313
|
|
|
|
|
|
|
=cut |
1314
|
|
|
|
|
|
|
|
1315
|
|
|
|
|
|
|
sub check_cached |
1316
|
|
|
|
|
|
|
{ |
1317
|
123
|
|
|
123
|
1
|
674
|
my ($self, $cache_name, $message, $check_sub) = @_; |
1318
|
123
|
50
|
|
|
|
976
|
ref $self or $self = $self->_get_instance(); |
1319
|
123
|
|
|
|
|
414
|
my $options = {}; |
1320
|
123
|
100
|
66
|
|
|
1975
|
scalar @_ > 4 and ref $_[-1] eq "HASH" and $options = pop @_; |
1321
|
|
|
|
|
|
|
|
1322
|
123
|
|
|
|
|
733
|
$self->msg_checking($message); |
1323
|
|
|
|
|
|
|
|
1324
|
|
|
|
|
|
|
defined $ENV{$cache_name} |
1325
|
|
|
|
|
|
|
and not defined $self->{cache}->{$cache_name} |
1326
|
123
|
100
|
66
|
|
|
652
|
and $self->{cache}->{$cache_name} = $ENV{$cache_name}; |
1327
|
|
|
|
|
|
|
|
1328
|
123
|
|
|
|
|
271
|
my @cached_result; |
1329
|
123
|
100
|
|
|
|
528
|
defined($self->{cache}->{$cache_name}) and push @cached_result, "(cached)"; |
1330
|
123
|
100
|
|
|
|
607
|
defined($self->{cache}->{$cache_name}) or $self->{cache}->{$cache_name} = $check_sub->(); |
1331
|
|
|
|
|
|
|
|
1332
|
123
|
|
|
|
|
12318
|
$self->msg_result(@cached_result, $self->{cache}->{$cache_name}); |
1333
|
|
|
|
|
|
|
|
1334
|
|
|
|
|
|
|
$options->{action_on_true} |
1335
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
1336
|
|
|
|
|
|
|
and $self->{cache}->{$cache_name} |
1337
|
123
|
100
|
66
|
|
|
2410
|
and $options->{action_on_true}->(); |
|
|
|
100
|
|
|
|
|
1338
|
|
|
|
|
|
|
|
1339
|
|
|
|
|
|
|
$options->{action_on_false} |
1340
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
1341
|
|
|
|
|
|
|
and !$self->{cache}->{$cache_name} |
1342
|
123
|
100
|
66
|
|
|
1890
|
and $options->{action_on_false}->(); |
|
|
|
100
|
|
|
|
|
1343
|
|
|
|
|
|
|
|
1344
|
123
|
|
|
|
|
7228
|
$self->{cache}->{$cache_name}; |
1345
|
|
|
|
|
|
|
} |
1346
|
|
|
|
|
|
|
|
1347
|
|
|
|
|
|
|
=head2 cache_val |
1348
|
|
|
|
|
|
|
|
1349
|
|
|
|
|
|
|
This function returns the value of a previously check_cached call. |
1350
|
|
|
|
|
|
|
|
1351
|
|
|
|
|
|
|
=cut |
1352
|
|
|
|
|
|
|
|
1353
|
|
|
|
|
|
|
sub cache_val |
1354
|
|
|
|
|
|
|
{ |
1355
|
86
|
|
|
86
|
1
|
420
|
my ($self, $cache_name) = @_; |
1356
|
86
|
50
|
|
|
|
739
|
ref $self or $self = $self->_get_instance(); |
1357
|
86
|
50
|
|
|
|
402
|
defined $self->{cache}->{$cache_name} or return; |
1358
|
86
|
|
|
|
|
1162
|
$self->{cache}->{$cache_name}; |
1359
|
|
|
|
|
|
|
} |
1360
|
|
|
|
|
|
|
|
1361
|
|
|
|
|
|
|
=head2 check_decl( $symbol, \%options? ) |
1362
|
|
|
|
|
|
|
|
1363
|
|
|
|
|
|
|
This method actually tests whether symbol is defined as a macro or can be |
1364
|
|
|
|
|
|
|
used as an r-value, not whether it is really declared, because it is much |
1365
|
|
|
|
|
|
|
safer to avoid introducing extra declarations when they are not needed. |
1366
|
|
|
|
|
|
|
In order to facilitate use of C++ and overloaded function declarations, it |
1367
|
|
|
|
|
|
|
is possible to specify function argument types in parentheses for types |
1368
|
|
|
|
|
|
|
which can be zero-initialized: |
1369
|
|
|
|
|
|
|
|
1370
|
|
|
|
|
|
|
Config::AutoConf->check_decl("basename(char *)") |
1371
|
|
|
|
|
|
|
|
1372
|
|
|
|
|
|
|
This method caches its result in the Cset langE>_symbol |
1373
|
|
|
|
|
|
|
variable. |
1374
|
|
|
|
|
|
|
|
1375
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
1376
|
|
|
|
|
|
|
to I or I are executed, respectively. |
1377
|
|
|
|
|
|
|
When a I exists in the optional hash at end, it will be favored |
1378
|
|
|
|
|
|
|
over C (represented by L). If any of |
1379
|
|
|
|
|
|
|
I, I is defined, both callbacks |
1380
|
|
|
|
|
|
|
are passed to L as I or I to |
1381
|
|
|
|
|
|
|
C, respectively. |
1382
|
|
|
|
|
|
|
|
1383
|
|
|
|
|
|
|
=cut |
1384
|
|
|
|
|
|
|
|
1385
|
|
|
|
|
|
|
sub check_decl |
1386
|
|
|
|
|
|
|
{ |
1387
|
5
|
|
|
5
|
1
|
2261
|
my ($self, $symbol) = @_; |
1388
|
5
|
|
|
|
|
32
|
$self = $self->_get_instance(); |
1389
|
5
|
|
|
|
|
24
|
my $options = {}; |
1390
|
5
|
50
|
33
|
|
|
84
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
1391
|
|
|
|
|
|
|
|
1392
|
5
|
50
|
|
|
|
28
|
defined($symbol) or return croak("No symbol to check for"); |
1393
|
5
|
50
|
|
|
|
27
|
ref($symbol) eq "" or return croak("No symbol to check for"); |
1394
|
5
|
|
|
|
|
84
|
(my $sym_plain = $symbol) =~ s/ *\(.*//; |
1395
|
5
|
|
|
|
|
16
|
my $sym_call = $symbol; |
1396
|
5
|
|
|
|
|
25
|
$sym_call =~ s/\(/((/; |
1397
|
5
|
|
|
|
|
15
|
$sym_call =~ s/\)/) 0)/; |
1398
|
5
|
|
|
|
|
19
|
$sym_call =~ s/,/) 0, (/g; |
1399
|
|
|
|
|
|
|
|
1400
|
5
|
|
|
|
|
51
|
my $cache_name = $self->_cache_name("decl", $self->{lang}, $symbol); |
1401
|
|
|
|
|
|
|
my $check_sub = sub { |
1402
|
|
|
|
|
|
|
|
1403
|
5
|
|
|
5
|
|
26
|
my $body = <
|
1404
|
|
|
|
|
|
|
#ifndef $sym_plain |
1405
|
|
|
|
|
|
|
(void) $sym_call; |
1406
|
|
|
|
|
|
|
#endif |
1407
|
|
|
|
|
|
|
ACEOF |
1408
|
5
|
|
|
|
|
73
|
my $conftest = $self->lang_build_program($options->{prologue}, $body); |
1409
|
|
|
|
|
|
|
|
1410
|
|
|
|
|
|
|
my $have_decl = $self->compile_if_else( |
1411
|
|
|
|
|
|
|
$conftest, |
1412
|
|
|
|
|
|
|
{ |
1413
|
|
|
|
|
|
|
($options->{action_on_true} ? (action_on_true => $options->{action_on_true}) : ()), |
1414
|
5
|
50
|
|
|
|
44
|
($options->{action_on_false} ? (action_on_false => $options->{action_on_false}) : ()) |
|
|
50
|
|
|
|
|
|
1415
|
|
|
|
|
|
|
} |
1416
|
|
|
|
|
|
|
); |
1417
|
|
|
|
|
|
|
|
1418
|
5
|
|
|
|
|
6396
|
$have_decl; |
1419
|
5
|
|
|
|
|
56
|
}; |
1420
|
|
|
|
|
|
|
|
1421
|
|
|
|
|
|
|
$self->check_cached( |
1422
|
|
|
|
|
|
|
$cache_name, |
1423
|
|
|
|
|
|
|
"whether $symbol is declared", |
1424
|
|
|
|
|
|
|
$check_sub, |
1425
|
|
|
|
|
|
|
{ |
1426
|
|
|
|
|
|
|
($options->{action_on_cache_true} ? (action_on_true => $options->{action_on_cache_true}) : ()), |
1427
|
5
|
50
|
|
|
|
109
|
($options->{action_on_cache_false} ? (action_on_false => $options->{action_on_cache_false}) : ()) |
|
|
50
|
|
|
|
|
|
1428
|
|
|
|
|
|
|
} |
1429
|
|
|
|
|
|
|
); |
1430
|
|
|
|
|
|
|
} |
1431
|
|
|
|
|
|
|
|
1432
|
|
|
|
|
|
|
=head2 check_decls( symbols, \%options? ) |
1433
|
|
|
|
|
|
|
|
1434
|
|
|
|
|
|
|
For each of the symbols (with optional function argument types for C++ |
1435
|
|
|
|
|
|
|
overloads), run L. |
1436
|
|
|
|
|
|
|
|
1437
|
|
|
|
|
|
|
Contrary to B, this method does not declare C |
1438
|
|
|
|
|
|
|
macros for the resulting C, because it differs as C |
1439
|
|
|
|
|
|
|
between compiling languages. |
1440
|
|
|
|
|
|
|
|
1441
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
1442
|
|
|
|
|
|
|
to I or I are executed, respectively. |
1443
|
|
|
|
|
|
|
When a I exists in the optional hash at end, it will be favored |
1444
|
|
|
|
|
|
|
over C (represented by L). If any of |
1445
|
|
|
|
|
|
|
I, I is defined, both callbacks |
1446
|
|
|
|
|
|
|
are passed to L as I or I to |
1447
|
|
|
|
|
|
|
C, respectively. |
1448
|
|
|
|
|
|
|
Given callbacks for I or I are |
1449
|
|
|
|
|
|
|
called for each symbol checked using L receiving the symbol as |
1450
|
|
|
|
|
|
|
first argument. |
1451
|
|
|
|
|
|
|
|
1452
|
|
|
|
|
|
|
=cut |
1453
|
|
|
|
|
|
|
|
1454
|
|
|
|
|
|
|
sub check_decls |
1455
|
|
|
|
|
|
|
{ |
1456
|
1
|
|
|
1
|
1
|
5
|
my ($self, $symbols) = @_; |
1457
|
1
|
|
|
|
|
98
|
$self = $self->_get_instance(); |
1458
|
1
|
|
|
|
|
4
|
my $options = {}; |
1459
|
1
|
50
|
33
|
|
|
38
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
1460
|
|
|
|
|
|
|
|
1461
|
1
|
|
|
|
|
9
|
my %pass_options; |
1462
|
1
|
50
|
|
|
|
17
|
defined $options->{prologue} and $pass_options{prologue} = $options->{prologue}; |
1463
|
1
|
50
|
|
|
|
27
|
defined $options->{action_on_cache_true} and $pass_options{action_on_cache_true} = $options->{action_on_cache_true}; |
1464
|
1
|
50
|
|
|
|
13
|
defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false}; |
1465
|
|
|
|
|
|
|
|
1466
|
1
|
|
|
|
|
13
|
my $have_syms = 1; |
1467
|
1
|
|
|
|
|
12
|
foreach my $symbol (@$symbols) |
1468
|
|
|
|
|
|
|
{ |
1469
|
|
|
|
|
|
|
$have_syms &= $self->check_decl( |
1470
|
|
|
|
|
|
|
$symbol, |
1471
|
|
|
|
|
|
|
{ |
1472
|
|
|
|
|
|
|
%pass_options, |
1473
|
|
|
|
|
|
|
( |
1474
|
|
|
|
|
|
|
$options->{action_on_symbol_true} && "CODE" eq ref $options->{action_on_symbol_true} |
1475
|
0
|
|
|
0
|
|
0
|
? (action_on_true => sub { $options->{action_on_symbol_true}->($symbol) }) |
1476
|
|
|
|
|
|
|
: () |
1477
|
|
|
|
|
|
|
), |
1478
|
|
|
|
|
|
|
( |
1479
|
|
|
|
|
|
|
$options->{action_on_symbol_false} && "CODE" eq ref $options->{action_on_symbol_false} |
1480
|
0
|
|
|
0
|
|
0
|
? (action_on_false => sub { $options->{action_on_symbol_false}->($symbol) }) |
1481
|
3
|
50
|
33
|
|
|
76
|
: () |
|
|
50
|
33
|
|
|
|
|
1482
|
|
|
|
|
|
|
), |
1483
|
|
|
|
|
|
|
} |
1484
|
|
|
|
|
|
|
); |
1485
|
|
|
|
|
|
|
} |
1486
|
|
|
|
|
|
|
|
1487
|
|
|
|
|
|
|
$have_syms |
1488
|
|
|
|
|
|
|
and $options->{action_on_true} |
1489
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
1490
|
1
|
50
|
33
|
|
|
115
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
1491
|
|
|
|
|
|
|
|
1492
|
|
|
|
|
|
|
$options->{action_on_false} |
1493
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
1494
|
|
|
|
|
|
|
and !$have_syms |
1495
|
1
|
0
|
33
|
|
|
21
|
and $options->{action_on_false}->(); |
|
|
|
33
|
|
|
|
|
1496
|
|
|
|
|
|
|
|
1497
|
1
|
|
|
|
|
34
|
$have_syms; |
1498
|
|
|
|
|
|
|
} |
1499
|
|
|
|
|
|
|
|
1500
|
|
|
|
|
|
|
sub _have_func_define_name |
1501
|
|
|
|
|
|
|
{ |
1502
|
4
|
|
|
4
|
|
29
|
my $func = $_[0]; |
1503
|
4
|
|
|
|
|
29
|
my $have_name = "HAVE_" . uc($func); |
1504
|
4
|
|
|
|
|
29
|
$have_name =~ tr/_A-Za-z0-9/_/c; |
1505
|
4
|
|
|
|
|
56
|
$have_name; |
1506
|
|
|
|
|
|
|
} |
1507
|
|
|
|
|
|
|
|
1508
|
|
|
|
|
|
|
=head2 check_func( $function, \%options? ) |
1509
|
|
|
|
|
|
|
|
1510
|
|
|
|
|
|
|
This method actually tests whether I<$funcion> can be linked into a program |
1511
|
|
|
|
|
|
|
trying to call I<$function>. This method caches its result in the |
1512
|
|
|
|
|
|
|
ac_cv_func_FUNCTION variable. |
1513
|
|
|
|
|
|
|
|
1514
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
1515
|
|
|
|
|
|
|
to I or I are executed, respectively. |
1516
|
|
|
|
|
|
|
If any of I, I is defined, |
1517
|
|
|
|
|
|
|
both callbacks are passed to L as I or |
1518
|
|
|
|
|
|
|
I to C, respectively. |
1519
|
|
|
|
|
|
|
|
1520
|
|
|
|
|
|
|
Returns: True if the function was found, false otherwise |
1521
|
|
|
|
|
|
|
|
1522
|
|
|
|
|
|
|
=cut |
1523
|
|
|
|
|
|
|
|
1524
|
|
|
|
|
|
|
sub check_func |
1525
|
|
|
|
|
|
|
{ |
1526
|
4
|
|
|
4
|
1
|
28
|
my ($self, $function) = @_; |
1527
|
4
|
|
|
|
|
39
|
$self = $self->_get_instance(); |
1528
|
4
|
|
|
|
|
13
|
my $options = {}; |
1529
|
4
|
100
|
66
|
|
|
59
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
1530
|
|
|
|
|
|
|
|
1531
|
|
|
|
|
|
|
# Build the name of the cache variable. |
1532
|
4
|
|
|
|
|
32
|
my $cache_name = $self->_cache_name('func', $function); |
1533
|
|
|
|
|
|
|
# Wrap the actual check in a closure so that we can use check_cached. |
1534
|
|
|
|
|
|
|
my $check_sub = sub { |
1535
|
|
|
|
|
|
|
my $have_func = $self->link_if_else( |
1536
|
|
|
|
|
|
|
$self->lang_call(q{}, $function), |
1537
|
|
|
|
|
|
|
{ |
1538
|
|
|
|
|
|
|
($options->{action_on_true} ? (action_on_true => $options->{action_on_true}) : ()), |
1539
|
4
|
100
|
|
4
|
|
57
|
($options->{action_on_false} ? (action_on_false => $options->{action_on_false}) : ()) |
|
|
100
|
|
|
|
|
|
1540
|
|
|
|
|
|
|
} |
1541
|
|
|
|
|
|
|
); |
1542
|
4
|
|
|
|
|
4787
|
$have_func; |
1543
|
4
|
|
|
|
|
48
|
}; |
1544
|
|
|
|
|
|
|
|
1545
|
|
|
|
|
|
|
# Run the check and cache the results. |
1546
|
|
|
|
|
|
|
return $self->check_cached( |
1547
|
|
|
|
|
|
|
$cache_name, |
1548
|
|
|
|
|
|
|
"for $function", |
1549
|
|
|
|
|
|
|
$check_sub, |
1550
|
|
|
|
|
|
|
{ |
1551
|
|
|
|
|
|
|
action_on_true => sub { |
1552
|
4
|
|
|
4
|
|
52
|
$self->define_var( |
1553
|
|
|
|
|
|
|
_have_func_define_name($function), |
1554
|
|
|
|
|
|
|
$self->cache_val($cache_name), |
1555
|
|
|
|
|
|
|
"Defined when $function is available" |
1556
|
|
|
|
|
|
|
); |
1557
|
|
|
|
|
|
|
$options->{action_on_cache_true} |
1558
|
|
|
|
|
|
|
and ref $options->{action_on_cache_true} eq "CODE" |
1559
|
4
|
50
|
33
|
|
|
37
|
and $options->{action_on_cache_true}->(); |
1560
|
|
|
|
|
|
|
}, |
1561
|
|
|
|
|
|
|
action_on_false => sub { |
1562
|
0
|
|
|
0
|
|
0
|
$self->define_var(_have_func_define_name($function), undef, "Defined when $function is available"); |
1563
|
|
|
|
|
|
|
$options->{action_on_cache_false} |
1564
|
|
|
|
|
|
|
and ref $options->{action_on_cache_false} eq "CODE" |
1565
|
0
|
0
|
0
|
|
|
0
|
and $options->{action_on_cache_false}->(); |
1566
|
|
|
|
|
|
|
}, |
1567
|
|
|
|
|
|
|
} |
1568
|
4
|
|
|
|
|
79
|
); |
1569
|
|
|
|
|
|
|
} |
1570
|
|
|
|
|
|
|
|
1571
|
|
|
|
|
|
|
=head2 check_funcs( \@functions-list, $action-if-true?, $action-if-false? ) |
1572
|
|
|
|
|
|
|
|
1573
|
|
|
|
|
|
|
The same as check_func, but takes a list of functions in I<\@functions-list> |
1574
|
|
|
|
|
|
|
to look for and checks for each in turn. Define HAVE_FUNCTION for each |
1575
|
|
|
|
|
|
|
function that was found. |
1576
|
|
|
|
|
|
|
|
1577
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
1578
|
|
|
|
|
|
|
to I or I are executed, respectively. |
1579
|
|
|
|
|
|
|
If any of I, I is defined, |
1580
|
|
|
|
|
|
|
both callbacks are passed to L as I or |
1581
|
|
|
|
|
|
|
I to C, respectively. Given callbacks |
1582
|
|
|
|
|
|
|
for I or I are called for |
1583
|
|
|
|
|
|
|
each symbol checked using L receiving the symbol as first |
1584
|
|
|
|
|
|
|
argument. |
1585
|
|
|
|
|
|
|
|
1586
|
|
|
|
|
|
|
=cut |
1587
|
|
|
|
|
|
|
|
1588
|
|
|
|
|
|
|
sub check_funcs |
1589
|
|
|
|
|
|
|
{ |
1590
|
1
|
|
|
1
|
1
|
11
|
my ($self, $functions_ref) = @_; |
1591
|
1
|
|
|
|
|
10
|
$self = $self->_get_instance(); |
1592
|
|
|
|
|
|
|
|
1593
|
1
|
|
|
|
|
8
|
my $options = {}; |
1594
|
1
|
50
|
33
|
|
|
29
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
1595
|
|
|
|
|
|
|
|
1596
|
1
|
|
|
|
|
7
|
my %pass_options; |
1597
|
1
|
50
|
|
|
|
13
|
defined $options->{action_on_cache_true} and $pass_options{action_on_cache_true} = $options->{action_on_cache_true}; |
1598
|
1
|
50
|
|
|
|
15
|
defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false}; |
1599
|
|
|
|
|
|
|
|
1600
|
|
|
|
|
|
|
# Go through the list of functions and call check_func for each one. We |
1601
|
|
|
|
|
|
|
# generate new closures for the found and not-found functions that pass in |
1602
|
|
|
|
|
|
|
# the relevant function name. |
1603
|
1
|
|
|
|
|
3
|
my $have_funcs = 1; |
1604
|
1
|
|
|
|
|
3
|
for my $function (@{$functions_ref}) |
|
1
|
|
|
|
|
12
|
|
1605
|
|
|
|
|
|
|
{ |
1606
|
|
|
|
|
|
|
# Build the code reference to run when a function was found. This defines |
1607
|
|
|
|
|
|
|
# a HAVE_FUNCTION symbol, plus runs the current $action-if-true if there is |
1608
|
|
|
|
|
|
|
# one. |
1609
|
|
|
|
|
|
|
$pass_options{action_on_true} = sub { |
1610
|
|
|
|
|
|
|
# Run the user-provided hook, if there is one. |
1611
|
|
|
|
|
|
|
defined $options->{action_on_function_true} |
1612
|
|
|
|
|
|
|
and ref $options->{action_on_function_true} eq "CODE" |
1613
|
2
|
50
|
33
|
2
|
|
37
|
and $options->{action_on_function_true}->($function); |
1614
|
2
|
|
|
|
|
45
|
}; |
1615
|
|
|
|
|
|
|
|
1616
|
|
|
|
|
|
|
defined $options->{action_on_function_false} |
1617
|
|
|
|
|
|
|
and ref $options->{action_on_function_false} eq "CODE" |
1618
|
2
|
50
|
33
|
0
|
|
23
|
and $pass_options{action_on_false} = sub { $options->{action_on_function_false}->($function); }; |
|
0
|
|
|
|
|
0
|
|
1619
|
|
|
|
|
|
|
|
1620
|
2
|
|
|
|
|
18
|
$have_funcs &= check_func($self, $function, \%pass_options); |
1621
|
|
|
|
|
|
|
} |
1622
|
|
|
|
|
|
|
|
1623
|
|
|
|
|
|
|
$have_funcs |
1624
|
|
|
|
|
|
|
and $options->{action_on_true} |
1625
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
1626
|
1
|
50
|
33
|
|
|
49
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
1627
|
|
|
|
|
|
|
|
1628
|
|
|
|
|
|
|
$options->{action_on_false} |
1629
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
1630
|
|
|
|
|
|
|
and !$have_funcs |
1631
|
1
|
0
|
33
|
|
|
17
|
and $options->{action_on_false}->(); |
|
|
|
33
|
|
|
|
|
1632
|
|
|
|
|
|
|
|
1633
|
1
|
|
|
|
|
63
|
return $have_funcs; |
1634
|
|
|
|
|
|
|
} |
1635
|
|
|
|
|
|
|
|
1636
|
|
|
|
|
|
|
=head2 check_builtin( $builtin, \%options? ) |
1637
|
|
|
|
|
|
|
|
1638
|
|
|
|
|
|
|
This method actually tests whether I<$builtin> is a supported built-in |
1639
|
|
|
|
|
|
|
known by the compiler. Either, by giving us the type of the built-in or |
1640
|
|
|
|
|
|
|
by taking the value from C<__has_builtin>. This method caches its result |
1641
|
|
|
|
|
|
|
in the ac_cv_builtin_FUNCTION variable. |
1642
|
|
|
|
|
|
|
|
1643
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
1644
|
|
|
|
|
|
|
to I or I are executed, respectively. |
1645
|
|
|
|
|
|
|
If any of I, I is defined, |
1646
|
|
|
|
|
|
|
both callbacks are passed to L as I or |
1647
|
|
|
|
|
|
|
I to C, respectively. |
1648
|
|
|
|
|
|
|
|
1649
|
|
|
|
|
|
|
Returns: True if the function was found, false otherwise |
1650
|
|
|
|
|
|
|
|
1651
|
|
|
|
|
|
|
=cut |
1652
|
|
|
|
|
|
|
|
1653
|
|
|
|
|
|
|
sub _have_builtin_define_name |
1654
|
|
|
|
|
|
|
{ |
1655
|
1
|
|
|
1
|
|
26
|
my $builtin = $_[0]; |
1656
|
1
|
|
|
|
|
12
|
my $have_name = "HAVE_BUILTIN_" . uc($builtin); |
1657
|
1
|
|
|
|
|
128
|
$have_name =~ tr/_A-Za-z0-9/_/c; |
1658
|
1
|
|
|
|
|
23
|
$have_name; |
1659
|
|
|
|
|
|
|
} |
1660
|
|
|
|
|
|
|
|
1661
|
|
|
|
|
|
|
sub check_builtin |
1662
|
|
|
|
|
|
|
{ |
1663
|
1
|
|
|
1
|
1
|
892
|
my ($self, $builtin) = @_; |
1664
|
1
|
|
|
|
|
12
|
$self = $self->_get_instance(); |
1665
|
1
|
|
|
|
|
3
|
my $options = {}; |
1666
|
1
|
50
|
33
|
|
|
6
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
1667
|
|
|
|
|
|
|
|
1668
|
|
|
|
|
|
|
# Build the name of the cache variable. |
1669
|
1
|
|
|
|
|
10
|
my $cache_name = $self->_cache_name('builtin', $builtin); |
1670
|
|
|
|
|
|
|
# Wrap the actual check in a closure so that we can use check_cached. |
1671
|
|
|
|
|
|
|
my $check_sub = sub { |
1672
|
|
|
|
|
|
|
my $have_builtin = $self->link_if_else( |
1673
|
|
|
|
|
|
|
$self->lang_builtin(q{}, $builtin), |
1674
|
|
|
|
|
|
|
{ |
1675
|
|
|
|
|
|
|
($options->{action_on_true} ? (action_on_true => $options->{action_on_true}) : ()), |
1676
|
1
|
50
|
|
1
|
|
25
|
($options->{action_on_false} ? (action_on_false => $options->{action_on_false}) : ()) |
|
|
50
|
|
|
|
|
|
1677
|
|
|
|
|
|
|
} |
1678
|
|
|
|
|
|
|
); |
1679
|
1
|
|
|
|
|
1016
|
$have_builtin; |
1680
|
1
|
|
|
|
|
19
|
}; |
1681
|
|
|
|
|
|
|
|
1682
|
|
|
|
|
|
|
# Run the check and cache the results. |
1683
|
|
|
|
|
|
|
return $self->check_cached( |
1684
|
|
|
|
|
|
|
$cache_name, |
1685
|
|
|
|
|
|
|
"for builtin $builtin", |
1686
|
|
|
|
|
|
|
$check_sub, |
1687
|
|
|
|
|
|
|
{ |
1688
|
|
|
|
|
|
|
action_on_true => sub { |
1689
|
0
|
|
|
0
|
|
0
|
$self->define_var( |
1690
|
|
|
|
|
|
|
_have_builtin_define_name($builtin), |
1691
|
|
|
|
|
|
|
$self->cache_val($cache_name), |
1692
|
|
|
|
|
|
|
"Defined when builtin $builtin is available" |
1693
|
|
|
|
|
|
|
); |
1694
|
|
|
|
|
|
|
$options->{action_on_cache_true} |
1695
|
|
|
|
|
|
|
and ref $options->{action_on_cache_true} eq "CODE" |
1696
|
0
|
0
|
0
|
|
|
0
|
and $options->{action_on_cache_true}->(); |
1697
|
|
|
|
|
|
|
}, |
1698
|
|
|
|
|
|
|
action_on_false => sub { |
1699
|
1
|
|
|
1
|
|
13
|
$self->define_var(_have_builtin_define_name($builtin), undef, "Defined when builtin $builtin is available"); |
1700
|
|
|
|
|
|
|
$options->{action_on_cache_false} |
1701
|
|
|
|
|
|
|
and ref $options->{action_on_cache_false} eq "CODE" |
1702
|
1
|
50
|
33
|
|
|
37
|
and $options->{action_on_cache_false}->(); |
1703
|
|
|
|
|
|
|
}, |
1704
|
|
|
|
|
|
|
} |
1705
|
1
|
|
|
|
|
37
|
); |
1706
|
|
|
|
|
|
|
} |
1707
|
|
|
|
|
|
|
|
1708
|
|
|
|
|
|
|
sub _have_type_define_name |
1709
|
|
|
|
|
|
|
{ |
1710
|
5
|
|
|
5
|
|
37
|
my $type = $_[0]; |
1711
|
5
|
|
|
|
|
53
|
my $have_name = "HAVE_" . uc($type); |
1712
|
5
|
|
|
|
|
25
|
$have_name =~ tr/*/P/; |
1713
|
5
|
|
|
|
|
17
|
$have_name =~ tr/_A-Za-z0-9/_/c; |
1714
|
5
|
|
|
|
|
47
|
$have_name; |
1715
|
|
|
|
|
|
|
} |
1716
|
|
|
|
|
|
|
|
1717
|
|
|
|
|
|
|
=head2 check_type( $symbol, \%options? ) |
1718
|
|
|
|
|
|
|
|
1719
|
|
|
|
|
|
|
Check whether type is defined. It may be a compiler builtin type or defined |
1720
|
|
|
|
|
|
|
by the includes. In C, type must be a type-name, so that the expression |
1721
|
|
|
|
|
|
|
C is valid (but C is not). |
1722
|
|
|
|
|
|
|
|
1723
|
|
|
|
|
|
|
If I type is defined, preprocessor macro HAVE_I (in all |
1724
|
|
|
|
|
|
|
capitals, with "*" replaced by "P" and spaces and dots replaced by |
1725
|
|
|
|
|
|
|
underscores) is defined. |
1726
|
|
|
|
|
|
|
|
1727
|
|
|
|
|
|
|
This method caches its result in the Ctype variable. |
1728
|
|
|
|
|
|
|
|
1729
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
1730
|
|
|
|
|
|
|
to I or I are executed, respectively. |
1731
|
|
|
|
|
|
|
When a I exists in the optional hash at end, it will be favored |
1732
|
|
|
|
|
|
|
over C (represented by L). If any of |
1733
|
|
|
|
|
|
|
I, I is defined, both callbacks |
1734
|
|
|
|
|
|
|
are passed to L as I or I to |
1735
|
|
|
|
|
|
|
C, respectively. |
1736
|
|
|
|
|
|
|
|
1737
|
|
|
|
|
|
|
=cut |
1738
|
|
|
|
|
|
|
|
1739
|
|
|
|
|
|
|
sub check_type |
1740
|
|
|
|
|
|
|
{ |
1741
|
5
|
|
|
5
|
1
|
361
|
my ($self, $type) = @_; |
1742
|
5
|
|
|
|
|
32
|
$self = $self->_get_instance(); |
1743
|
5
|
|
|
|
|
16
|
my $options = {}; |
1744
|
5
|
100
|
66
|
|
|
89
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
1745
|
|
|
|
|
|
|
|
1746
|
5
|
50
|
|
|
|
32
|
defined($type) or return croak("No type to check for"); |
1747
|
5
|
50
|
|
|
|
33
|
ref($type) eq "" or return croak("No type to check for"); |
1748
|
|
|
|
|
|
|
|
1749
|
5
|
|
|
|
|
47
|
my $cache_name = $self->_cache_type_name("type", $type); |
1750
|
|
|
|
|
|
|
my $check_sub = sub { |
1751
|
|
|
|
|
|
|
|
1752
|
4
|
|
|
4
|
|
17
|
my $body = <
|
1753
|
|
|
|
|
|
|
if( sizeof ($type) ) |
1754
|
|
|
|
|
|
|
return 0; |
1755
|
|
|
|
|
|
|
ACEOF |
1756
|
4
|
|
|
|
|
69
|
my $conftest = $self->lang_build_program($options->{prologue}, $body); |
1757
|
|
|
|
|
|
|
|
1758
|
|
|
|
|
|
|
my $have_type = $self->compile_if_else( |
1759
|
|
|
|
|
|
|
$conftest, |
1760
|
|
|
|
|
|
|
{ |
1761
|
|
|
|
|
|
|
($options->{action_on_true} ? (action_on_true => $options->{action_on_true}) : ()), |
1762
|
4
|
50
|
|
|
|
36
|
($options->{action_on_false} ? (action_on_false => $options->{action_on_false}) : ()) |
|
|
50
|
|
|
|
|
|
1763
|
|
|
|
|
|
|
} |
1764
|
|
|
|
|
|
|
); |
1765
|
4
|
|
|
|
|
4974
|
$have_type; |
1766
|
5
|
|
|
|
|
49
|
}; |
1767
|
|
|
|
|
|
|
|
1768
|
|
|
|
|
|
|
$self->check_cached( |
1769
|
|
|
|
|
|
|
$cache_name, |
1770
|
|
|
|
|
|
|
"for $type", |
1771
|
|
|
|
|
|
|
$check_sub, |
1772
|
|
|
|
|
|
|
{ |
1773
|
|
|
|
|
|
|
action_on_true => sub { |
1774
|
5
|
|
|
5
|
|
82
|
$self->define_var(_have_type_define_name($type), $self->cache_val($cache_name), |
1775
|
|
|
|
|
|
|
"defined when $type is available"); |
1776
|
|
|
|
|
|
|
$options->{action_on_cache_true} |
1777
|
|
|
|
|
|
|
and ref $options->{action_on_cache_true} eq "CODE" |
1778
|
5
|
50
|
33
|
|
|
44
|
and $options->{action_on_cache_true}->(); |
1779
|
|
|
|
|
|
|
}, |
1780
|
|
|
|
|
|
|
action_on_false => sub { |
1781
|
0
|
|
|
0
|
|
0
|
$self->define_var(_have_type_define_name($type), undef, "defined when $type is available"); |
1782
|
|
|
|
|
|
|
$options->{action_on_cache_false} |
1783
|
|
|
|
|
|
|
and ref $options->{action_on_cache_false} eq "CODE" |
1784
|
0
|
0
|
0
|
|
|
0
|
and $options->{action_on_cache_false}->(); |
1785
|
|
|
|
|
|
|
}, |
1786
|
|
|
|
|
|
|
} |
1787
|
5
|
|
|
|
|
104
|
); |
1788
|
|
|
|
|
|
|
} |
1789
|
|
|
|
|
|
|
|
1790
|
|
|
|
|
|
|
=head2 check_types( \@type-list, \%options? ) |
1791
|
|
|
|
|
|
|
|
1792
|
|
|
|
|
|
|
For each type in I<@type-list>, call L is called to check |
1793
|
|
|
|
|
|
|
for type and return the accumulated result (accumulation op is binary and). |
1794
|
|
|
|
|
|
|
|
1795
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
1796
|
|
|
|
|
|
|
to I or I are executed, respectively. |
1797
|
|
|
|
|
|
|
When a I exists in the optional hash at end, it will be favored |
1798
|
|
|
|
|
|
|
over C (represented by L). If any of |
1799
|
|
|
|
|
|
|
I, I is defined, both callbacks |
1800
|
|
|
|
|
|
|
are passed to L as I or I to |
1801
|
|
|
|
|
|
|
C, respectively. |
1802
|
|
|
|
|
|
|
Given callbacks for I or I are |
1803
|
|
|
|
|
|
|
called for each symbol checked using L receiving the symbol as |
1804
|
|
|
|
|
|
|
first argument. |
1805
|
|
|
|
|
|
|
|
1806
|
|
|
|
|
|
|
=cut |
1807
|
|
|
|
|
|
|
|
1808
|
|
|
|
|
|
|
sub check_types |
1809
|
|
|
|
|
|
|
{ |
1810
|
1
|
|
|
1
|
1
|
5
|
my ($self, $types) = @_; |
1811
|
1
|
|
|
|
|
9
|
$self = $self->_get_instance(); |
1812
|
1
|
|
|
|
|
7
|
my $options = {}; |
1813
|
1
|
50
|
33
|
|
|
24
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
1814
|
|
|
|
|
|
|
|
1815
|
1
|
|
|
|
|
7
|
my %pass_options; |
1816
|
1
|
50
|
|
|
|
12
|
defined $options->{prologue} and $pass_options{prologue} = $options->{prologue}; |
1817
|
1
|
50
|
|
|
|
18
|
defined $options->{action_on_cache_true} and $pass_options{action_on_cache_true} = $options->{action_on_cache_true}; |
1818
|
1
|
50
|
|
|
|
14
|
defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false}; |
1819
|
|
|
|
|
|
|
|
1820
|
1
|
|
|
|
|
3
|
my $have_types = 1; |
1821
|
1
|
|
|
|
|
11
|
foreach my $type (@$types) |
1822
|
|
|
|
|
|
|
{ |
1823
|
|
|
|
|
|
|
$have_types &= $self->check_type( |
1824
|
|
|
|
|
|
|
$type, |
1825
|
|
|
|
|
|
|
{ |
1826
|
|
|
|
|
|
|
%pass_options, |
1827
|
|
|
|
|
|
|
( |
1828
|
|
|
|
|
|
|
$options->{action_on_type_true} && "CODE" eq ref $options->{action_on_type_true} |
1829
|
0
|
|
|
0
|
|
0
|
? (action_on_true => sub { $options->{action_on_type_true}->($type) }) |
1830
|
|
|
|
|
|
|
: () |
1831
|
|
|
|
|
|
|
), |
1832
|
|
|
|
|
|
|
( |
1833
|
|
|
|
|
|
|
$options->{action_on_type_false} && "CODE" eq ref $options->{action_on_type_false} |
1834
|
0
|
|
|
0
|
|
0
|
? (action_on_false => sub { $options->{action_on_type_false}->($type) }) |
1835
|
3
|
50
|
33
|
|
|
74
|
: () |
|
|
50
|
33
|
|
|
|
|
1836
|
|
|
|
|
|
|
), |
1837
|
|
|
|
|
|
|
} |
1838
|
|
|
|
|
|
|
); |
1839
|
|
|
|
|
|
|
} |
1840
|
|
|
|
|
|
|
|
1841
|
|
|
|
|
|
|
$have_types |
1842
|
|
|
|
|
|
|
and $options->{action_on_true} |
1843
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
1844
|
1
|
50
|
33
|
|
|
32
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
1845
|
|
|
|
|
|
|
|
1846
|
|
|
|
|
|
|
$options->{action_on_false} |
1847
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
1848
|
|
|
|
|
|
|
and !$have_types |
1849
|
1
|
0
|
33
|
|
|
25
|
and $options->{action_on_false}->(); |
|
|
|
33
|
|
|
|
|
1850
|
|
|
|
|
|
|
|
1851
|
1
|
|
|
|
|
42
|
$have_types; |
1852
|
|
|
|
|
|
|
} |
1853
|
|
|
|
|
|
|
|
1854
|
|
|
|
|
|
|
sub _compute_int_compile |
1855
|
|
|
|
|
|
|
{ |
1856
|
11
|
|
|
11
|
|
73
|
my ($self, $expr, $prologue, @decls) = @_; |
1857
|
11
|
|
|
|
|
37
|
$self = $self->_get_instance(); |
1858
|
|
|
|
|
|
|
|
1859
|
11
|
|
|
|
|
37
|
my ($body, $conftest, $compile_result); |
1860
|
|
|
|
|
|
|
|
1861
|
11
|
|
|
|
|
38
|
my ($low, $mid, $high) = (0, 0, 0); |
1862
|
11
|
100
|
|
|
|
189
|
if ($self->compile_if_else($self->lang_build_bool_test($prologue, "((long int)($expr)) >= 0", @decls))) |
|
|
50
|
|
|
|
|
|
1863
|
|
|
|
|
|
|
{ |
1864
|
10
|
|
|
|
|
14051
|
$low = $mid = 0; |
1865
|
10
|
|
|
|
|
42
|
while (1) |
1866
|
|
|
|
|
|
|
{ |
1867
|
37
|
100
|
|
|
|
1044
|
if ($self->compile_if_else($self->lang_build_bool_test($prologue, "((long int)($expr)) <= $mid", @decls))) |
1868
|
|
|
|
|
|
|
{ |
1869
|
10
|
|
|
|
|
13597
|
$high = $mid; |
1870
|
10
|
|
|
|
|
71
|
last; |
1871
|
|
|
|
|
|
|
} |
1872
|
27
|
|
|
|
|
36277
|
$low = $mid + 1; |
1873
|
|
|
|
|
|
|
# avoid overflow |
1874
|
27
|
50
|
|
|
|
195
|
if ($low <= $mid) |
1875
|
|
|
|
|
|
|
{ |
1876
|
0
|
|
|
|
|
0
|
$low = 0; |
1877
|
0
|
|
|
|
|
0
|
last; |
1878
|
|
|
|
|
|
|
} |
1879
|
27
|
|
|
|
|
118
|
$mid = $low * 2; |
1880
|
|
|
|
|
|
|
} |
1881
|
|
|
|
|
|
|
} |
1882
|
|
|
|
|
|
|
elsif ($self->compile_if_else($self->lang_build_bool_test($prologue, "((long int)($expr)) < 0", @decls))) |
1883
|
|
|
|
|
|
|
{ |
1884
|
1
|
|
|
|
|
1363
|
$high = $mid = -1; |
1885
|
1
|
|
|
|
|
4
|
while (1) |
1886
|
|
|
|
|
|
|
{ |
1887
|
2
|
100
|
|
|
|
70
|
if ($self->compile_if_else($self->lang_build_bool_test($prologue, "((long int)($expr)) >= $mid", @decls))) |
1888
|
|
|
|
|
|
|
{ |
1889
|
1
|
|
|
|
|
1227
|
$low = $mid; |
1890
|
1
|
|
|
|
|
10
|
last; |
1891
|
|
|
|
|
|
|
} |
1892
|
1
|
|
|
|
|
1149
|
$high = $mid - 1; |
1893
|
|
|
|
|
|
|
# avoid overflow |
1894
|
1
|
50
|
|
|
|
16
|
if ($mid < $high) |
1895
|
|
|
|
|
|
|
{ |
1896
|
0
|
|
|
|
|
0
|
$high = 0; |
1897
|
0
|
|
|
|
|
0
|
last; |
1898
|
|
|
|
|
|
|
} |
1899
|
1
|
|
|
|
|
15
|
$mid = $high * 2; |
1900
|
|
|
|
|
|
|
} |
1901
|
|
|
|
|
|
|
} |
1902
|
|
|
|
|
|
|
|
1903
|
|
|
|
|
|
|
# perform binary search between $low and $high |
1904
|
11
|
|
|
|
|
151
|
while ($low <= $high) |
1905
|
|
|
|
|
|
|
{ |
1906
|
19
|
|
|
|
|
232
|
$mid = int(($high - $low) / 2 + $low); |
1907
|
19
|
100
|
|
|
|
438
|
if ($self->compile_if_else($self->lang_build_bool_test($prologue, "((long int)($expr)) < $mid", @decls))) |
|
|
100
|
|
|
|
|
|
1908
|
|
|
|
|
|
|
{ |
1909
|
7
|
|
|
|
|
8334
|
$high = $mid - 1; |
1910
|
|
|
|
|
|
|
} |
1911
|
|
|
|
|
|
|
elsif ($self->compile_if_else($self->lang_build_bool_test($prologue, "((long int)($expr)) > $mid", @decls))) |
1912
|
|
|
|
|
|
|
{ |
1913
|
1
|
|
|
|
|
1060
|
$low = $mid + 1; |
1914
|
|
|
|
|
|
|
} |
1915
|
|
|
|
|
|
|
else |
1916
|
|
|
|
|
|
|
{ |
1917
|
11
|
|
|
|
|
13705
|
return $mid; |
1918
|
|
|
|
|
|
|
} |
1919
|
|
|
|
|
|
|
} |
1920
|
|
|
|
|
|
|
|
1921
|
0
|
|
|
|
|
0
|
return; |
1922
|
|
|
|
|
|
|
} |
1923
|
|
|
|
|
|
|
|
1924
|
|
|
|
|
|
|
=head2 compute_int( $expression, @decls?, \%options ) |
1925
|
|
|
|
|
|
|
|
1926
|
|
|
|
|
|
|
Returns the value of the integer I. The value should fit in an |
1927
|
|
|
|
|
|
|
initializer in a C variable of type signed long. It should be possible |
1928
|
|
|
|
|
|
|
to evaluate the expression at compile-time. If no includes are specified, |
1929
|
|
|
|
|
|
|
the default includes are used. |
1930
|
|
|
|
|
|
|
|
1931
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
1932
|
|
|
|
|
|
|
to I or I are executed, respectively. |
1933
|
|
|
|
|
|
|
When a I exists in the optional hash at end, it will be favored |
1934
|
|
|
|
|
|
|
over C (represented by L). If any of |
1935
|
|
|
|
|
|
|
I, I is defined, both callbacks |
1936
|
|
|
|
|
|
|
are passed to L as I or I to |
1937
|
|
|
|
|
|
|
C, respectively. |
1938
|
|
|
|
|
|
|
|
1939
|
|
|
|
|
|
|
=cut |
1940
|
|
|
|
|
|
|
|
1941
|
|
|
|
|
|
|
sub _expr_value_define_name |
1942
|
|
|
|
|
|
|
{ |
1943
|
1
|
|
|
1
|
|
8
|
my $expr = $_[0]; |
1944
|
1
|
|
|
|
|
11
|
my $have_name = "EXPR_" . uc($expr); |
1945
|
1
|
|
|
|
|
5
|
$have_name =~ tr/*/P/; |
1946
|
1
|
|
|
|
|
5
|
$have_name =~ tr/_A-Za-z0-9/_/c; |
1947
|
1
|
|
|
|
|
18
|
$have_name; |
1948
|
|
|
|
|
|
|
} |
1949
|
|
|
|
|
|
|
|
1950
|
|
|
|
|
|
|
sub compute_int |
1951
|
|
|
|
|
|
|
{ |
1952
|
1
|
|
|
1
|
1
|
7
|
my $options = {}; |
1953
|
1
|
50
|
33
|
|
|
18
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
1954
|
1
|
|
|
|
|
12
|
my ($self, $expr, @decls) = @_; |
1955
|
1
|
|
|
|
|
10
|
$self = $self->_get_instance(); |
1956
|
|
|
|
|
|
|
|
1957
|
1
|
|
|
|
|
11
|
my $cache_name = $self->_cache_type_name("compute_int", $self->{lang}, $expr); |
1958
|
|
|
|
|
|
|
my $check_sub = sub { |
1959
|
1
|
|
|
1
|
|
18
|
my $val = $self->_compute_int_compile($expr, $options->{prologue}, @decls); |
1960
|
|
|
|
|
|
|
|
1961
|
|
|
|
|
|
|
defined $val |
1962
|
|
|
|
|
|
|
and $options->{action_on_true} |
1963
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
1964
|
1
|
50
|
33
|
|
|
54
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
1965
|
|
|
|
|
|
|
|
1966
|
|
|
|
|
|
|
$options->{action_on_false} |
1967
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
1968
|
|
|
|
|
|
|
and !defined $val |
1969
|
1
|
0
|
33
|
|
|
24
|
and $options->{action_on_false}->(); |
|
|
|
33
|
|
|
|
|
1970
|
|
|
|
|
|
|
|
1971
|
1
|
|
|
|
|
22
|
$val; |
1972
|
1
|
|
|
|
|
20
|
}; |
1973
|
|
|
|
|
|
|
|
1974
|
|
|
|
|
|
|
$self->check_cached( |
1975
|
|
|
|
|
|
|
$cache_name, |
1976
|
|
|
|
|
|
|
"for compute result of ($expr)", |
1977
|
|
|
|
|
|
|
$check_sub, |
1978
|
|
|
|
|
|
|
{ |
1979
|
|
|
|
|
|
|
action_on_true => sub { |
1980
|
1
|
|
|
1
|
|
14
|
$self->define_var( |
1981
|
|
|
|
|
|
|
_expr_value_define_name($expr), |
1982
|
|
|
|
|
|
|
$self->cache_val($cache_name), |
1983
|
|
|
|
|
|
|
"defined when ($expr) could computed" |
1984
|
|
|
|
|
|
|
); |
1985
|
|
|
|
|
|
|
$options->{action_on_cache_true} |
1986
|
|
|
|
|
|
|
and ref $options->{action_on_cache_true} eq "CODE" |
1987
|
1
|
50
|
33
|
|
|
12
|
and $options->{action_on_cache_true}->(); |
1988
|
|
|
|
|
|
|
}, |
1989
|
|
|
|
|
|
|
action_on_false => sub { |
1990
|
0
|
|
|
0
|
|
0
|
$self->define_var(_expr_value_define_name($expr), undef, "defined when ($expr) could computed"); |
1991
|
|
|
|
|
|
|
$options->{action_on_cache_false} |
1992
|
|
|
|
|
|
|
and ref $options->{action_on_cache_false} eq "CODE" |
1993
|
0
|
0
|
0
|
|
|
0
|
and $options->{action_on_cache_false}->(); |
1994
|
|
|
|
|
|
|
}, |
1995
|
|
|
|
|
|
|
} |
1996
|
1
|
|
|
|
|
34
|
); |
1997
|
|
|
|
|
|
|
} |
1998
|
|
|
|
|
|
|
|
1999
|
|
|
|
|
|
|
=head2 check_sizeof_type( $type, \%options? ) |
2000
|
|
|
|
|
|
|
|
2001
|
|
|
|
|
|
|
Checks for the size of the specified type by compiling and define |
2002
|
|
|
|
|
|
|
C using the determined size. |
2003
|
|
|
|
|
|
|
|
2004
|
|
|
|
|
|
|
In opposition to GNU AutoConf, this method can determine size of structure |
2005
|
|
|
|
|
|
|
members, e.g. |
2006
|
|
|
|
|
|
|
|
2007
|
|
|
|
|
|
|
$ac->check_sizeof_type( "SV.sv_refcnt", { prologue => $include_perl } ); |
2008
|
|
|
|
|
|
|
# or |
2009
|
|
|
|
|
|
|
$ac->check_sizeof_type( "struct utmpx.ut_id", { prologue => "#include " } ); |
2010
|
|
|
|
|
|
|
|
2011
|
|
|
|
|
|
|
This method caches its result in the Cset langE>_type variable. |
2012
|
|
|
|
|
|
|
|
2013
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
2014
|
|
|
|
|
|
|
to I or I are executed, respectively. |
2015
|
|
|
|
|
|
|
When a I exists in the optional hash at end, it will be favored |
2016
|
|
|
|
|
|
|
over C (represented by L). If any of |
2017
|
|
|
|
|
|
|
I, I is defined, both callbacks |
2018
|
|
|
|
|
|
|
are passed to L as I or I to |
2019
|
|
|
|
|
|
|
C, respectively. |
2020
|
|
|
|
|
|
|
|
2021
|
|
|
|
|
|
|
=cut |
2022
|
|
|
|
|
|
|
|
2023
|
|
|
|
|
|
|
sub _sizeof_type_define_name |
2024
|
|
|
|
|
|
|
{ |
2025
|
6
|
|
|
6
|
|
41
|
my $type = $_[0]; |
2026
|
6
|
|
|
|
|
39
|
my $have_name = "SIZEOF_" . uc($type); |
2027
|
6
|
|
|
|
|
28
|
$have_name =~ tr/*/P/; |
2028
|
6
|
|
|
|
|
20
|
$have_name =~ tr/_A-Za-z0-9/_/c; |
2029
|
6
|
|
|
|
|
68
|
$have_name; |
2030
|
|
|
|
|
|
|
} |
2031
|
|
|
|
|
|
|
|
2032
|
|
|
|
|
|
|
sub check_sizeof_type |
2033
|
|
|
|
|
|
|
{ |
2034
|
6
|
|
|
6
|
1
|
18
|
my $options = {}; |
2035
|
6
|
50
|
33
|
|
|
99
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
2036
|
6
|
|
|
|
|
39
|
my ($self, $type) = @_; |
2037
|
6
|
|
|
|
|
27
|
$self = $self->_get_instance(); |
2038
|
6
|
50
|
|
|
|
31
|
defined($type) or return croak("No type to check for"); |
2039
|
6
|
50
|
|
|
|
26
|
ref($type) eq "" or return croak("No type to check for"); |
2040
|
|
|
|
|
|
|
|
2041
|
6
|
|
|
|
|
61
|
my $cache_name = $self->_cache_type_name("sizeof", $self->{lang}, $type); |
2042
|
|
|
|
|
|
|
my $check_sub = sub { |
2043
|
5
|
|
|
5
|
|
18
|
my @decls; |
2044
|
5
|
100
|
|
|
|
74
|
if ($type =~ m/^([^.]+)\.([^.]+)$/) |
2045
|
|
|
|
|
|
|
{ |
2046
|
1
|
|
|
|
|
23
|
my $struct = $1; |
2047
|
1
|
|
|
|
|
28
|
$type = "_ac_test_aggr.$2"; |
2048
|
1
|
|
|
|
|
7
|
my $decl = "static $struct _ac_test_aggr;"; |
2049
|
1
|
|
|
|
|
13
|
push(@decls, $decl); |
2050
|
|
|
|
|
|
|
} |
2051
|
|
|
|
|
|
|
|
2052
|
5
|
|
|
|
|
39
|
my $typesize = $self->_compute_int_compile("sizeof($type)", $options->{prologue}, @decls); |
2053
|
|
|
|
|
|
|
|
2054
|
|
|
|
|
|
|
$typesize |
2055
|
|
|
|
|
|
|
and $options->{action_on_true} |
2056
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
2057
|
5
|
50
|
33
|
|
|
138
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
2058
|
|
|
|
|
|
|
|
2059
|
|
|
|
|
|
|
$options->{action_on_false} |
2060
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
2061
|
|
|
|
|
|
|
and !$typesize |
2062
|
5
|
0
|
33
|
|
|
45
|
and $options->{action_on_false}->(); |
|
|
|
33
|
|
|
|
|
2063
|
|
|
|
|
|
|
|
2064
|
5
|
|
|
|
|
140
|
$typesize; |
2065
|
6
|
|
|
|
|
67
|
}; |
2066
|
|
|
|
|
|
|
|
2067
|
|
|
|
|
|
|
$self->check_cached( |
2068
|
|
|
|
|
|
|
$cache_name, |
2069
|
|
|
|
|
|
|
"for size of $type", |
2070
|
|
|
|
|
|
|
$check_sub, |
2071
|
|
|
|
|
|
|
{ |
2072
|
|
|
|
|
|
|
action_on_true => sub { |
2073
|
6
|
|
|
6
|
|
78
|
$self->define_var( |
2074
|
|
|
|
|
|
|
_sizeof_type_define_name($type), |
2075
|
|
|
|
|
|
|
$self->cache_val($cache_name), |
2076
|
|
|
|
|
|
|
"defined when sizeof($type) is available" |
2077
|
|
|
|
|
|
|
); |
2078
|
|
|
|
|
|
|
$options->{action_on_cache_true} |
2079
|
|
|
|
|
|
|
and ref $options->{action_on_cache_true} eq "CODE" |
2080
|
6
|
50
|
33
|
|
|
38
|
and $options->{action_on_cache_true}->(); |
2081
|
|
|
|
|
|
|
}, |
2082
|
|
|
|
|
|
|
action_on_false => sub { |
2083
|
0
|
|
|
0
|
|
0
|
$self->define_var(_sizeof_type_define_name($type), undef, "defined when sizeof($type) is available"); |
2084
|
|
|
|
|
|
|
$options->{action_on_cache_false} |
2085
|
|
|
|
|
|
|
and ref $options->{action_on_cache_false} eq "CODE" |
2086
|
0
|
0
|
0
|
|
|
0
|
and $options->{action_on_cache_false}->(); |
2087
|
|
|
|
|
|
|
}, |
2088
|
|
|
|
|
|
|
} |
2089
|
6
|
|
|
|
|
100
|
); |
2090
|
|
|
|
|
|
|
} |
2091
|
|
|
|
|
|
|
|
2092
|
|
|
|
|
|
|
=head2 check_sizeof_types( type, \%options? ) |
2093
|
|
|
|
|
|
|
|
2094
|
|
|
|
|
|
|
For each type L is called to check for size of type. |
2095
|
|
|
|
|
|
|
|
2096
|
|
|
|
|
|
|
If I is given, it is additionally executed when all of the |
2097
|
|
|
|
|
|
|
sizes of the types could determined. If I is given, it |
2098
|
|
|
|
|
|
|
is executed when one size of the types could not determined. |
2099
|
|
|
|
|
|
|
|
2100
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
2101
|
|
|
|
|
|
|
to I or I are executed, respectively. |
2102
|
|
|
|
|
|
|
When a I exists in the optional hash at end, it will be favored |
2103
|
|
|
|
|
|
|
over C (represented by L). If any of |
2104
|
|
|
|
|
|
|
I, I is defined, both callbacks |
2105
|
|
|
|
|
|
|
are passed to L as I or I to |
2106
|
|
|
|
|
|
|
C, respectively. |
2107
|
|
|
|
|
|
|
Given callbacks for I or I are |
2108
|
|
|
|
|
|
|
called for each symbol checked using L receiving the |
2109
|
|
|
|
|
|
|
symbol as first argument. |
2110
|
|
|
|
|
|
|
|
2111
|
|
|
|
|
|
|
=cut |
2112
|
|
|
|
|
|
|
|
2113
|
|
|
|
|
|
|
sub check_sizeof_types |
2114
|
|
|
|
|
|
|
{ |
2115
|
1
|
|
|
1
|
1
|
1062
|
my $options = {}; |
2116
|
1
|
50
|
33
|
|
|
19
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
2117
|
1
|
|
|
|
|
3
|
my ($self, $types) = @_; |
2118
|
1
|
|
|
|
|
14
|
$self = $self->_get_instance(); |
2119
|
|
|
|
|
|
|
|
2120
|
1
|
|
|
|
|
3
|
my %pass_options; |
2121
|
1
|
50
|
|
|
|
5
|
defined $options->{prologue} and $pass_options{prologue} = $options->{prologue}; |
2122
|
1
|
50
|
|
|
|
130
|
defined $options->{action_on_cache_true} and $pass_options{action_on_cache_true} = $options->{action_on_cache_true}; |
2123
|
1
|
50
|
|
|
|
4
|
defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false}; |
2124
|
|
|
|
|
|
|
|
2125
|
1
|
|
|
|
|
27
|
my $have_sizes = 1; |
2126
|
1
|
|
|
|
|
9
|
foreach my $type (@$types) |
2127
|
|
|
|
|
|
|
{ |
2128
|
|
|
|
|
|
|
$have_sizes &= !!( |
2129
|
|
|
|
|
|
|
$self->check_sizeof_type( |
2130
|
|
|
|
|
|
|
$type, |
2131
|
|
|
|
|
|
|
{ |
2132
|
|
|
|
|
|
|
%pass_options, |
2133
|
|
|
|
|
|
|
( |
2134
|
|
|
|
|
|
|
$options->{action_on_size_true} && "CODE" eq ref $options->{action_on_size_true} |
2135
|
0
|
|
|
0
|
|
0
|
? (action_on_true => sub { $options->{action_on_size_true}->($type) }) |
2136
|
|
|
|
|
|
|
: () |
2137
|
|
|
|
|
|
|
), |
2138
|
|
|
|
|
|
|
( |
2139
|
|
|
|
|
|
|
$options->{action_on_size_false} && "CODE" eq ref $options->{action_on_size_false} |
2140
|
0
|
|
|
0
|
|
0
|
? (action_on_false => sub { $options->{action_on_size_false}->($type) }) |
2141
|
5
|
50
|
33
|
|
|
87
|
: () |
|
|
50
|
33
|
|
|
|
|
2142
|
|
|
|
|
|
|
), |
2143
|
|
|
|
|
|
|
} |
2144
|
|
|
|
|
|
|
) |
2145
|
|
|
|
|
|
|
); |
2146
|
|
|
|
|
|
|
} |
2147
|
|
|
|
|
|
|
|
2148
|
|
|
|
|
|
|
$have_sizes |
2149
|
|
|
|
|
|
|
and $options->{action_on_true} |
2150
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
2151
|
1
|
50
|
33
|
|
|
34
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
2152
|
|
|
|
|
|
|
|
2153
|
|
|
|
|
|
|
$options->{action_on_false} |
2154
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
2155
|
|
|
|
|
|
|
and !$have_sizes |
2156
|
1
|
0
|
33
|
|
|
23
|
and $options->{action_on_false}->(); |
|
|
|
33
|
|
|
|
|
2157
|
|
|
|
|
|
|
|
2158
|
1
|
|
|
|
|
37
|
$have_sizes; |
2159
|
|
|
|
|
|
|
} |
2160
|
|
|
|
|
|
|
|
2161
|
|
|
|
|
|
|
sub _alignof_type_define_name |
2162
|
|
|
|
|
|
|
{ |
2163
|
7
|
|
|
7
|
|
46
|
my $type = $_[0]; |
2164
|
7
|
|
|
|
|
42
|
my $have_name = "ALIGNOF_" . uc($type); |
2165
|
7
|
|
|
|
|
34
|
$have_name =~ tr/*/P/; |
2166
|
7
|
|
|
|
|
37
|
$have_name =~ tr/_A-Za-z0-9/_/c; |
2167
|
7
|
|
|
|
|
72
|
$have_name; |
2168
|
|
|
|
|
|
|
} |
2169
|
|
|
|
|
|
|
|
2170
|
|
|
|
|
|
|
=head2 check_alignof_type( type, \%options? ) |
2171
|
|
|
|
|
|
|
|
2172
|
|
|
|
|
|
|
Define ALIGNOF_type to be the alignment in bytes of type. I must |
2173
|
|
|
|
|
|
|
be valid as a structure member declaration or I must be a structure |
2174
|
|
|
|
|
|
|
member itself. |
2175
|
|
|
|
|
|
|
|
2176
|
|
|
|
|
|
|
This method caches its result in the Cset langE>_type |
2177
|
|
|
|
|
|
|
variable, with I<*> mapped to C and other characters not suitable for a |
2178
|
|
|
|
|
|
|
variable name mapped to underscores. |
2179
|
|
|
|
|
|
|
|
2180
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
2181
|
|
|
|
|
|
|
to I or I are executed, respectively. |
2182
|
|
|
|
|
|
|
When a I exists in the optional hash at end, it will be favored |
2183
|
|
|
|
|
|
|
over C (represented by L). If any of |
2184
|
|
|
|
|
|
|
I, I is defined, both callbacks |
2185
|
|
|
|
|
|
|
are passed to L as I or I to |
2186
|
|
|
|
|
|
|
C, respectively. |
2187
|
|
|
|
|
|
|
|
2188
|
|
|
|
|
|
|
=cut |
2189
|
|
|
|
|
|
|
|
2190
|
|
|
|
|
|
|
sub check_alignof_type |
2191
|
|
|
|
|
|
|
{ |
2192
|
7
|
|
|
7
|
1
|
28
|
my $options = {}; |
2193
|
7
|
50
|
33
|
|
|
90
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
2194
|
7
|
|
|
|
|
40
|
my ($self, $type) = @_; |
2195
|
7
|
|
|
|
|
34
|
$self = $self->_get_instance(); |
2196
|
7
|
50
|
|
|
|
36
|
defined($type) or return croak("No type to check for"); |
2197
|
7
|
50
|
|
|
|
34
|
ref($type) eq "" or return croak("No type to check for"); |
2198
|
|
|
|
|
|
|
|
2199
|
7
|
|
|
|
|
82
|
my $cache_name = $self->_cache_type_name("alignof", $self->{lang}, $type); |
2200
|
|
|
|
|
|
|
my $check_sub = sub { |
2201
|
5
|
|
|
5
|
|
29
|
my @decls = ( |
2202
|
|
|
|
|
|
|
"#ifndef offsetof", |
2203
|
|
|
|
|
|
|
"# ifdef __ICC", |
2204
|
|
|
|
|
|
|
"# define offsetof(type,memb) ((size_t)(((char *)(&((type*)0)->memb)) - ((char *)0)))", |
2205
|
|
|
|
|
|
|
"# else", "# define offsetof(type,memb) ((size_t)&((type*)0)->memb)", |
2206
|
|
|
|
|
|
|
"# endif", "#endif" |
2207
|
|
|
|
|
|
|
); |
2208
|
|
|
|
|
|
|
|
2209
|
5
|
|
|
|
|
16
|
my ($struct, $memb); |
2210
|
5
|
100
|
|
|
|
88
|
if ($type =~ m/^([^.]+)\.([^.]+)$/) |
2211
|
|
|
|
|
|
|
{ |
2212
|
1
|
|
|
|
|
6
|
$struct = $1; |
2213
|
1
|
|
|
|
|
14
|
$memb = $2; |
2214
|
|
|
|
|
|
|
} |
2215
|
|
|
|
|
|
|
else |
2216
|
|
|
|
|
|
|
{ |
2217
|
4
|
|
|
|
|
21
|
push(@decls, "typedef struct { char x; $type y; } ac__type_alignof_;"); |
2218
|
4
|
|
|
|
|
14
|
$struct = "ac__type_alignof_"; |
2219
|
4
|
|
|
|
|
22
|
$memb = "y"; |
2220
|
|
|
|
|
|
|
} |
2221
|
|
|
|
|
|
|
|
2222
|
5
|
|
|
|
|
45
|
my $typealign = $self->_compute_int_compile("offsetof($struct, $memb)", $options->{prologue}, @decls); |
2223
|
|
|
|
|
|
|
|
2224
|
|
|
|
|
|
|
$typealign |
2225
|
|
|
|
|
|
|
and $options->{action_on_true} |
2226
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
2227
|
5
|
50
|
33
|
|
|
156
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
2228
|
|
|
|
|
|
|
|
2229
|
|
|
|
|
|
|
$options->{action_on_false} |
2230
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
2231
|
|
|
|
|
|
|
and !$typealign |
2232
|
5
|
0
|
33
|
|
|
40
|
and $options->{action_on_false}->(); |
|
|
|
33
|
|
|
|
|
2233
|
|
|
|
|
|
|
|
2234
|
5
|
|
|
|
|
152
|
$typealign; |
2235
|
7
|
|
|
|
|
86
|
}; |
2236
|
|
|
|
|
|
|
|
2237
|
|
|
|
|
|
|
$self->check_cached( |
2238
|
|
|
|
|
|
|
$cache_name, |
2239
|
|
|
|
|
|
|
"for align of $type", |
2240
|
|
|
|
|
|
|
$check_sub, |
2241
|
|
|
|
|
|
|
{ |
2242
|
|
|
|
|
|
|
action_on_true => sub { |
2243
|
7
|
|
|
7
|
|
102
|
$self->define_var( |
2244
|
|
|
|
|
|
|
_alignof_type_define_name($type), |
2245
|
|
|
|
|
|
|
$self->cache_val($cache_name), |
2246
|
|
|
|
|
|
|
"defined when alignof($type) is available" |
2247
|
|
|
|
|
|
|
); |
2248
|
|
|
|
|
|
|
$options->{action_on_cache_true} |
2249
|
|
|
|
|
|
|
and ref $options->{action_on_cache_true} eq "CODE" |
2250
|
7
|
50
|
33
|
|
|
53
|
and $options->{action_on_cache_true}->(); |
2251
|
|
|
|
|
|
|
}, |
2252
|
|
|
|
|
|
|
action_on_false => sub { |
2253
|
0
|
|
|
0
|
|
0
|
$self->define_var(_alignof_type_define_name($type), undef, "defined when alignof($type) is available"); |
2254
|
|
|
|
|
|
|
$options->{action_on_cache_false} |
2255
|
|
|
|
|
|
|
and ref $options->{action_on_cache_false} eq "CODE" |
2256
|
0
|
0
|
0
|
|
|
0
|
and $options->{action_on_cache_false}->(); |
2257
|
|
|
|
|
|
|
}, |
2258
|
|
|
|
|
|
|
} |
2259
|
7
|
|
|
|
|
133
|
); |
2260
|
|
|
|
|
|
|
} |
2261
|
|
|
|
|
|
|
|
2262
|
|
|
|
|
|
|
=head2 check_alignof_types (type, [action-if-found], [action-if-not-found], [prologue = default includes]) |
2263
|
|
|
|
|
|
|
|
2264
|
|
|
|
|
|
|
For each type L is called to check for align of type. |
2265
|
|
|
|
|
|
|
|
2266
|
|
|
|
|
|
|
If I is given, it is additionally executed when all of the |
2267
|
|
|
|
|
|
|
aligns of the types could determined. If I is given, it |
2268
|
|
|
|
|
|
|
is executed when one align of the types could not determined. |
2269
|
|
|
|
|
|
|
|
2270
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
2271
|
|
|
|
|
|
|
to I or I are executed, respectively. |
2272
|
|
|
|
|
|
|
When a I exists in the optional hash at end, it will be favored |
2273
|
|
|
|
|
|
|
over C (represented by L). If any of |
2274
|
|
|
|
|
|
|
I, I is defined, both callbacks |
2275
|
|
|
|
|
|
|
are passed to L as I or I to |
2276
|
|
|
|
|
|
|
C, respectively. |
2277
|
|
|
|
|
|
|
Given callbacks for I or I are |
2278
|
|
|
|
|
|
|
called for each symbol checked using L receiving the |
2279
|
|
|
|
|
|
|
symbol as first argument. |
2280
|
|
|
|
|
|
|
|
2281
|
|
|
|
|
|
|
=cut |
2282
|
|
|
|
|
|
|
|
2283
|
|
|
|
|
|
|
sub check_alignof_types |
2284
|
|
|
|
|
|
|
{ |
2285
|
1
|
|
|
1
|
1
|
9
|
my $options = {}; |
2286
|
1
|
50
|
33
|
|
|
27
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
2287
|
1
|
|
|
|
|
11
|
my ($self, $types) = @_; |
2288
|
1
|
|
|
|
|
13
|
$self = $self->_get_instance(); |
2289
|
|
|
|
|
|
|
|
2290
|
1
|
|
|
|
|
7
|
my %pass_options; |
2291
|
1
|
50
|
|
|
|
15
|
defined $options->{prologue} and $pass_options{prologue} = $options->{prologue}; |
2292
|
1
|
50
|
|
|
|
9
|
defined $options->{action_on_cache_true} and $pass_options{action_on_cache_true} = $options->{action_on_cache_true}; |
2293
|
1
|
50
|
|
|
|
9
|
defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false}; |
2294
|
|
|
|
|
|
|
|
2295
|
1
|
|
|
|
|
3
|
my $have_aligns = 1; |
2296
|
1
|
|
|
|
|
12
|
foreach my $type (@$types) |
2297
|
|
|
|
|
|
|
{ |
2298
|
|
|
|
|
|
|
$have_aligns &= !!( |
2299
|
|
|
|
|
|
|
$self->check_alignof_type( |
2300
|
|
|
|
|
|
|
$type, |
2301
|
|
|
|
|
|
|
{ |
2302
|
|
|
|
|
|
|
%pass_options, |
2303
|
|
|
|
|
|
|
( |
2304
|
|
|
|
|
|
|
$options->{action_on_align_true} && "CODE" eq ref $options->{action_on_align_true} |
2305
|
0
|
|
|
0
|
|
0
|
? (action_on_true => sub { $options->{action_on_align_true}->($type) }) |
2306
|
|
|
|
|
|
|
: () |
2307
|
|
|
|
|
|
|
), |
2308
|
|
|
|
|
|
|
( |
2309
|
|
|
|
|
|
|
$options->{action_on_align_false} && "CODE" eq ref $options->{action_on_align_false} |
2310
|
0
|
|
|
0
|
|
0
|
? (action_on_false => sub { $options->{action_on_align_false}->($type) }) |
2311
|
5
|
50
|
33
|
|
|
109
|
: () |
|
|
50
|
33
|
|
|
|
|
2312
|
|
|
|
|
|
|
), |
2313
|
|
|
|
|
|
|
} |
2314
|
|
|
|
|
|
|
) |
2315
|
|
|
|
|
|
|
); |
2316
|
|
|
|
|
|
|
} |
2317
|
|
|
|
|
|
|
|
2318
|
|
|
|
|
|
|
$have_aligns |
2319
|
|
|
|
|
|
|
and $options->{action_on_true} |
2320
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
2321
|
1
|
50
|
33
|
|
|
38
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
2322
|
|
|
|
|
|
|
|
2323
|
|
|
|
|
|
|
$options->{action_on_false} |
2324
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
2325
|
|
|
|
|
|
|
and !$have_aligns |
2326
|
1
|
0
|
33
|
|
|
21
|
and $options->{action_on_false}->(); |
|
|
|
33
|
|
|
|
|
2327
|
|
|
|
|
|
|
|
2328
|
1
|
|
|
|
|
43
|
$have_aligns; |
2329
|
|
|
|
|
|
|
} |
2330
|
|
|
|
|
|
|
|
2331
|
|
|
|
|
|
|
sub _have_member_define_name |
2332
|
|
|
|
|
|
|
{ |
2333
|
32
|
|
|
32
|
|
132
|
my $member = $_[0]; |
2334
|
32
|
|
|
|
|
167
|
my $have_name = "HAVE_" . uc($member); |
2335
|
32
|
|
|
|
|
204
|
$have_name =~ tr/_A-Za-z0-9/_/c; |
2336
|
32
|
|
|
|
|
489
|
$have_name; |
2337
|
|
|
|
|
|
|
} |
2338
|
|
|
|
|
|
|
|
2339
|
|
|
|
|
|
|
=head2 check_member( member, \%options? ) |
2340
|
|
|
|
|
|
|
|
2341
|
|
|
|
|
|
|
Check whether I is in form of I.I and |
2342
|
|
|
|
|
|
|
I is a member of the I aggregate. |
2343
|
|
|
|
|
|
|
|
2344
|
|
|
|
|
|
|
which are used prior to the aggregate under test. |
2345
|
|
|
|
|
|
|
|
2346
|
|
|
|
|
|
|
Config::AutoConf->check_member( |
2347
|
|
|
|
|
|
|
"struct STRUCT_SV.sv_refcnt", |
2348
|
|
|
|
|
|
|
{ |
2349
|
|
|
|
|
|
|
action_on_false => sub { Config::AutoConf->msg_failure( "sv_refcnt member required for struct STRUCT_SV" ); }, |
2350
|
|
|
|
|
|
|
prologue => "#include \n#include " |
2351
|
|
|
|
|
|
|
} |
2352
|
|
|
|
|
|
|
); |
2353
|
|
|
|
|
|
|
|
2354
|
|
|
|
|
|
|
This function will return a true value (1) if the member is found. |
2355
|
|
|
|
|
|
|
|
2356
|
|
|
|
|
|
|
If I aggregate has I member, preprocessor |
2357
|
|
|
|
|
|
|
macro HAVE_I_I (in all capitals, with spaces |
2358
|
|
|
|
|
|
|
and dots replaced by underscores) is defined. |
2359
|
|
|
|
|
|
|
|
2360
|
|
|
|
|
|
|
This macro caches its result in the Caggr_member variable. |
2361
|
|
|
|
|
|
|
|
2362
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
2363
|
|
|
|
|
|
|
to I or I are executed, respectively. |
2364
|
|
|
|
|
|
|
When a I exists in the optional hash at end, it will be favored |
2365
|
|
|
|
|
|
|
over C (represented by L). If any of |
2366
|
|
|
|
|
|
|
I, I is defined, both callbacks |
2367
|
|
|
|
|
|
|
are passed to L as I or I to |
2368
|
|
|
|
|
|
|
C, respectively. |
2369
|
|
|
|
|
|
|
|
2370
|
|
|
|
|
|
|
=cut |
2371
|
|
|
|
|
|
|
|
2372
|
|
|
|
|
|
|
sub check_member |
2373
|
|
|
|
|
|
|
{ |
2374
|
32
|
|
|
32
|
1
|
1536
|
my $options = {}; |
2375
|
32
|
50
|
33
|
|
|
702
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
2376
|
32
|
|
|
|
|
137
|
my ($self, $member) = @_; |
2377
|
32
|
|
|
|
|
131
|
$self = $self->_get_instance(); |
2378
|
32
|
50
|
|
|
|
136
|
defined($member) or return croak("No type to check for"); |
2379
|
32
|
50
|
|
|
|
134
|
ref($member) eq "" or return croak("No type to check for"); |
2380
|
|
|
|
|
|
|
|
2381
|
32
|
50
|
|
|
|
902
|
$member =~ m/^([^.]+)\.([^.]+)$/ or return croak("check_member(\"struct foo.member\", \%options)"); |
2382
|
32
|
|
|
|
|
251
|
my $type = $1; |
2383
|
32
|
|
|
|
|
423
|
$member = $2; |
2384
|
|
|
|
|
|
|
|
2385
|
32
|
|
|
|
|
454
|
my $cache_name = $self->_cache_type_name("$type.$member"); |
2386
|
|
|
|
|
|
|
my $check_sub = sub { |
2387
|
|
|
|
|
|
|
|
2388
|
32
|
|
|
32
|
|
163
|
my $body = <
|
2389
|
|
|
|
|
|
|
static $type check_aggr; |
2390
|
|
|
|
|
|
|
if( check_aggr.$member ) |
2391
|
|
|
|
|
|
|
return 0; |
2392
|
|
|
|
|
|
|
ACEOF |
2393
|
32
|
|
|
|
|
484
|
my $conftest = $self->lang_build_program($options->{prologue}, $body); |
2394
|
32
|
|
|
|
|
182
|
my $have_member = $self->compile_if_else($conftest); |
2395
|
|
|
|
|
|
|
|
2396
|
32
|
100
|
|
|
|
44047
|
unless ($have_member) |
2397
|
|
|
|
|
|
|
{ |
2398
|
10
|
|
|
|
|
89
|
$body = <
|
2399
|
|
|
|
|
|
|
static $type check_aggr; |
2400
|
|
|
|
|
|
|
if( sizeof check_aggr.$member ) |
2401
|
|
|
|
|
|
|
return 0; |
2402
|
|
|
|
|
|
|
ACEOF |
2403
|
10
|
|
|
|
|
233
|
$conftest = $self->lang_build_program($options->{prologue}, $body); |
2404
|
10
|
|
|
|
|
76
|
$have_member = $self->compile_if_else($conftest); |
2405
|
|
|
|
|
|
|
} |
2406
|
|
|
|
|
|
|
|
2407
|
|
|
|
|
|
|
$have_member |
2408
|
|
|
|
|
|
|
and $options->{action_on_true} |
2409
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
2410
|
32
|
50
|
66
|
|
|
12701
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
2411
|
|
|
|
|
|
|
|
2412
|
|
|
|
|
|
|
$options->{action_on_false} |
2413
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
2414
|
32
|
100
|
33
|
|
|
236
|
and $options->{action_on_false}->() |
|
|
|
33
|
|
|
|
|
2415
|
|
|
|
|
|
|
unless $have_member; |
2416
|
|
|
|
|
|
|
|
2417
|
32
|
|
|
|
|
720
|
$have_member; |
2418
|
32
|
|
|
|
|
400
|
}; |
2419
|
|
|
|
|
|
|
|
2420
|
|
|
|
|
|
|
$self->check_cached( |
2421
|
|
|
|
|
|
|
$cache_name, |
2422
|
|
|
|
|
|
|
"for $type.$member", |
2423
|
|
|
|
|
|
|
$check_sub, |
2424
|
|
|
|
|
|
|
{ |
2425
|
|
|
|
|
|
|
action_on_true => sub { |
2426
|
23
|
|
|
23
|
|
559
|
$self->define_var( |
2427
|
|
|
|
|
|
|
_have_member_define_name("$type.$member"), |
2428
|
|
|
|
|
|
|
$self->cache_val($cache_name), |
2429
|
|
|
|
|
|
|
"defined when $type.$member is available" |
2430
|
|
|
|
|
|
|
); |
2431
|
|
|
|
|
|
|
$options->{action_on_cache_true} |
2432
|
|
|
|
|
|
|
and ref $options->{action_on_cache_true} eq "CODE" |
2433
|
23
|
50
|
33
|
|
|
184
|
and $options->{action_on_cache_true}->(); |
2434
|
|
|
|
|
|
|
}, |
2435
|
|
|
|
|
|
|
action_on_false => sub { |
2436
|
9
|
|
|
9
|
|
205
|
$self->define_var(_have_member_define_name("$type.$member"), undef, "defined when $type.$member is available"); |
2437
|
|
|
|
|
|
|
$options->{action_on_cache_false} |
2438
|
|
|
|
|
|
|
and ref $options->{action_on_cache_false} eq "CODE" |
2439
|
9
|
50
|
33
|
|
|
65
|
and $options->{action_on_cache_false}->(); |
2440
|
|
|
|
|
|
|
}, |
2441
|
|
|
|
|
|
|
} |
2442
|
32
|
|
|
|
|
698
|
); |
2443
|
|
|
|
|
|
|
} |
2444
|
|
|
|
|
|
|
|
2445
|
|
|
|
|
|
|
=head2 check_members( members, \%options? ) |
2446
|
|
|
|
|
|
|
|
2447
|
|
|
|
|
|
|
For each member L is called to check for member of aggregate. |
2448
|
|
|
|
|
|
|
|
2449
|
|
|
|
|
|
|
This function will return a true value (1) if at least one member is found. |
2450
|
|
|
|
|
|
|
|
2451
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
2452
|
|
|
|
|
|
|
to I or I are executed, respectively. |
2453
|
|
|
|
|
|
|
When a I exists in the optional hash at end, it will be favored |
2454
|
|
|
|
|
|
|
over C (represented by L). If any of |
2455
|
|
|
|
|
|
|
I, I is defined, both callbacks |
2456
|
|
|
|
|
|
|
are passed to L as I or I to |
2457
|
|
|
|
|
|
|
C, respectively. |
2458
|
|
|
|
|
|
|
Given callbacks for I or I are |
2459
|
|
|
|
|
|
|
called for each symbol checked using L receiving the symbol as |
2460
|
|
|
|
|
|
|
first argument. |
2461
|
|
|
|
|
|
|
|
2462
|
|
|
|
|
|
|
=cut |
2463
|
|
|
|
|
|
|
|
2464
|
|
|
|
|
|
|
sub check_members |
2465
|
|
|
|
|
|
|
{ |
2466
|
2
|
|
|
2
|
1
|
9
|
my $options = {}; |
2467
|
2
|
50
|
33
|
|
|
234
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
2468
|
2
|
|
|
|
|
18
|
my ($self, $members) = @_; |
2469
|
2
|
|
|
|
|
10
|
$self = $self->_get_instance(); |
2470
|
|
|
|
|
|
|
|
2471
|
2
|
|
|
|
|
8
|
my %pass_options; |
2472
|
2
|
50
|
|
|
|
19
|
defined $options->{prologue} and $pass_options{prologue} = $options->{prologue}; |
2473
|
2
|
50
|
|
|
|
7
|
defined $options->{action_on_cache_true} and $pass_options{action_on_cache_true} = $options->{action_on_cache_true}; |
2474
|
2
|
50
|
|
|
|
14
|
defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false}; |
2475
|
|
|
|
|
|
|
|
2476
|
2
|
|
|
|
|
10
|
my $have_members = 0; |
2477
|
2
|
|
|
|
|
27
|
foreach my $member (@$members) |
2478
|
|
|
|
|
|
|
{ |
2479
|
|
|
|
|
|
|
$have_members |= ( |
2480
|
|
|
|
|
|
|
$self->check_member( |
2481
|
|
|
|
|
|
|
$member, |
2482
|
|
|
|
|
|
|
{ |
2483
|
|
|
|
|
|
|
%pass_options, |
2484
|
|
|
|
|
|
|
( |
2485
|
|
|
|
|
|
|
$options->{action_on_member_true} && "CODE" eq ref $options->{action_on_member_true} |
2486
|
0
|
|
|
0
|
|
0
|
? (action_on_true => sub { $options->{action_on_member_true}->($member) }) |
2487
|
|
|
|
|
|
|
: () |
2488
|
|
|
|
|
|
|
), |
2489
|
|
|
|
|
|
|
( |
2490
|
|
|
|
|
|
|
$options->{action_on_member_false} && "CODE" eq ref $options->{action_on_member_false} |
2491
|
0
|
|
|
0
|
|
0
|
? (action_on_false => sub { $options->{action_on_member_false}->($member) }) |
2492
|
30
|
50
|
33
|
|
|
497
|
: () |
|
|
50
|
33
|
|
|
|
|
2493
|
|
|
|
|
|
|
), |
2494
|
|
|
|
|
|
|
} |
2495
|
|
|
|
|
|
|
) |
2496
|
|
|
|
|
|
|
); |
2497
|
|
|
|
|
|
|
} |
2498
|
|
|
|
|
|
|
|
2499
|
|
|
|
|
|
|
$have_members |
2500
|
|
|
|
|
|
|
and $options->{action_on_true} |
2501
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
2502
|
2
|
50
|
33
|
|
|
105
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
2503
|
|
|
|
|
|
|
|
2504
|
|
|
|
|
|
|
$options->{action_on_false} |
2505
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
2506
|
|
|
|
|
|
|
and !$have_members |
2507
|
2
|
0
|
33
|
|
|
33
|
and $options->{action_on_false}->(); |
|
|
|
33
|
|
|
|
|
2508
|
|
|
|
|
|
|
|
2509
|
2
|
|
|
|
|
113
|
$have_members; |
2510
|
|
|
|
|
|
|
} |
2511
|
|
|
|
|
|
|
|
2512
|
|
|
|
|
|
|
sub _have_header_define_name |
2513
|
|
|
|
|
|
|
{ |
2514
|
30
|
|
|
30
|
|
207
|
my $header = $_[0]; |
2515
|
30
|
|
|
|
|
275
|
my $have_name = "HAVE_" . uc($header); |
2516
|
30
|
|
|
|
|
122
|
$have_name =~ tr/_A-Za-z0-9/_/c; |
2517
|
30
|
|
|
|
|
400
|
return $have_name; |
2518
|
|
|
|
|
|
|
} |
2519
|
|
|
|
|
|
|
|
2520
|
|
|
|
|
|
|
sub _check_header |
2521
|
|
|
|
|
|
|
{ |
2522
|
28
|
|
|
28
|
|
101
|
my $options = {}; |
2523
|
28
|
50
|
33
|
|
|
379
|
scalar @_ > 4 and ref $_[-1] eq "HASH" and $options = pop @_; |
2524
|
28
|
|
|
|
|
135
|
my ($self, $header, $prologue, $body) = @_; |
2525
|
|
|
|
|
|
|
|
2526
|
28
|
|
|
|
|
86
|
$prologue .= <<"_ACEOF"; |
2527
|
|
|
|
|
|
|
#include <$header> |
2528
|
|
|
|
|
|
|
_ACEOF |
2529
|
28
|
|
|
|
|
336
|
my $conftest = $self->lang_build_program($prologue, $body); |
2530
|
|
|
|
|
|
|
|
2531
|
28
|
|
|
|
|
138
|
$self->compile_if_else($conftest, $options); |
2532
|
|
|
|
|
|
|
} |
2533
|
|
|
|
|
|
|
|
2534
|
|
|
|
|
|
|
=head2 check_header( $header, \%options? ) |
2535
|
|
|
|
|
|
|
|
2536
|
|
|
|
|
|
|
This function is used to check if a specific header file is present in |
2537
|
|
|
|
|
|
|
the system: if we detect it and if we can compile anything with that |
2538
|
|
|
|
|
|
|
header included. Note that normally you want to check for a header |
2539
|
|
|
|
|
|
|
first, and then check for the corresponding library (not all at once). |
2540
|
|
|
|
|
|
|
|
2541
|
|
|
|
|
|
|
The standard usage for this module is: |
2542
|
|
|
|
|
|
|
|
2543
|
|
|
|
|
|
|
Config::AutoConf->check_header("ncurses.h"); |
2544
|
|
|
|
|
|
|
|
2545
|
|
|
|
|
|
|
This function will return a true value (1) on success, and a false value |
2546
|
|
|
|
|
|
|
if the header is not present or not available for common usage. |
2547
|
|
|
|
|
|
|
|
2548
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
2549
|
|
|
|
|
|
|
to I or I are executed, respectively. |
2550
|
|
|
|
|
|
|
When a I exists in the optional hash at end, it will be prepended |
2551
|
|
|
|
|
|
|
to the tested header. If any of I, |
2552
|
|
|
|
|
|
|
I is defined, both callbacks are passed to |
2553
|
|
|
|
|
|
|
L as I or I to |
2554
|
|
|
|
|
|
|
C, respectively. |
2555
|
|
|
|
|
|
|
|
2556
|
|
|
|
|
|
|
=cut |
2557
|
|
|
|
|
|
|
|
2558
|
|
|
|
|
|
|
sub check_header |
2559
|
|
|
|
|
|
|
{ |
2560
|
30
|
|
|
30
|
1
|
377
|
my $options = {}; |
2561
|
30
|
100
|
66
|
|
|
454
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
2562
|
30
|
|
|
|
|
148
|
my ($self, $header) = @_; |
2563
|
30
|
|
|
|
|
109
|
$self = $self->_get_instance(); |
2564
|
30
|
50
|
|
|
|
113
|
defined($header) or return croak("No type to check for"); |
2565
|
30
|
50
|
|
|
|
107
|
ref($header) eq "" or return croak("No type to check for"); |
2566
|
|
|
|
|
|
|
|
2567
|
30
|
50
|
|
|
|
82
|
return 0 unless $header; |
2568
|
30
|
|
|
|
|
233
|
my $cache_name = $self->_cache_name($header); |
2569
|
|
|
|
|
|
|
my $check_sub = sub { |
2570
|
27
|
50
|
|
27
|
|
96
|
my $prologue = defined $options->{prologue} ? $options->{prologue} : ""; |
2571
|
|
|
|
|
|
|
|
2572
|
|
|
|
|
|
|
my $have_header = $self->_check_header( |
2573
|
|
|
|
|
|
|
$header, |
2574
|
|
|
|
|
|
|
$prologue, |
2575
|
|
|
|
|
|
|
"", |
2576
|
|
|
|
|
|
|
{ |
2577
|
|
|
|
|
|
|
($options->{action_on_true} ? (action_on_true => $options->{action_on_true}) : ()), |
2578
|
27
|
50
|
|
|
|
280
|
($options->{action_on_false} ? (action_on_false => $options->{action_on_false}) : ()) |
|
|
50
|
|
|
|
|
|
2579
|
|
|
|
|
|
|
} |
2580
|
|
|
|
|
|
|
); |
2581
|
|
|
|
|
|
|
|
2582
|
27
|
|
|
|
|
28467
|
$have_header; |
2583
|
30
|
|
|
|
|
258
|
}; |
2584
|
|
|
|
|
|
|
|
2585
|
|
|
|
|
|
|
$self->check_cached( |
2586
|
|
|
|
|
|
|
$cache_name, |
2587
|
|
|
|
|
|
|
"for $header", |
2588
|
|
|
|
|
|
|
$check_sub, |
2589
|
|
|
|
|
|
|
{ |
2590
|
|
|
|
|
|
|
action_on_true => sub { |
2591
|
28
|
|
|
28
|
|
161
|
$self->define_var( |
2592
|
|
|
|
|
|
|
_have_header_define_name($header), |
2593
|
|
|
|
|
|
|
$self->cache_val($cache_name), |
2594
|
|
|
|
|
|
|
"defined when $header is available" |
2595
|
|
|
|
|
|
|
); |
2596
|
|
|
|
|
|
|
$options->{action_on_cache_true} |
2597
|
|
|
|
|
|
|
and ref $options->{action_on_cache_true} eq "CODE" |
2598
|
28
|
50
|
33
|
|
|
147
|
and $options->{action_on_cache_true}->(); |
2599
|
|
|
|
|
|
|
}, |
2600
|
|
|
|
|
|
|
action_on_false => sub { |
2601
|
2
|
|
|
2
|
|
13
|
$self->define_var(_have_header_define_name($header), undef, "defined when $header is available"); |
2602
|
|
|
|
|
|
|
$options->{action_on_cache_false} |
2603
|
|
|
|
|
|
|
and ref $options->{action_on_cache_false} eq "CODE" |
2604
|
2
|
50
|
33
|
|
|
17
|
and $options->{action_on_cache_false}->(); |
2605
|
|
|
|
|
|
|
}, |
2606
|
|
|
|
|
|
|
} |
2607
|
30
|
|
|
|
|
470
|
); |
2608
|
|
|
|
|
|
|
} |
2609
|
|
|
|
|
|
|
|
2610
|
|
|
|
|
|
|
=head2 check_headers |
2611
|
|
|
|
|
|
|
|
2612
|
|
|
|
|
|
|
This function uses check_header to check if a set of include files exist |
2613
|
|
|
|
|
|
|
in the system and can be included and compiled by the available compiler. |
2614
|
|
|
|
|
|
|
Returns the name of the first header file found. |
2615
|
|
|
|
|
|
|
|
2616
|
|
|
|
|
|
|
Passes an optional \%options hash to each L call. |
2617
|
|
|
|
|
|
|
|
2618
|
|
|
|
|
|
|
=cut |
2619
|
|
|
|
|
|
|
|
2620
|
|
|
|
|
|
|
sub check_headers |
2621
|
|
|
|
|
|
|
{ |
2622
|
1
|
|
|
1
|
1
|
8
|
my $options = {}; |
2623
|
1
|
50
|
33
|
|
|
15
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
2624
|
1
|
|
|
|
|
10
|
my $self = shift->_get_instance(); |
2625
|
1
|
|
100
|
|
|
7
|
$self->check_header($_, $options) and return $_ for (@_); |
2626
|
0
|
|
|
|
|
0
|
return; |
2627
|
|
|
|
|
|
|
} |
2628
|
|
|
|
|
|
|
|
2629
|
|
|
|
|
|
|
=head2 check_all_headers |
2630
|
|
|
|
|
|
|
|
2631
|
|
|
|
|
|
|
This function checks each given header for usability and returns true |
2632
|
|
|
|
|
|
|
when each header can be used -- otherwise false. |
2633
|
|
|
|
|
|
|
|
2634
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
2635
|
|
|
|
|
|
|
to I or I are executed, respectively. |
2636
|
|
|
|
|
|
|
Each of existing key/value pairs using I, I |
2637
|
|
|
|
|
|
|
or I as key are passed-through to each call of |
2638
|
|
|
|
|
|
|
L. |
2639
|
|
|
|
|
|
|
Given callbacks for I or I are |
2640
|
|
|
|
|
|
|
called for each symbol checked using L receiving the symbol as |
2641
|
|
|
|
|
|
|
first argument. |
2642
|
|
|
|
|
|
|
|
2643
|
|
|
|
|
|
|
=cut |
2644
|
|
|
|
|
|
|
|
2645
|
|
|
|
|
|
|
sub check_all_headers |
2646
|
|
|
|
|
|
|
{ |
2647
|
2
|
|
|
2
|
1
|
5
|
my $options = {}; |
2648
|
2
|
50
|
33
|
|
|
33
|
scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_; |
2649
|
2
|
|
|
|
|
9
|
my $self = shift->_get_instance(); |
2650
|
2
|
50
|
|
|
|
7
|
@_ or return; |
2651
|
|
|
|
|
|
|
|
2652
|
2
|
|
|
|
|
6
|
my %pass_options; |
2653
|
2
|
50
|
|
|
|
12
|
defined $options->{prologue} and $pass_options{prologue} = $options->{prologue}; |
2654
|
2
|
50
|
|
|
|
8
|
defined $options->{action_on_cache_true} and $pass_options{action_on_cache_true} = $options->{action_on_cache_true}; |
2655
|
2
|
50
|
|
|
|
7
|
defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false}; |
2656
|
|
|
|
|
|
|
|
2657
|
2
|
|
|
|
|
4
|
my $all_headers = 1; |
2658
|
2
|
|
|
|
|
11
|
foreach my $header (@_) |
2659
|
|
|
|
|
|
|
{ |
2660
|
|
|
|
|
|
|
$all_headers &= $self->check_header( |
2661
|
|
|
|
|
|
|
$header, |
2662
|
|
|
|
|
|
|
{ |
2663
|
|
|
|
|
|
|
%pass_options, |
2664
|
|
|
|
|
|
|
( |
2665
|
|
|
|
|
|
|
$options->{action_on_header_true} && "CODE" eq ref $options->{action_on_header_true} |
2666
|
0
|
|
|
0
|
|
0
|
? (action_on_true => sub { $options->{action_on_header_true}->($header) }) |
2667
|
|
|
|
|
|
|
: () |
2668
|
|
|
|
|
|
|
), |
2669
|
|
|
|
|
|
|
( |
2670
|
|
|
|
|
|
|
$options->{action_on_header_false} && "CODE" eq ref $options->{action_on_header_false} |
2671
|
0
|
|
|
0
|
|
0
|
? (action_on_false => sub { $options->{action_on_header_false}->($header) }) |
2672
|
22
|
50
|
33
|
|
|
303
|
: () |
|
|
50
|
33
|
|
|
|
|
2673
|
|
|
|
|
|
|
), |
2674
|
|
|
|
|
|
|
} |
2675
|
|
|
|
|
|
|
); |
2676
|
|
|
|
|
|
|
} |
2677
|
|
|
|
|
|
|
|
2678
|
|
|
|
|
|
|
$all_headers |
2679
|
|
|
|
|
|
|
and $options->{action_on_true} |
2680
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
2681
|
2
|
50
|
33
|
|
|
58
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
2682
|
|
|
|
|
|
|
|
2683
|
|
|
|
|
|
|
$options->{action_on_false} |
2684
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
2685
|
|
|
|
|
|
|
and !$all_headers |
2686
|
2
|
0
|
33
|
|
|
18
|
and $options->{action_on_false}->(); |
|
|
|
33
|
|
|
|
|
2687
|
|
|
|
|
|
|
|
2688
|
2
|
|
|
|
|
22
|
$all_headers; |
2689
|
|
|
|
|
|
|
} |
2690
|
|
|
|
|
|
|
|
2691
|
|
|
|
|
|
|
=head2 check_stdc_headers |
2692
|
|
|
|
|
|
|
|
2693
|
|
|
|
|
|
|
Checks for standard C89 headers, namely stdlib.h, stdarg.h, string.h and float.h. |
2694
|
|
|
|
|
|
|
If those are found, additional all remaining C89 headers are checked: assert.h, |
2695
|
|
|
|
|
|
|
ctype.h, errno.h, limits.h, locale.h, math.h, setjmp.h, signal.h, stddef.h, |
2696
|
|
|
|
|
|
|
stdio.h and time.h. |
2697
|
|
|
|
|
|
|
|
2698
|
|
|
|
|
|
|
Returns a false value if it fails. |
2699
|
|
|
|
|
|
|
|
2700
|
|
|
|
|
|
|
Passes an optional \%options hash to each L call. |
2701
|
|
|
|
|
|
|
|
2702
|
|
|
|
|
|
|
=cut |
2703
|
|
|
|
|
|
|
|
2704
|
|
|
|
|
|
|
my @ansi_c_headers = qw(stdlib stdarg string float assert ctype errno limits locale math setjmp signal stddef stdio time); |
2705
|
|
|
|
|
|
|
|
2706
|
|
|
|
|
|
|
sub check_stdc_headers |
2707
|
|
|
|
|
|
|
{ |
2708
|
1
|
|
|
1
|
1
|
3
|
my $options = {}; |
2709
|
1
|
50
|
33
|
|
|
18
|
scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_; |
2710
|
1
|
|
|
|
|
12
|
my $self = shift->_get_instance(); |
2711
|
|
|
|
|
|
|
|
2712
|
|
|
|
|
|
|
# XXX for C++ the map should look like "c${_}" ... |
2713
|
1
|
|
|
|
|
10
|
my @c_ansi_c_headers = map { "${_}.h" } @ansi_c_headers; |
|
15
|
|
|
|
|
33
|
|
2714
|
1
|
|
|
|
|
6
|
my $rc = $self->check_all_headers(@c_ansi_c_headers, $options); |
2715
|
1
|
50
|
|
|
|
21
|
$rc and $self->define_var("STDC_HEADERS", 1, "Define to 1 if you have the ANSI C header files."); |
2716
|
1
|
|
|
|
|
23
|
$rc; |
2717
|
|
|
|
|
|
|
} |
2718
|
|
|
|
|
|
|
|
2719
|
|
|
|
|
|
|
=head2 check_default_headers |
2720
|
|
|
|
|
|
|
|
2721
|
|
|
|
|
|
|
This function checks for some default headers, the std c89 headers and |
2722
|
|
|
|
|
|
|
sys/types.h, sys/stat.h, memory.h, strings.h, inttypes.h, stdint.h and unistd.h |
2723
|
|
|
|
|
|
|
|
2724
|
|
|
|
|
|
|
Passes an optional \%options hash to each L call. |
2725
|
|
|
|
|
|
|
|
2726
|
|
|
|
|
|
|
=cut |
2727
|
|
|
|
|
|
|
|
2728
|
|
|
|
|
|
|
sub check_default_headers |
2729
|
|
|
|
|
|
|
{ |
2730
|
1
|
|
|
1
|
1
|
19
|
my $options = {}; |
2731
|
1
|
50
|
33
|
|
|
8
|
scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_; |
2732
|
1
|
|
|
|
|
9
|
my $self = shift->_get_instance(); |
2733
|
1
|
50
|
|
|
|
5
|
$self->check_stdc_headers($options) |
2734
|
|
|
|
|
|
|
and $self->check_all_headers(qw(sys/types.h sys/stat.h memory.h strings.h inttypes.h stdint.h unistd.h), $options); |
2735
|
|
|
|
|
|
|
} |
2736
|
|
|
|
|
|
|
|
2737
|
|
|
|
|
|
|
=head2 check_dirent_header |
2738
|
|
|
|
|
|
|
|
2739
|
|
|
|
|
|
|
Check for the following header files. For the first one that is found and |
2740
|
|
|
|
|
|
|
defines 'DIR', define the listed C preprocessor macro: |
2741
|
|
|
|
|
|
|
|
2742
|
|
|
|
|
|
|
dirent.h HAVE_DIRENT_H |
2743
|
|
|
|
|
|
|
sys/ndir.h HAVE_SYS_NDIR_H |
2744
|
|
|
|
|
|
|
sys/dir.h HAVE_SYS_DIR_H |
2745
|
|
|
|
|
|
|
ndir.h HAVE_NDIR_H |
2746
|
|
|
|
|
|
|
|
2747
|
|
|
|
|
|
|
The directory-library declarations in your source code should look |
2748
|
|
|
|
|
|
|
something like the following: |
2749
|
|
|
|
|
|
|
|
2750
|
|
|
|
|
|
|
#include |
2751
|
|
|
|
|
|
|
#ifdef HAVE_DIRENT_H |
2752
|
|
|
|
|
|
|
# include |
2753
|
|
|
|
|
|
|
# define NAMLEN(dirent) strlen ((dirent)->d_name) |
2754
|
|
|
|
|
|
|
#else |
2755
|
|
|
|
|
|
|
# define dirent direct |
2756
|
|
|
|
|
|
|
# define NAMLEN(dirent) ((dirent)->d_namlen) |
2757
|
|
|
|
|
|
|
# ifdef HAVE_SYS_NDIR_H |
2758
|
|
|
|
|
|
|
# include |
2759
|
|
|
|
|
|
|
# endif |
2760
|
|
|
|
|
|
|
# ifdef HAVE_SYS_DIR_H |
2761
|
|
|
|
|
|
|
# include |
2762
|
|
|
|
|
|
|
# endif |
2763
|
|
|
|
|
|
|
# ifdef HAVE_NDIR_H |
2764
|
|
|
|
|
|
|
# include |
2765
|
|
|
|
|
|
|
# endif |
2766
|
|
|
|
|
|
|
#endif |
2767
|
|
|
|
|
|
|
|
2768
|
|
|
|
|
|
|
Using the above declarations, the program would declare variables to be of |
2769
|
|
|
|
|
|
|
type C, not C, and would access the length |
2770
|
|
|
|
|
|
|
of a directory entry name by passing a pointer to a C to |
2771
|
|
|
|
|
|
|
the C macro. |
2772
|
|
|
|
|
|
|
|
2773
|
|
|
|
|
|
|
For the found header, the macro HAVE_DIRENT_IN_${header} is defined. |
2774
|
|
|
|
|
|
|
|
2775
|
|
|
|
|
|
|
This method might be obsolescent, as all current systems with directory |
2776
|
|
|
|
|
|
|
libraries have C<< Edirent.hE >>. Programs supporting only newer OS |
2777
|
|
|
|
|
|
|
might not need to use this method. |
2778
|
|
|
|
|
|
|
|
2779
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
2780
|
|
|
|
|
|
|
to I or I are executed, respectively. |
2781
|
|
|
|
|
|
|
Each of existing key/value pairs using I, I |
2782
|
|
|
|
|
|
|
(as I having the name of the tested header as first argument) |
2783
|
|
|
|
|
|
|
or I (as I having the name of the |
2784
|
|
|
|
|
|
|
tested header as first argument) as key are passed-through to each call of |
2785
|
|
|
|
|
|
|
L. |
2786
|
|
|
|
|
|
|
Given callbacks for I or I are |
2787
|
|
|
|
|
|
|
passed to the call of L. |
2788
|
|
|
|
|
|
|
|
2789
|
|
|
|
|
|
|
=cut |
2790
|
|
|
|
|
|
|
|
2791
|
|
|
|
|
|
|
sub _have_dirent_header_define_name |
2792
|
|
|
|
|
|
|
{ |
2793
|
1
|
|
|
1
|
|
12
|
my $header = $_[0]; |
2794
|
1
|
|
|
|
|
11
|
my $have_name = "HAVE_DIRENT_IN_" . uc($header); |
2795
|
1
|
|
|
|
|
10
|
$have_name =~ tr/_A-Za-z0-9/_/c; |
2796
|
1
|
|
|
|
|
21
|
return $have_name; |
2797
|
|
|
|
|
|
|
} |
2798
|
|
|
|
|
|
|
|
2799
|
|
|
|
|
|
|
sub check_dirent_header |
2800
|
|
|
|
|
|
|
{ |
2801
|
1
|
|
|
1
|
1
|
3
|
my $options = {}; |
2802
|
1
|
50
|
33
|
|
|
18
|
scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_; |
2803
|
1
|
|
|
|
|
9
|
my $self = shift->_get_instance(); |
2804
|
|
|
|
|
|
|
|
2805
|
1
|
|
|
|
|
4
|
my %pass_options; |
2806
|
1
|
50
|
|
|
|
16
|
defined $options->{prologue} and $pass_options{prologue} = $options->{prologue}; |
2807
|
|
|
|
|
|
|
|
2808
|
1
|
|
|
|
|
2
|
my $have_dirent; |
2809
|
1
|
|
|
|
|
12
|
foreach my $header (qw(dirent.h sys/ndir.h sys/dir.h ndir.h)) |
2810
|
|
|
|
|
|
|
{ |
2811
|
1
|
50
|
|
|
|
11
|
if ($self->check_header($header)) |
2812
|
|
|
|
|
|
|
{ |
2813
|
1
|
|
|
|
|
24
|
my $cache_name = $self->_cache_name("dirent", $header); |
2814
|
|
|
|
|
|
|
my $check_sub = sub { |
2815
|
1
|
|
|
1
|
|
9
|
my $have_dirent; |
2816
|
|
|
|
|
|
|
$have_dirent = $self->_check_header( |
2817
|
|
|
|
|
|
|
$header, |
2818
|
|
|
|
|
|
|
"#include \n", |
2819
|
|
|
|
|
|
|
"if ((DIR *) 0) { return 0; }", |
2820
|
|
|
|
|
|
|
{ |
2821
|
|
|
|
|
|
|
%pass_options, |
2822
|
|
|
|
|
|
|
( |
2823
|
|
|
|
|
|
|
$options->{action_on_header_true} && "CODE" eq ref $options->{action_on_header_true} |
2824
|
0
|
|
|
|
|
0
|
? (action_on_true => sub { $options->{action_on_header_true}->($header) }) |
2825
|
|
|
|
|
|
|
: () |
2826
|
|
|
|
|
|
|
), |
2827
|
|
|
|
|
|
|
( |
2828
|
|
|
|
|
|
|
$options->{action_on_header_false} && "CODE" eq ref $options->{action_on_header_false} |
2829
|
0
|
|
|
|
|
0
|
? (action_on_false => sub { $options->{action_on_header_false}->($header) }) |
2830
|
1
|
50
|
33
|
|
|
37
|
: () |
|
|
50
|
33
|
|
|
|
|
2831
|
|
|
|
|
|
|
), |
2832
|
|
|
|
|
|
|
} |
2833
|
|
|
|
|
|
|
); |
2834
|
1
|
|
|
|
|
18
|
}; |
2835
|
|
|
|
|
|
|
|
2836
|
|
|
|
|
|
|
$have_dirent = $self->check_cached( |
2837
|
|
|
|
|
|
|
$cache_name, |
2838
|
|
|
|
|
|
|
"for header defining DIR *", |
2839
|
|
|
|
|
|
|
$check_sub, |
2840
|
|
|
|
|
|
|
{ |
2841
|
|
|
|
|
|
|
action_on_true => sub { |
2842
|
1
|
|
|
1
|
|
30
|
$self->define_var( |
2843
|
|
|
|
|
|
|
_have_dirent_header_define_name($header), |
2844
|
|
|
|
|
|
|
$self->cache_val($cache_name), |
2845
|
|
|
|
|
|
|
"defined when $header is available" |
2846
|
|
|
|
|
|
|
); |
2847
|
|
|
|
|
|
|
$options->{action_on_cache_true} |
2848
|
|
|
|
|
|
|
and ref $options->{action_on_cache_true} eq "CODE" |
2849
|
1
|
50
|
33
|
|
|
16
|
and $options->{action_on_cache_true}->(); |
2850
|
|
|
|
|
|
|
}, |
2851
|
|
|
|
|
|
|
action_on_false => sub { |
2852
|
0
|
|
|
0
|
|
0
|
$self->define_var(_have_dirent_header_define_name($header), undef, "defined when $header is available"); |
2853
|
|
|
|
|
|
|
$options->{action_on_cache_false} |
2854
|
|
|
|
|
|
|
and ref $options->{action_on_cache_false} eq "CODE" |
2855
|
0
|
0
|
0
|
|
|
0
|
and $options->{action_on_cache_false}->(); |
2856
|
|
|
|
|
|
|
}, |
2857
|
|
|
|
|
|
|
} |
2858
|
1
|
|
|
|
|
55
|
); |
2859
|
|
|
|
|
|
|
|
2860
|
1
|
50
|
33
|
|
|
55
|
$have_dirent and $have_dirent = $header and last; |
2861
|
|
|
|
|
|
|
} |
2862
|
|
|
|
|
|
|
} |
2863
|
|
|
|
|
|
|
|
2864
|
|
|
|
|
|
|
$have_dirent |
2865
|
|
|
|
|
|
|
and $options->{action_on_true} |
2866
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
2867
|
1
|
50
|
33
|
|
|
47
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
2868
|
|
|
|
|
|
|
|
2869
|
|
|
|
|
|
|
$options->{action_on_false} |
2870
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
2871
|
|
|
|
|
|
|
and !$have_dirent |
2872
|
1
|
0
|
33
|
|
|
20
|
and $options->{action_on_false}->(); |
|
|
|
33
|
|
|
|
|
2873
|
|
|
|
|
|
|
|
2874
|
1
|
|
|
|
|
15
|
$have_dirent; |
2875
|
|
|
|
|
|
|
} |
2876
|
|
|
|
|
|
|
|
2877
|
|
|
|
|
|
|
=head2 _check_perlapi_program |
2878
|
|
|
|
|
|
|
|
2879
|
|
|
|
|
|
|
This method provides the program source which is suitable to do basic |
2880
|
|
|
|
|
|
|
compile/link tests to prove perl development environment. |
2881
|
|
|
|
|
|
|
|
2882
|
|
|
|
|
|
|
=cut |
2883
|
|
|
|
|
|
|
|
2884
|
|
|
|
|
|
|
sub _check_perlapi_program |
2885
|
|
|
|
|
|
|
{ |
2886
|
2
|
|
|
2
|
|
24
|
my $self = shift; |
2887
|
|
|
|
|
|
|
|
2888
|
2
|
|
|
|
|
14
|
my $includes = $self->_default_includes_with_perl(); |
2889
|
2
|
|
|
|
|
20
|
my $perl_check_body = <<'EOB'; |
2890
|
|
|
|
|
|
|
I32 rc; |
2891
|
|
|
|
|
|
|
SV *foo = newSVpv("Perl rocks", 11); |
2892
|
|
|
|
|
|
|
rc = SvCUR(foo); |
2893
|
|
|
|
|
|
|
EOB |
2894
|
2
|
|
|
|
|
28
|
$self->lang_build_program($includes, $perl_check_body); |
2895
|
|
|
|
|
|
|
} |
2896
|
|
|
|
|
|
|
|
2897
|
|
|
|
|
|
|
=head2 _check_compile_perlapi |
2898
|
|
|
|
|
|
|
|
2899
|
|
|
|
|
|
|
This method can be used from other checks to prove whether we have a perl |
2900
|
|
|
|
|
|
|
development environment or not (perl.h, reasonable basic checks - types, etc.) |
2901
|
|
|
|
|
|
|
|
2902
|
|
|
|
|
|
|
=cut |
2903
|
|
|
|
|
|
|
|
2904
|
|
|
|
|
|
|
sub _check_compile_perlapi |
2905
|
|
|
|
|
|
|
{ |
2906
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
2907
|
|
|
|
|
|
|
|
2908
|
1
|
|
|
|
|
6
|
my $conftest = $self->_check_perlapi_program(); |
2909
|
1
|
|
|
|
|
9
|
$self->compile_if_else($conftest); |
2910
|
|
|
|
|
|
|
} |
2911
|
|
|
|
|
|
|
|
2912
|
|
|
|
|
|
|
=head2 check_compile_perlapi |
2913
|
|
|
|
|
|
|
|
2914
|
|
|
|
|
|
|
This method can be used from other checks to prove whether we have a perl |
2915
|
|
|
|
|
|
|
development environment or not (perl.h, reasonable basic checks - types, etc.) |
2916
|
|
|
|
|
|
|
|
2917
|
|
|
|
|
|
|
=cut |
2918
|
|
|
|
|
|
|
|
2919
|
|
|
|
|
|
|
sub check_compile_perlapi |
2920
|
|
|
|
|
|
|
{ |
2921
|
1
|
|
|
1
|
1
|
579
|
my $self = shift->_get_instance; |
2922
|
1
|
|
|
|
|
11
|
my $cache_name = $self->_cache_name(qw(compile perlapi)); |
2923
|
|
|
|
|
|
|
|
2924
|
1
|
|
|
1
|
|
24
|
$self->check_cached($cache_name, "whether perlapi is accessible", sub { $self->_check_compile_perlapi }); |
|
1
|
|
|
|
|
14
|
|
2925
|
|
|
|
|
|
|
} |
2926
|
|
|
|
|
|
|
|
2927
|
|
|
|
|
|
|
=head2 check_compile_perlapi_or_die |
2928
|
|
|
|
|
|
|
|
2929
|
|
|
|
|
|
|
Dies when not being able to compile using the Perl API |
2930
|
|
|
|
|
|
|
|
2931
|
|
|
|
|
|
|
=cut |
2932
|
|
|
|
|
|
|
|
2933
|
|
|
|
|
|
|
sub check_compile_perlapi_or_die |
2934
|
|
|
|
|
|
|
{ |
2935
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
2936
|
0
|
0
|
|
|
|
0
|
$self->check_compile_perlapi(@_) or $self->msg_error("Cannot use Perl API - giving up"); |
2937
|
|
|
|
|
|
|
} |
2938
|
|
|
|
|
|
|
|
2939
|
|
|
|
|
|
|
=head2 check_linkable_xs_so |
2940
|
|
|
|
|
|
|
|
2941
|
|
|
|
|
|
|
Checks whether a dynamic loadable object containing an XS module can be |
2942
|
|
|
|
|
|
|
linked or not. Due the nature of the beast, this test currently always |
2943
|
|
|
|
|
|
|
succeed. |
2944
|
|
|
|
|
|
|
|
2945
|
|
|
|
|
|
|
=cut |
2946
|
|
|
|
|
|
|
|
2947
|
0
|
|
|
0
|
1
|
0
|
sub check_linkable_xs_so { 1 } |
2948
|
|
|
|
|
|
|
|
2949
|
|
|
|
|
|
|
=head2 check_linkable_xs_so_or_die |
2950
|
|
|
|
|
|
|
|
2951
|
|
|
|
|
|
|
Dies when L fails. |
2952
|
|
|
|
|
|
|
|
2953
|
|
|
|
|
|
|
=cut |
2954
|
|
|
|
|
|
|
|
2955
|
|
|
|
|
|
|
sub check_linkable_xs_so_or_die |
2956
|
|
|
|
|
|
|
{ |
2957
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
2958
|
0
|
0
|
|
|
|
0
|
$self->check_linkable_xs_so(@_) or $self->msg_error("Cannot link XS dynamic loadable - giving up"); |
2959
|
|
|
|
|
|
|
} |
2960
|
|
|
|
|
|
|
|
2961
|
|
|
|
|
|
|
=head2 check_loadable_xs_so |
2962
|
|
|
|
|
|
|
|
2963
|
|
|
|
|
|
|
Checks whether a dynamic loadable object containing an XS module can be |
2964
|
|
|
|
|
|
|
loaded or not. Due the nature of the beast, this test currently always |
2965
|
|
|
|
|
|
|
succeed. |
2966
|
|
|
|
|
|
|
|
2967
|
|
|
|
|
|
|
=cut |
2968
|
|
|
|
|
|
|
|
2969
|
0
|
|
|
0
|
1
|
0
|
sub check_loadable_xs_so { 1 } |
2970
|
|
|
|
|
|
|
|
2971
|
|
|
|
|
|
|
=head2 check_loadable_xs_so_or_die |
2972
|
|
|
|
|
|
|
|
2973
|
|
|
|
|
|
|
Dies when L fails. |
2974
|
|
|
|
|
|
|
|
2975
|
|
|
|
|
|
|
=cut |
2976
|
|
|
|
|
|
|
|
2977
|
|
|
|
|
|
|
sub check_loadable_xs_so_or_die |
2978
|
|
|
|
|
|
|
{ |
2979
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
2980
|
0
|
0
|
|
|
|
0
|
$self->check_loadable_xs_so(@_) or $self->msg_error("Cannot load XS dynamic loadable - giving up"); |
2981
|
|
|
|
|
|
|
} |
2982
|
|
|
|
|
|
|
|
2983
|
|
|
|
|
|
|
=head2 _check_link_perlapi |
2984
|
|
|
|
|
|
|
|
2985
|
|
|
|
|
|
|
This method can be used from other checks to prove whether we have a perl |
2986
|
|
|
|
|
|
|
development environment including a suitable libperl or not (perl.h, |
2987
|
|
|
|
|
|
|
reasonable basic checks - types, etc.) |
2988
|
|
|
|
|
|
|
|
2989
|
|
|
|
|
|
|
Caller must ensure that the linker flags are set appropriate (C<-lperl> |
2990
|
|
|
|
|
|
|
or similar). |
2991
|
|
|
|
|
|
|
|
2992
|
|
|
|
|
|
|
=cut |
2993
|
|
|
|
|
|
|
|
2994
|
|
|
|
|
|
|
sub _check_link_perlapi |
2995
|
|
|
|
|
|
|
{ |
2996
|
1
|
|
|
1
|
|
8
|
my $self = shift; |
2997
|
|
|
|
|
|
|
|
2998
|
1
|
|
|
|
|
12
|
my $conftest = $self->_check_perlapi_program(); |
2999
|
1
|
|
|
|
|
4
|
my @save_libs = @{$self->{extra_libs}}; |
|
1
|
|
|
|
|
14
|
|
3000
|
1
|
|
|
|
|
3
|
my @save_extra_link_flags = @{$self->{extra_link_flags}}; |
|
1
|
|
|
|
|
5
|
|
3001
|
|
|
|
|
|
|
|
3002
|
1
|
|
|
|
|
53
|
my $libperl = $Config{libperl}; |
3003
|
1
|
|
|
|
|
16
|
$libperl =~ s/^lib//; |
3004
|
1
|
|
|
|
|
7
|
$libperl =~ s/\.[^\.]*$//; |
3005
|
|
|
|
|
|
|
|
3006
|
1
|
|
|
|
|
3
|
push @{$self->{extra_link_flags}}, "-L" . File::Spec->catdir($Config{installarchlib}, "CORE"); |
|
1
|
|
|
|
|
38
|
|
3007
|
1
|
|
|
|
|
10
|
push @{$self->{extra_libs}}, "$libperl"; |
|
1
|
|
|
|
|
9
|
|
3008
|
1
|
50
|
|
|
|
21
|
if ($Config{perllibs}) |
3009
|
|
|
|
|
|
|
{ |
3010
|
1
|
|
|
|
|
17
|
foreach my $perllib (split(" ", $Config{perllibs})) |
3011
|
|
|
|
|
|
|
{ |
3012
|
7
|
50
|
33
|
|
|
30
|
$perllib =~ m/^\-l(\w+)$/ and push @{$self->{extra_libs}}, "$1" and next; |
|
7
|
|
|
|
|
44
|
|
3013
|
0
|
|
|
|
|
0
|
push @{$self->{extra_link_flags}}, $perllib; |
|
0
|
|
|
|
|
0
|
|
3014
|
|
|
|
|
|
|
} |
3015
|
|
|
|
|
|
|
} |
3016
|
|
|
|
|
|
|
|
3017
|
1
|
|
|
|
|
7
|
my $have_libperl = $self->link_if_else($conftest); |
3018
|
|
|
|
|
|
|
|
3019
|
1
|
50
|
|
|
|
1729
|
$have_libperl or $self->{extra_libs} = [@save_libs]; |
3020
|
1
|
50
|
|
|
|
12
|
$have_libperl or $self->{extra_link_flags} = [@save_extra_link_flags]; |
3021
|
|
|
|
|
|
|
|
3022
|
1
|
|
|
|
|
40
|
$have_libperl; |
3023
|
|
|
|
|
|
|
} |
3024
|
|
|
|
|
|
|
|
3025
|
|
|
|
|
|
|
=head2 check_link_perlapi |
3026
|
|
|
|
|
|
|
|
3027
|
|
|
|
|
|
|
This method can be used from other checks to prove whether we have a perl |
3028
|
|
|
|
|
|
|
development environment or not (perl.h, libperl.la, reasonable basic |
3029
|
|
|
|
|
|
|
checks - types, etc.) |
3030
|
|
|
|
|
|
|
|
3031
|
|
|
|
|
|
|
=cut |
3032
|
|
|
|
|
|
|
|
3033
|
|
|
|
|
|
|
sub check_link_perlapi |
3034
|
|
|
|
|
|
|
{ |
3035
|
1
|
|
|
1
|
1
|
697
|
my $self = shift->_get_instance; |
3036
|
1
|
|
|
|
|
12
|
my $cache_name = $self->_cache_name(qw(link perlapi)); |
3037
|
|
|
|
|
|
|
|
3038
|
1
|
|
|
1
|
|
24
|
$self->check_cached($cache_name, "whether perlapi is linkable", sub { $self->_check_link_perlapi }); |
|
1
|
|
|
|
|
11
|
|
3039
|
|
|
|
|
|
|
} |
3040
|
|
|
|
|
|
|
|
3041
|
|
|
|
|
|
|
sub _have_lib_define_name |
3042
|
|
|
|
|
|
|
{ |
3043
|
2
|
|
|
2
|
|
6
|
my $lib = $_[0]; |
3044
|
2
|
|
|
|
|
10
|
my $have_name = "HAVE_LIB" . uc($lib); |
3045
|
2
|
|
|
|
|
8
|
$have_name =~ tr/_A-Za-z0-9/_/c; |
3046
|
2
|
|
|
|
|
24
|
return $have_name; |
3047
|
|
|
|
|
|
|
} |
3048
|
|
|
|
|
|
|
|
3049
|
|
|
|
|
|
|
=head2 check_lib( lib, func, @other-libs?, \%options? ) |
3050
|
|
|
|
|
|
|
|
3051
|
|
|
|
|
|
|
This function is used to check if a specific library includes some |
3052
|
|
|
|
|
|
|
function. Call it with the library name (without the lib portion), and |
3053
|
|
|
|
|
|
|
the name of the function you want to test: |
3054
|
|
|
|
|
|
|
|
3055
|
|
|
|
|
|
|
Config::AutoConf->check_lib("z", "gzopen"); |
3056
|
|
|
|
|
|
|
|
3057
|
|
|
|
|
|
|
It returns 1 if the function exist, 0 otherwise. |
3058
|
|
|
|
|
|
|
|
3059
|
|
|
|
|
|
|
In case of function found, the HAVE_LIBlibrary (all in capitals) |
3060
|
|
|
|
|
|
|
preprocessor macro is defined with 1 and $lib together with @other_libs |
3061
|
|
|
|
|
|
|
are added to the list of libraries to link with. |
3062
|
|
|
|
|
|
|
|
3063
|
|
|
|
|
|
|
If linking with library results in unresolved symbols that would be |
3064
|
|
|
|
|
|
|
resolved by linking with additional libraries, give those libraries |
3065
|
|
|
|
|
|
|
as the I argument: e.g., C<[qw(Xt X11)]>. |
3066
|
|
|
|
|
|
|
Otherwise, this routine may fail to detect that library is present, |
3067
|
|
|
|
|
|
|
because linking the test program can fail with unresolved symbols. |
3068
|
|
|
|
|
|
|
The other-libraries argument should be limited to cases where it is |
3069
|
|
|
|
|
|
|
desirable to test for one library in the presence of another that |
3070
|
|
|
|
|
|
|
is not already in LIBS. |
3071
|
|
|
|
|
|
|
|
3072
|
|
|
|
|
|
|
This method caches its result in the Clib_func variable. |
3073
|
|
|
|
|
|
|
|
3074
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
3075
|
|
|
|
|
|
|
to I or I are executed, respectively. |
3076
|
|
|
|
|
|
|
If any of I, I is defined, |
3077
|
|
|
|
|
|
|
both callbacks are passed to L as I or |
3078
|
|
|
|
|
|
|
I to C, respectively. |
3079
|
|
|
|
|
|
|
|
3080
|
|
|
|
|
|
|
It's recommended to use L instead of check_lib these days. |
3081
|
|
|
|
|
|
|
|
3082
|
|
|
|
|
|
|
=cut |
3083
|
|
|
|
|
|
|
|
3084
|
|
|
|
|
|
|
sub check_lib |
3085
|
|
|
|
|
|
|
{ |
3086
|
2
|
|
|
2
|
1
|
13
|
my $options = {}; |
3087
|
2
|
50
|
33
|
|
|
45
|
scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_; |
3088
|
2
|
|
|
|
|
14
|
my $self = shift->_get_instance(); |
3089
|
2
|
|
|
|
|
16
|
my ($lib, $func, @other_libs) = @_; |
3090
|
|
|
|
|
|
|
|
3091
|
2
|
50
|
33
|
|
|
30
|
return 0 unless $lib and $func; |
3092
|
|
|
|
|
|
|
|
3093
|
|
|
|
|
|
|
scalar(@other_libs) == 1 |
3094
|
|
|
|
|
|
|
and ref($other_libs[0]) eq "ARRAY" |
3095
|
2
|
50
|
33
|
|
|
12
|
and @other_libs = @{$other_libs[0]}; |
|
0
|
|
|
|
|
0
|
|
3096
|
|
|
|
|
|
|
|
3097
|
2
|
|
|
|
|
12
|
my $cache_name = $self->_cache_name("lib", $lib, $func); |
3098
|
|
|
|
|
|
|
my $check_sub = sub { |
3099
|
2
|
|
|
2
|
|
25
|
my $conftest = $self->lang_call("", $func); |
3100
|
|
|
|
|
|
|
|
3101
|
2
|
|
|
|
|
5
|
my @save_libs = @{$self->{extra_libs}}; |
|
2
|
|
|
|
|
12
|
|
3102
|
2
|
|
|
|
|
6
|
push(@{$self->{extra_libs}}, $lib, @other_libs); |
|
2
|
|
|
|
|
6
|
|
3103
|
|
|
|
|
|
|
my $have_lib = $self->link_if_else( |
3104
|
|
|
|
|
|
|
$conftest, |
3105
|
|
|
|
|
|
|
{ |
3106
|
|
|
|
|
|
|
($options->{action_on_true} ? (action_on_true => $options->{action_on_true}) : ()), |
3107
|
2
|
50
|
|
|
|
16
|
($options->{action_on_false} ? (action_on_false => $options->{action_on_false}) : ()) |
|
|
50
|
|
|
|
|
|
3108
|
|
|
|
|
|
|
} |
3109
|
|
|
|
|
|
|
); |
3110
|
2
|
|
|
|
|
2036
|
$self->{extra_libs} = [@save_libs]; |
3111
|
|
|
|
|
|
|
|
3112
|
2
|
|
|
|
|
54
|
$have_lib; |
3113
|
2
|
|
|
|
|
25
|
}; |
3114
|
|
|
|
|
|
|
|
3115
|
|
|
|
|
|
|
$self->check_cached( |
3116
|
|
|
|
|
|
|
$cache_name, |
3117
|
|
|
|
|
|
|
"for $func in -l$lib", |
3118
|
|
|
|
|
|
|
$check_sub, |
3119
|
|
|
|
|
|
|
{ |
3120
|
|
|
|
|
|
|
action_on_true => sub { |
3121
|
1
|
|
|
1
|
|
26
|
$self->define_var( |
3122
|
|
|
|
|
|
|
_have_lib_define_name($lib), |
3123
|
|
|
|
|
|
|
$self->cache_val($cache_name), |
3124
|
|
|
|
|
|
|
"defined when library $lib is available" |
3125
|
|
|
|
|
|
|
); |
3126
|
1
|
|
|
|
|
3
|
push(@{$self->{extra_libs}}, $lib, @other_libs); |
|
1
|
|
|
|
|
9
|
|
3127
|
|
|
|
|
|
|
$options->{action_on_cache_true} |
3128
|
|
|
|
|
|
|
and ref $options->{action_on_cache_true} eq "CODE" |
3129
|
1
|
50
|
33
|
|
|
20
|
and $options->{action_on_cache_true}->(); |
3130
|
|
|
|
|
|
|
}, |
3131
|
|
|
|
|
|
|
action_on_false => sub { |
3132
|
1
|
|
|
1
|
|
21
|
$self->define_var(_have_lib_define_name($lib), undef, "defined when library $lib is available"); |
3133
|
|
|
|
|
|
|
$options->{action_on_cache_false} |
3134
|
|
|
|
|
|
|
and ref $options->{action_on_cache_false} eq "CODE" |
3135
|
1
|
50
|
33
|
|
|
11
|
and $options->{action_on_cache_false}->(); |
3136
|
|
|
|
|
|
|
}, |
3137
|
|
|
|
|
|
|
} |
3138
|
2
|
|
|
|
|
51
|
); |
3139
|
|
|
|
|
|
|
} |
3140
|
|
|
|
|
|
|
|
3141
|
|
|
|
|
|
|
=head2 search_libs( function, search-libs, @other-libs?, @extra_link_flags?, \%options? ) |
3142
|
|
|
|
|
|
|
|
3143
|
|
|
|
|
|
|
Config::AutoConf->search_libs("gethostent", "nsl", [qw(socket net)], { |
3144
|
|
|
|
|
|
|
action_on_true => sub { ... } |
3145
|
|
|
|
|
|
|
}); |
3146
|
|
|
|
|
|
|
Config::AutoConf->search_libs("log4cplus_initialize", ["log4cplus"], |
3147
|
|
|
|
|
|
|
[[qw(stdc++)], [qw(stdc++ unwind)]], |
3148
|
|
|
|
|
|
|
[qw(-pthread -thread)] |
3149
|
|
|
|
|
|
|
); |
3150
|
|
|
|
|
|
|
|
3151
|
|
|
|
|
|
|
Search for a library defining function if it's not already available. |
3152
|
|
|
|
|
|
|
This equates to calling |
3153
|
|
|
|
|
|
|
|
3154
|
|
|
|
|
|
|
Config::AutoConf->link_if_else( |
3155
|
|
|
|
|
|
|
Config::AutoConf->lang_call( "", "$function" ) ); |
3156
|
|
|
|
|
|
|
|
3157
|
|
|
|
|
|
|
first with no libraries, then for each library listed in search-libs. |
3158
|
|
|
|
|
|
|
I must be specified as an array reference to avoid |
3159
|
|
|
|
|
|
|
confusion in argument order. |
3160
|
|
|
|
|
|
|
|
3161
|
|
|
|
|
|
|
Prepend -llibrary to LIBS for the first library found to contain function. |
3162
|
|
|
|
|
|
|
|
3163
|
|
|
|
|
|
|
If linking with library results in unresolved symbols that would be |
3164
|
|
|
|
|
|
|
resolved by linking with additional libraries, give those libraries as |
3165
|
|
|
|
|
|
|
the I argument: e.g., C<[qw(Xt X11)]> or C<[qw(intl), |
3166
|
|
|
|
|
|
|
qw(intl iconv)]>. Otherwise, this method fails to detect that function |
3167
|
|
|
|
|
|
|
is present, because linking the test program always fails with unresolved |
3168
|
|
|
|
|
|
|
symbols. |
3169
|
|
|
|
|
|
|
|
3170
|
|
|
|
|
|
|
The result of this test is cached in the ac_cv_search_function variable |
3171
|
|
|
|
|
|
|
as "none required" if function is already available, as C<0> if no |
3172
|
|
|
|
|
|
|
library containing function was found, otherwise as the -llibrary option |
3173
|
|
|
|
|
|
|
that needs to be prepended to LIBS. |
3174
|
|
|
|
|
|
|
|
3175
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
3176
|
|
|
|
|
|
|
to I or I are executed, respectively. |
3177
|
|
|
|
|
|
|
If any of I, I is defined, |
3178
|
|
|
|
|
|
|
both callbacks are passed to L as I or |
3179
|
|
|
|
|
|
|
I to C, respectively. Given callbacks |
3180
|
|
|
|
|
|
|
for I or I are called for |
3181
|
|
|
|
|
|
|
each library checked using L receiving the library as |
3182
|
|
|
|
|
|
|
first argument and all C<@other_libs> subsequently. |
3183
|
|
|
|
|
|
|
|
3184
|
|
|
|
|
|
|
=cut |
3185
|
|
|
|
|
|
|
|
3186
|
|
|
|
|
|
|
sub search_libs |
3187
|
|
|
|
|
|
|
{ |
3188
|
7
|
|
|
7
|
1
|
23
|
my $options = {}; |
3189
|
7
|
100
|
66
|
|
|
102
|
scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_; |
3190
|
7
|
|
|
|
|
48
|
my $self = shift->_get_instance(); |
3191
|
7
|
|
|
|
|
29
|
my ($func, $libs, @other_libs, @other_link_flags) = @_; |
3192
|
|
|
|
|
|
|
|
3193
|
7
|
50
|
33
|
|
|
149
|
(defined($libs) and "ARRAY" eq ref($libs) and scalar(@{$libs}) > 0) |
|
7
|
|
33
|
|
|
54
|
|
3194
|
|
|
|
|
|
|
or return 0; # XXX would prefer croak |
3195
|
7
|
50
|
|
|
|
34
|
return 0 unless $func; |
3196
|
|
|
|
|
|
|
|
3197
|
|
|
|
|
|
|
scalar(@other_libs) == 1 |
3198
|
|
|
|
|
|
|
and ref($other_libs[0]) eq "ARRAY" |
3199
|
7
|
50
|
33
|
|
|
39
|
and @other_libs = @{$other_libs[0]}; |
|
0
|
|
|
|
|
0
|
|
3200
|
|
|
|
|
|
|
|
3201
|
|
|
|
|
|
|
scalar(@other_link_flags) == 1 |
3202
|
|
|
|
|
|
|
and ref($other_link_flags[0]) eq "ARRAY" |
3203
|
7
|
50
|
33
|
|
|
28
|
and @other_link_flags = @{$other_link_flags[0]}; |
|
0
|
|
|
|
|
0
|
|
3204
|
|
|
|
|
|
|
|
3205
|
7
|
|
|
|
|
48
|
my $cache_name = $self->_cache_name("search", $func); |
3206
|
|
|
|
|
|
|
my $check_sub = sub { |
3207
|
7
|
|
|
7
|
|
72
|
my $conftest = $self->lang_call("", $func); |
3208
|
|
|
|
|
|
|
|
3209
|
7
|
|
|
|
|
19
|
my @save_libs = @{$self->{extra_libs}}; |
|
7
|
|
|
|
|
25
|
|
3210
|
7
|
|
|
|
|
12
|
my @save_extra = @{$self->{extra_link_flags}}; |
|
7
|
|
|
|
|
20
|
|
3211
|
7
|
|
|
|
|
12
|
my $have_lib = 0; |
3212
|
|
|
|
|
|
|
|
3213
|
|
|
|
|
|
|
my $if_else_sub = sub { |
3214
|
9
|
|
|
|
|
36
|
my ($libstest, @other) = @_; |
3215
|
9
|
100
|
|
|
|
28
|
defined($libstest) and unshift(@{$self->{extra_libs}}, $libstest, @other); |
|
2
|
|
|
|
|
19
|
|
3216
|
|
|
|
|
|
|
$self->link_if_else( |
3217
|
|
|
|
|
|
|
$conftest, |
3218
|
|
|
|
|
|
|
{ |
3219
|
|
|
|
|
|
|
( |
3220
|
|
|
|
|
|
|
$options->{action_on_lib_true} && "CODE" eq ref $options->{action_on_lib_true} |
3221
|
6
|
|
|
|
|
120
|
? (action_on_true => sub { $options->{action_on_lib_true}->($libstest, @other, @_) }) |
3222
|
|
|
|
|
|
|
: () |
3223
|
|
|
|
|
|
|
), |
3224
|
|
|
|
|
|
|
( |
3225
|
|
|
|
|
|
|
$options->{action_on_lib_false} && "CODE" eq ref $options->{action_on_lib_false} |
3226
|
1
|
|
|
|
|
24
|
? (action_on_false => sub { $options->{action_on_lib_false}->($libstest, @other, @_) }) |
3227
|
9
|
100
|
66
|
|
|
184
|
: () |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
3228
|
|
|
|
|
|
|
), |
3229
|
|
|
|
|
|
|
} |
3230
|
|
|
|
|
|
|
) and ($have_lib = defined($libstest) ? $libstest : "none required"); |
3231
|
7
|
|
|
|
|
71
|
}; |
3232
|
|
|
|
|
|
|
|
3233
|
|
|
|
|
|
|
LIBTEST: |
3234
|
7
|
|
|
|
|
29
|
foreach my $libstest (undef, @$libs) |
3235
|
|
|
|
|
|
|
{ |
3236
|
9
|
|
|
|
|
2111
|
foreach my $linkextra (undef, @other_link_flags) |
3237
|
|
|
|
|
|
|
{ |
3238
|
|
|
|
|
|
|
# XXX would local work on array refs? can we omit @save_libs? |
3239
|
9
|
|
|
|
|
42
|
$self->{extra_libs} = [@save_libs]; |
3240
|
9
|
|
|
|
|
26
|
$self->{extra_link_flags} = [@save_extra]; |
3241
|
9
|
50
|
66
|
|
|
61
|
if (defined $libstest and scalar(@other_libs) > 1 and ref($other_libs[0]) eq "ARRAY") |
|
|
|
33
|
|
|
|
|
3242
|
|
|
|
|
|
|
{ |
3243
|
0
|
|
|
|
|
0
|
foreach my $ol (@other_libs) |
3244
|
|
|
|
|
|
|
{ |
3245
|
0
|
0
|
|
|
|
0
|
$if_else_sub->($libstest, @{$ol}) and last LIBTEST; |
|
0
|
|
|
|
|
0
|
|
3246
|
|
|
|
|
|
|
} |
3247
|
|
|
|
|
|
|
} |
3248
|
|
|
|
|
|
|
else |
3249
|
|
|
|
|
|
|
{ |
3250
|
9
|
100
|
|
|
|
28
|
$if_else_sub->($libstest, @other_libs) and last LIBTEST; |
3251
|
|
|
|
|
|
|
} |
3252
|
|
|
|
|
|
|
} |
3253
|
|
|
|
|
|
|
} |
3254
|
|
|
|
|
|
|
|
3255
|
7
|
|
|
|
|
8118
|
$self->{extra_libs} = [@save_libs]; |
3256
|
|
|
|
|
|
|
|
3257
|
|
|
|
|
|
|
$have_lib |
3258
|
|
|
|
|
|
|
and $options->{action_on_true} |
3259
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
3260
|
7
|
50
|
33
|
|
|
120
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
3261
|
|
|
|
|
|
|
|
3262
|
|
|
|
|
|
|
$options->{action_on_false} |
3263
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
3264
|
|
|
|
|
|
|
and !$have_lib |
3265
|
7
|
0
|
33
|
|
|
51
|
and $options->{action_on_false}->(); |
|
|
|
33
|
|
|
|
|
3266
|
|
|
|
|
|
|
|
3267
|
7
|
|
|
|
|
238
|
$have_lib; |
3268
|
7
|
|
|
|
|
93
|
}; |
3269
|
|
|
|
|
|
|
|
3270
|
|
|
|
|
|
|
return $self->check_cached( |
3271
|
|
|
|
|
|
|
$cache_name, |
3272
|
|
|
|
|
|
|
"for library containing $func", |
3273
|
|
|
|
|
|
|
$check_sub, |
3274
|
|
|
|
|
|
|
{ |
3275
|
|
|
|
|
|
|
action_on_true => sub { |
3276
|
|
|
|
|
|
|
$self->cache_val($cache_name) eq "none required" |
3277
|
7
|
100
|
|
7
|
|
45
|
or unshift(@{$self->{extra_libs}}, $self->cache_val($cache_name)); |
|
2
|
|
|
|
|
14
|
|
3278
|
|
|
|
|
|
|
|
3279
|
|
|
|
|
|
|
$options->{action_on_cache_true} |
3280
|
|
|
|
|
|
|
and ref $options->{action_on_cache_true} eq "CODE" |
3281
|
7
|
50
|
33
|
|
|
95
|
and $options->{action_on_cache_true}->(); |
3282
|
|
|
|
|
|
|
}, |
3283
|
7
|
50
|
|
|
|
128
|
($options->{action_on_cache_false} ? (action_on_false => $options->{action_on_cache_false}) : ()) |
3284
|
|
|
|
|
|
|
} |
3285
|
|
|
|
|
|
|
); |
3286
|
|
|
|
|
|
|
} |
3287
|
|
|
|
|
|
|
|
3288
|
3
|
|
|
3
|
|
63
|
sub _check_lm_funcs { qw(log2 pow log10 log exp sqrt) } |
3289
|
|
|
|
|
|
|
|
3290
|
|
|
|
|
|
|
=head2 check_lm( \%options? ) |
3291
|
|
|
|
|
|
|
|
3292
|
|
|
|
|
|
|
This method is used to check if some common C functions are |
3293
|
|
|
|
|
|
|
available, and if C<-lm> is needed. Returns the empty string if no |
3294
|
|
|
|
|
|
|
library is needed, or the "-lm" string if libm is needed. |
3295
|
|
|
|
|
|
|
|
3296
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
3297
|
|
|
|
|
|
|
to I or I are executed, respectively. |
3298
|
|
|
|
|
|
|
Each of existing key/value pairs using I (as |
3299
|
|
|
|
|
|
|
I having the name of the tested functions as first argument), |
3300
|
|
|
|
|
|
|
I (as I having the name of the tested |
3301
|
|
|
|
|
|
|
functions as first argument), I (as |
3302
|
|
|
|
|
|
|
I having the name of the tested functions as first |
3303
|
|
|
|
|
|
|
argument), I (as I having |
3304
|
|
|
|
|
|
|
the name of the tested functions as first argument) as key are passed- |
3305
|
|
|
|
|
|
|
through to each call of L. |
3306
|
|
|
|
|
|
|
Given callbacks for I, I, |
3307
|
|
|
|
|
|
|
I or I are passed to the |
3308
|
|
|
|
|
|
|
call of L. |
3309
|
|
|
|
|
|
|
|
3310
|
|
|
|
|
|
|
B that I and I or |
3311
|
|
|
|
|
|
|
I and I cannot be used |
3312
|
|
|
|
|
|
|
at the same time, respectively. |
3313
|
|
|
|
|
|
|
|
3314
|
|
|
|
|
|
|
=cut |
3315
|
|
|
|
|
|
|
|
3316
|
|
|
|
|
|
|
sub check_lm |
3317
|
|
|
|
|
|
|
{ |
3318
|
3
|
|
|
3
|
1
|
457
|
my $options = {}; |
3319
|
3
|
50
|
33
|
|
|
46
|
scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_; |
3320
|
3
|
|
|
|
|
13
|
my $self = shift->_get_instance(); |
3321
|
|
|
|
|
|
|
|
3322
|
|
|
|
|
|
|
defined $options->{action_on_lib_true} |
3323
|
|
|
|
|
|
|
and defined $options->{action_on_func_lib_true} |
3324
|
3
|
100
|
66
|
|
|
390
|
and croak("action_on_lib_true and action_on_func_lib_true cannot be used together"); |
3325
|
|
|
|
|
|
|
defined $options->{action_on_lib_false} |
3326
|
|
|
|
|
|
|
and defined $options->{action_on_func_lib_false} |
3327
|
2
|
100
|
66
|
|
|
134
|
and croak("action_on_lib_false and action_on_func_lib_false cannot be used together"); |
3328
|
|
|
|
|
|
|
|
3329
|
1
|
|
|
|
|
2
|
my %pass_options; |
3330
|
1
|
50
|
|
|
|
4
|
defined $options->{action_on_cache_true} and $pass_options{action_on_cache_true} = $options->{action_on_cache_true}; |
3331
|
1
|
50
|
|
|
|
8
|
defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false}; |
3332
|
1
|
50
|
|
|
|
10
|
defined $options->{action_on_lib_true} and $pass_options{action_on_lib_true} = $options->{action_on_lib_true}; |
3333
|
1
|
50
|
|
|
|
5
|
defined $options->{action_on_lib_false} and $pass_options{action_on_lib_false} = $options->{action_on_lib_false}; |
3334
|
|
|
|
|
|
|
|
3335
|
1
|
|
|
|
|
2
|
my $fail = 0; |
3336
|
1
|
|
|
|
|
2
|
my $required = ""; |
3337
|
1
|
|
|
|
|
13
|
my @math_funcs = $self->_check_lm_funcs; |
3338
|
1
|
|
|
|
|
4
|
for my $func (@math_funcs) |
3339
|
|
|
|
|
|
|
{ |
3340
|
|
|
|
|
|
|
my $ans = $self->search_libs( |
3341
|
|
|
|
|
|
|
$func, |
3342
|
|
|
|
|
|
|
['m'], |
3343
|
|
|
|
|
|
|
{ |
3344
|
|
|
|
|
|
|
%pass_options, |
3345
|
|
|
|
|
|
|
( |
3346
|
|
|
|
|
|
|
$options->{action_on_func_true} && "CODE" eq ref $options->{action_on_func_true} |
3347
|
0
|
|
|
0
|
|
0
|
? (action_on_true => sub { $options->{action_on_func_true}->($func, @_) }) |
3348
|
|
|
|
|
|
|
: () |
3349
|
|
|
|
|
|
|
), |
3350
|
|
|
|
|
|
|
( |
3351
|
|
|
|
|
|
|
$options->{action_on_func_false} && "CODE" eq ref $options->{action_on_func_false} |
3352
|
0
|
|
|
0
|
|
0
|
? (action_on_false => sub { $options->{action_on_func_false}->($func, @_) }) |
3353
|
|
|
|
|
|
|
: () |
3354
|
|
|
|
|
|
|
), |
3355
|
|
|
|
|
|
|
( |
3356
|
|
|
|
|
|
|
$options->{action_on_func_lib_true} && "CODE" eq ref $options->{action_on_func_lib_true} |
3357
|
6
|
|
|
6
|
|
171
|
? (action_on_lib_true => sub { $options->{action_on_func_lib_true}->($func, @_) }) |
3358
|
|
|
|
|
|
|
: () |
3359
|
|
|
|
|
|
|
), |
3360
|
|
|
|
|
|
|
( |
3361
|
|
|
|
|
|
|
$options->{action_on_func_lib_false} && "CODE" eq ref $options->{action_on_func_lib_false} |
3362
|
1
|
|
|
1
|
|
32
|
? (action_on_lib_false => sub { $options->{action_on_func_lib_false}->($func, @_) }) |
3363
|
6
|
50
|
33
|
|
|
265
|
: () |
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
3364
|
|
|
|
|
|
|
), |
3365
|
|
|
|
|
|
|
}, |
3366
|
|
|
|
|
|
|
); |
3367
|
|
|
|
|
|
|
|
3368
|
6
|
50
|
|
|
|
218
|
$ans or $fail = 1; |
3369
|
6
|
100
|
|
|
|
54
|
$ans ne "none required" and $required = $ans; |
3370
|
|
|
|
|
|
|
} |
3371
|
|
|
|
|
|
|
|
3372
|
|
|
|
|
|
|
!$fail |
3373
|
|
|
|
|
|
|
and $options->{action_on_true} |
3374
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
3375
|
1
|
50
|
33
|
|
|
39
|
and $options->{action_on_true}->(); |
|
|
|
33
|
|
|
|
|
3376
|
|
|
|
|
|
|
|
3377
|
|
|
|
|
|
|
$fail |
3378
|
|
|
|
|
|
|
and $options->{action_on_false} |
3379
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
3380
|
1
|
0
|
33
|
|
|
11
|
and $options->{action_on_false}->(); |
|
|
|
0
|
|
|
|
|
3381
|
|
|
|
|
|
|
|
3382
|
1
|
|
|
|
|
18
|
$required; |
3383
|
|
|
|
|
|
|
} |
3384
|
|
|
|
|
|
|
|
3385
|
|
|
|
|
|
|
=head2 pkg_config_package_flags($package, \%options?) |
3386
|
|
|
|
|
|
|
|
3387
|
|
|
|
|
|
|
use Config::AutoConf |
3388
|
|
|
|
|
|
|
|
3389
|
|
|
|
|
|
|
my $c = Config::AutoConf->new; |
3390
|
|
|
|
|
|
|
$c->pkg_config_package_flags('log4cplus'); |
3391
|
|
|
|
|
|
|
WriteMakefile( |
3392
|
|
|
|
|
|
|
... |
3393
|
|
|
|
|
|
|
INC => $c->_get_extra_compiler_flags, |
3394
|
|
|
|
|
|
|
LIBS => $c->_get_extra_linker_flags, |
3395
|
|
|
|
|
|
|
); |
3396
|
|
|
|
|
|
|
|
3397
|
|
|
|
|
|
|
Search for C flags for package as specified. The flags which are |
3398
|
|
|
|
|
|
|
extracted are C<--cflags> and C<--libs>. The extracted flags are appended |
3399
|
|
|
|
|
|
|
to the global C, C or C, |
3400
|
|
|
|
|
|
|
respectively. Distinguishing between C and C |
3401
|
|
|
|
|
|
|
is essential to avoid conflicts with L |
3402
|
|
|
|
|
|
|
and family. In case, no I matching given criteria |
3403
|
|
|
|
|
|
|
could be found, return a C value (C<0>). |
3404
|
|
|
|
|
|
|
|
3405
|
|
|
|
|
|
|
The C flags are taken from I |
3406
|
|
|
|
|
|
|
C<< ${package}_CFLAGS >> or C<< ${package}_LIBS >> when defined, respectively. |
3407
|
|
|
|
|
|
|
It will be a nice touch to document the particular environment variables |
3408
|
|
|
|
|
|
|
for your build procedure - as for above example it should be |
3409
|
|
|
|
|
|
|
|
3410
|
|
|
|
|
|
|
$ env log4cplus_CFLAGS="-I/opt/coolapp/include" \ |
3411
|
|
|
|
|
|
|
log4cplus_LIBS="-L/opt/coolapp/lib -Wl,-R/opt/coolapp/lib -llog4cplus" \ |
3412
|
|
|
|
|
|
|
perl Makefile.PL |
3413
|
|
|
|
|
|
|
|
3414
|
|
|
|
|
|
|
Call C with the package you're looking for and |
3415
|
|
|
|
|
|
|
optional callback whether found or not. |
3416
|
|
|
|
|
|
|
|
3417
|
|
|
|
|
|
|
To support stage compiling properly (C vs. library file location), |
3418
|
|
|
|
|
|
|
the internal representation is a moving target. Do not use the result |
3419
|
|
|
|
|
|
|
directly - the getters L<_get_extra_compiler_flags|/_get_extra_compiler_flags> |
3420
|
|
|
|
|
|
|
and L<_get_extra_linker_flags|/_get_extra_linker_flags> are strongly |
3421
|
|
|
|
|
|
|
encouraged. In case this is not possible, please open a ticket to get |
3422
|
|
|
|
|
|
|
informed on invasive changes. |
3423
|
|
|
|
|
|
|
|
3424
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
3425
|
|
|
|
|
|
|
to I or I are executed, respectively. |
3426
|
|
|
|
|
|
|
If any of I, I is defined, |
3427
|
|
|
|
|
|
|
both callbacks are passed to L as I or |
3428
|
|
|
|
|
|
|
I to L, respectively. |
3429
|
|
|
|
|
|
|
|
3430
|
|
|
|
|
|
|
=cut |
3431
|
|
|
|
|
|
|
|
3432
|
|
|
|
|
|
|
my $_pkg_config_prog; |
3433
|
|
|
|
|
|
|
|
3434
|
|
|
|
|
|
|
sub _pkg_config_flag |
3435
|
|
|
|
|
|
|
{ |
3436
|
0
|
0
|
|
0
|
|
0
|
defined $_pkg_config_prog or croak("pkg_config_prog required"); |
3437
|
0
|
|
|
|
|
0
|
my @pkg_config_args = @_; |
3438
|
|
|
|
|
|
|
my ($stdout, $stderr, $exit) = |
3439
|
0
|
|
|
0
|
|
0
|
capture { system($_pkg_config_prog, @pkg_config_args); }; |
|
0
|
|
|
|
|
0
|
|
3440
|
0
|
|
|
|
|
0
|
chomp $stdout; |
3441
|
0
|
0
|
|
|
|
0
|
0 == $exit and return $stdout; |
3442
|
0
|
|
|
|
|
0
|
return $exit; |
3443
|
|
|
|
|
|
|
} |
3444
|
|
|
|
|
|
|
|
3445
|
|
|
|
|
|
|
sub pkg_config_package_flags |
3446
|
|
|
|
|
|
|
{ |
3447
|
0
|
|
|
0
|
1
|
0
|
my $options = {}; |
3448
|
0
|
0
|
0
|
|
|
0
|
scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_; |
3449
|
0
|
|
|
|
|
0
|
my ($self, $package) = @_; |
3450
|
0
|
|
|
|
|
0
|
$self = $self->_get_instance(); |
3451
|
|
|
|
|
|
|
|
3452
|
0
|
|
|
|
|
0
|
(my $pkgpfx = $package) =~ s/^(\w+).*?$/$1/; |
3453
|
0
|
|
|
|
|
0
|
my $cache_name = $self->_cache_name("pkg", $pkgpfx); |
3454
|
|
|
|
|
|
|
|
3455
|
0
|
0
|
|
|
|
0
|
defined $_pkg_config_prog or $_pkg_config_prog = $self->{cache}->{$self->_cache_name("prog", "PKG_CONFIG")}; |
3456
|
0
|
0
|
|
|
|
0
|
defined $_pkg_config_prog or $_pkg_config_prog = $self->check_prog_pkg_config; |
3457
|
|
|
|
|
|
|
my $check_sub = sub { |
3458
|
0
|
|
|
0
|
|
0
|
my (@pkg_cflags, @pkg_libs); |
3459
|
|
|
|
|
|
|
|
3460
|
0
|
|
|
|
|
0
|
(my $ENV_CFLAGS = $package) =~ s/^(\w+).*?$/$1_CFLAGS/; |
3461
|
0
|
|
|
|
|
0
|
(my $ENV_LIBS = $package) =~ s/^(\w+).*?$/$1_LIBS/; |
3462
|
|
|
|
|
|
|
|
3463
|
|
|
|
|
|
|
my $pkg_exists = 0 + ( |
3464
|
|
|
|
|
|
|
defined $ENV{$ENV_CFLAGS} |
3465
|
0
|
|
0
|
|
|
0
|
or defined $ENV{$ENV_LIBS} |
3466
|
|
|
|
|
|
|
or _pkg_config_flag($package, "--exists") eq "" |
3467
|
|
|
|
|
|
|
); |
3468
|
0
|
0
|
0
|
|
|
0
|
looks_like_number($pkg_exists) and $pkg_exists == 0 and return 0; |
3469
|
|
|
|
|
|
|
|
3470
|
|
|
|
|
|
|
my $CFLAGS = |
3471
|
|
|
|
|
|
|
defined $ENV{$ENV_CFLAGS} |
3472
|
0
|
0
|
|
|
|
0
|
? $ENV{$ENV_CFLAGS} |
3473
|
|
|
|
|
|
|
: _pkg_config_flag($package, "--cflags"); |
3474
|
|
|
|
|
|
|
$CFLAGS and not looks_like_number($CFLAGS) and @pkg_cflags = ( |
3475
|
0
|
|
|
|
|
0
|
map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; Text::ParseWords::shellwords $_; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
3476
|
|
|
|
|
|
|
split(m/\n/, $CFLAGS) |
3477
|
0
|
0
|
0
|
|
|
0
|
) and push @{$self->{extra_preprocess_flags}}, @pkg_cflags; |
|
0
|
|
0
|
|
|
0
|
|
3478
|
|
|
|
|
|
|
|
3479
|
|
|
|
|
|
|
# do not separate between libs and extra (for now) - they come with -l prepended |
3480
|
|
|
|
|
|
|
my $LIBS = |
3481
|
|
|
|
|
|
|
defined $ENV{$ENV_LIBS} |
3482
|
0
|
0
|
|
|
|
0
|
? $ENV{$ENV_LIBS} |
3483
|
|
|
|
|
|
|
: _pkg_config_flag($package, "--libs"); |
3484
|
|
|
|
|
|
|
$LIBS and not looks_like_number($LIBS) and @pkg_libs = ( |
3485
|
0
|
0
|
0
|
|
|
0
|
map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; Text::ParseWords::shellwords $_; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
3486
|
|
|
|
|
|
|
split(m/\n/, $LIBS) |
3487
|
|
|
|
|
|
|
); |
3488
|
0
|
0
|
|
|
|
0
|
@pkg_libs and push @{$self->{extra_link_flags}}, grep { $_ !~ m/^-l/ } @pkg_libs; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
3489
|
0
|
0
|
|
|
|
0
|
@pkg_libs and push @{$self->{extra_libs}}, map { (my $l = $_) =~ s/^-l//; $l } grep { $_ =~ m/^-l/ } @pkg_libs; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
3490
|
|
|
|
|
|
|
|
3491
|
0
|
|
|
|
|
0
|
my $pkg_config_flags = join(" ", @pkg_cflags, @pkg_libs); |
3492
|
|
|
|
|
|
|
|
3493
|
|
|
|
|
|
|
$pkg_config_flags |
3494
|
|
|
|
|
|
|
and $options->{action_on_true} |
3495
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
3496
|
0
|
0
|
0
|
|
|
0
|
and $options->{action_on_true}->(); |
|
|
|
0
|
|
|
|
|
3497
|
|
|
|
|
|
|
|
3498
|
|
|
|
|
|
|
$options->{action_on_false} |
3499
|
|
|
|
|
|
|
and ref $options->{action_on_false} eq "CODE" |
3500
|
|
|
|
|
|
|
and !$pkg_config_flags |
3501
|
0
|
0
|
0
|
|
|
0
|
and $options->{action_on_false}->(); |
|
|
|
0
|
|
|
|
|
3502
|
|
|
|
|
|
|
|
3503
|
0
|
|
|
|
|
0
|
$pkg_config_flags; |
3504
|
0
|
|
|
|
|
0
|
}; |
3505
|
|
|
|
|
|
|
|
3506
|
|
|
|
|
|
|
$self->check_cached( |
3507
|
|
|
|
|
|
|
$cache_name, |
3508
|
|
|
|
|
|
|
"for pkg-config package of $package", |
3509
|
|
|
|
|
|
|
$check_sub, |
3510
|
|
|
|
|
|
|
{ |
3511
|
|
|
|
|
|
|
($options->{action_on_cache_true} ? (action_on_true => $options->{action_on_cache_true}) : ()), |
3512
|
0
|
0
|
|
|
|
0
|
($options->{action_on_cache_false} ? (action_on_false => $options->{action_on_cache_false}) : ()) |
|
|
0
|
|
|
|
|
|
3513
|
|
|
|
|
|
|
} |
3514
|
|
|
|
|
|
|
); |
3515
|
|
|
|
|
|
|
} |
3516
|
|
|
|
|
|
|
|
3517
|
|
|
|
|
|
|
=head2 _check_mm_pureperl_build_wanted |
3518
|
|
|
|
|
|
|
|
3519
|
|
|
|
|
|
|
This method proves the C<_argv> attribute and (when set) the C |
3520
|
|
|
|
|
|
|
whether they contain I or not. The attribute C<_force_xs> |
3521
|
|
|
|
|
|
|
is set as appropriate, which allows a compile test to bail out when C |
3522
|
|
|
|
|
|
|
is called with I. |
3523
|
|
|
|
|
|
|
|
3524
|
|
|
|
|
|
|
=cut |
3525
|
|
|
|
|
|
|
|
3526
|
|
|
|
|
|
|
sub _check_mm_pureperl_build_wanted |
3527
|
|
|
|
|
|
|
{ |
3528
|
0
|
|
|
0
|
|
0
|
my $self = shift->_get_instance; |
3529
|
|
|
|
|
|
|
|
3530
|
0
|
0
|
|
|
|
0
|
defined $ENV{PERL_MM_OPT} and my @env_args = split " ", $ENV{PERL_MM_OPT}; |
3531
|
|
|
|
|
|
|
|
3532
|
0
|
|
|
|
|
0
|
foreach my $arg (@{$self->{_argv}}, @env_args) |
|
0
|
|
|
|
|
0
|
|
3533
|
|
|
|
|
|
|
{ |
3534
|
0
|
0
|
|
|
|
0
|
$arg =~ m/^PUREPERL_ONLY=(.*)$/ and return int($1); |
3535
|
|
|
|
|
|
|
} |
3536
|
|
|
|
|
|
|
|
3537
|
0
|
|
|
|
|
0
|
0; |
3538
|
|
|
|
|
|
|
} |
3539
|
|
|
|
|
|
|
|
3540
|
|
|
|
|
|
|
=head2 _check_mb_pureperl_build_wanted |
3541
|
|
|
|
|
|
|
|
3542
|
|
|
|
|
|
|
This method proves the C<_argv> attribute and (when set) the C |
3543
|
|
|
|
|
|
|
whether they contain I<--pureperl-only> or not. |
3544
|
|
|
|
|
|
|
|
3545
|
|
|
|
|
|
|
=cut |
3546
|
|
|
|
|
|
|
|
3547
|
|
|
|
|
|
|
sub _check_mb_pureperl_build_wanted |
3548
|
|
|
|
|
|
|
{ |
3549
|
0
|
|
|
0
|
|
0
|
my $self = shift->_get_instance; |
3550
|
|
|
|
|
|
|
|
3551
|
0
|
0
|
|
|
|
0
|
defined $ENV{PERL_MB_OPT} and my @env_args = split " ", $ENV{PERL_MB_OPT}; |
3552
|
|
|
|
|
|
|
|
3553
|
0
|
|
|
|
|
0
|
foreach my $arg (@{$self->{_argv}}, @env_args) |
|
0
|
|
|
|
|
0
|
|
3554
|
|
|
|
|
|
|
{ |
3555
|
0
|
0
|
|
|
|
0
|
$arg eq "--pureperl-only" and return 1; |
3556
|
|
|
|
|
|
|
} |
3557
|
|
|
|
|
|
|
|
3558
|
0
|
|
|
|
|
0
|
0; |
3559
|
|
|
|
|
|
|
} |
3560
|
|
|
|
|
|
|
|
3561
|
|
|
|
|
|
|
=head2 _check_pureperl_required |
3562
|
|
|
|
|
|
|
|
3563
|
|
|
|
|
|
|
This method calls C<_check_mm_pureperl_build_wanted> when running under |
3564
|
|
|
|
|
|
|
L (C) or C<_check_mb_pureperl_build_wanted> |
3565
|
|
|
|
|
|
|
when running under a C (L compatible) environment. |
3566
|
|
|
|
|
|
|
|
3567
|
|
|
|
|
|
|
When neither is found (C<$0> contains neither C nor C), |
3568
|
|
|
|
|
|
|
simply 0 is returned. |
3569
|
|
|
|
|
|
|
|
3570
|
|
|
|
|
|
|
=cut |
3571
|
|
|
|
|
|
|
|
3572
|
|
|
|
|
|
|
sub _check_pureperl_required |
3573
|
|
|
|
|
|
|
{ |
3574
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
3575
|
0
|
0
|
|
|
|
0
|
$0 =~ m/Makefile\.PL$/i and return $self->_check_mm_pureperl_build_wanted(@_); |
3576
|
0
|
0
|
|
|
|
0
|
$0 =~ m/Build\.PL$/i and return $self->_check_mb_pureperl_build_wanted(@_); |
3577
|
|
|
|
|
|
|
|
3578
|
0
|
|
|
|
|
0
|
0; |
3579
|
|
|
|
|
|
|
} |
3580
|
|
|
|
|
|
|
|
3581
|
|
|
|
|
|
|
=head2 check_pureperl_required |
3582
|
|
|
|
|
|
|
|
3583
|
|
|
|
|
|
|
This check method proves whether a pure perl build is wanted or not by |
3584
|
|
|
|
|
|
|
cached-checking C<< $self->_check_pureperl_required >>. |
3585
|
|
|
|
|
|
|
|
3586
|
|
|
|
|
|
|
=cut |
3587
|
|
|
|
|
|
|
|
3588
|
|
|
|
|
|
|
sub check_pureperl_required |
3589
|
|
|
|
|
|
|
{ |
3590
|
0
|
|
|
0
|
1
|
0
|
my $self = shift->_get_instance; |
3591
|
0
|
|
|
|
|
0
|
my $cache_name = $self->_cache_name(qw(pureperl required)); |
3592
|
0
|
|
|
0
|
|
0
|
$self->check_cached($cache_name, "whether pureperl is required", sub { $self->_check_pureperl_required }); |
|
0
|
|
|
|
|
0
|
|
3593
|
|
|
|
|
|
|
} |
3594
|
|
|
|
|
|
|
|
3595
|
|
|
|
|
|
|
=head2 check_produce_xs_build |
3596
|
|
|
|
|
|
|
|
3597
|
|
|
|
|
|
|
This routine checks whether XS can be produced. Therefore it does |
3598
|
|
|
|
|
|
|
following checks in given order: |
3599
|
|
|
|
|
|
|
|
3600
|
|
|
|
|
|
|
=over 4 |
3601
|
|
|
|
|
|
|
|
3602
|
|
|
|
|
|
|
=item * |
3603
|
|
|
|
|
|
|
|
3604
|
|
|
|
|
|
|
check pure perl environment variables (L) or |
3605
|
|
|
|
|
|
|
command line arguments and return false when pure perl is requested |
3606
|
|
|
|
|
|
|
|
3607
|
|
|
|
|
|
|
=item * |
3608
|
|
|
|
|
|
|
|
3609
|
|
|
|
|
|
|
check whether a compiler is available (L) and |
3610
|
|
|
|
|
|
|
return false if none found |
3611
|
|
|
|
|
|
|
|
3612
|
|
|
|
|
|
|
=item * |
3613
|
|
|
|
|
|
|
|
3614
|
|
|
|
|
|
|
check whether a test program accessing Perl API can be compiled and |
3615
|
|
|
|
|
|
|
die with error if not |
3616
|
|
|
|
|
|
|
|
3617
|
|
|
|
|
|
|
=back |
3618
|
|
|
|
|
|
|
|
3619
|
|
|
|
|
|
|
When all checks passed successfully, return a true value. |
3620
|
|
|
|
|
|
|
|
3621
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
3622
|
|
|
|
|
|
|
to I or I are executed, respectively. |
3623
|
|
|
|
|
|
|
|
3624
|
|
|
|
|
|
|
=cut |
3625
|
|
|
|
|
|
|
|
3626
|
|
|
|
|
|
|
sub check_produce_xs_build |
3627
|
|
|
|
|
|
|
{ |
3628
|
0
|
|
|
0
|
1
|
0
|
my $options = {}; |
3629
|
0
|
0
|
0
|
|
|
0
|
scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_; |
3630
|
0
|
|
|
|
|
0
|
my $self = shift->_get_instance; |
3631
|
0
|
0
|
|
|
|
0
|
$self->check_pureperl_required() and return _on_return_callback_helper(0, $options, "action_on_false"); |
3632
|
0
|
0
|
0
|
|
|
0
|
eval { $self->check_valid_compilers($_[0] || [qw(C)]) } |
|
0
|
|
|
|
|
0
|
|
3633
|
|
|
|
|
|
|
or return _on_return_callback_helper(0, $options, "action_on_false"); |
3634
|
|
|
|
|
|
|
# XXX necessary check for $Config{useshrlib}? (need to dicuss with e.g. TuX, 99% likely return 0) |
3635
|
0
|
|
|
|
|
0
|
$self->check_compile_perlapi_or_die(); |
3636
|
|
|
|
|
|
|
|
3637
|
|
|
|
|
|
|
$options->{action_on_true} |
3638
|
|
|
|
|
|
|
and ref $options->{action_on_true} eq "CODE" |
3639
|
0
|
0
|
0
|
|
|
0
|
and $options->{action_on_true}->(); |
3640
|
|
|
|
|
|
|
|
3641
|
0
|
|
|
|
|
0
|
return 1; |
3642
|
|
|
|
|
|
|
} |
3643
|
|
|
|
|
|
|
|
3644
|
|
|
|
|
|
|
=head2 check_produce_loadable_xs_build |
3645
|
|
|
|
|
|
|
|
3646
|
|
|
|
|
|
|
This routine proves whether XS should be built and it's possible to create |
3647
|
|
|
|
|
|
|
a dynamic linked object which can be loaded using Perl's Dynaloader. |
3648
|
|
|
|
|
|
|
|
3649
|
|
|
|
|
|
|
The extension over L can be avoided by adding the |
3650
|
|
|
|
|
|
|
C to C<$ENV{PERL5_AC_OPTS}>. |
3651
|
|
|
|
|
|
|
|
3652
|
|
|
|
|
|
|
If the very last parameter contains a hash reference, C references |
3653
|
|
|
|
|
|
|
to I or I are executed, respectively. |
3654
|
|
|
|
|
|
|
|
3655
|
|
|
|
|
|
|
=cut |
3656
|
|
|
|
|
|
|
|
3657
|
|
|
|
|
|
|
sub check_produce_loadable_xs_build |
3658
|
|
|
|
|
|
|
{ |
3659
|
0
|
|
|
0
|
1
|
0
|
my $self = shift->_get_instance; |
3660
|
|
|
|
|
|
|
$self->check_produce_xs_build(@_) |
3661
|
|
|
|
|
|
|
and !$self->{c_ac_flags}->{notest_loadable_xs} |
3662
|
0
|
0
|
0
|
|
|
0
|
and $self->check_linkable_xs_so_or_die |
|
|
|
0
|
|
|
|
|
3663
|
|
|
|
|
|
|
and $self->check_loadable_xs_so_or_die; |
3664
|
|
|
|
|
|
|
} |
3665
|
|
|
|
|
|
|
|
3666
|
|
|
|
|
|
|
# |
3667
|
|
|
|
|
|
|
# |
3668
|
|
|
|
|
|
|
# Auxiliary funcs |
3669
|
|
|
|
|
|
|
# |
3670
|
|
|
|
|
|
|
|
3671
|
|
|
|
|
|
|
=head2 _set_argv |
3672
|
|
|
|
|
|
|
|
3673
|
|
|
|
|
|
|
Intended to act as a helper for evaluating given command line arguments. |
3674
|
|
|
|
|
|
|
Stores given arguments in instances C<_argv> attribute. |
3675
|
|
|
|
|
|
|
|
3676
|
|
|
|
|
|
|
Call once at very begin of C or C: |
3677
|
|
|
|
|
|
|
|
3678
|
|
|
|
|
|
|
Your::Pkg::Config::AutoConf->_set_args(@ARGV); |
3679
|
|
|
|
|
|
|
|
3680
|
|
|
|
|
|
|
=cut |
3681
|
|
|
|
|
|
|
|
3682
|
|
|
|
|
|
|
sub _set_argv |
3683
|
|
|
|
|
|
|
{ |
3684
|
0
|
|
|
0
|
|
0
|
my ($self, @argv) = @_; |
3685
|
0
|
|
|
|
|
0
|
$self = $self->_get_instance; |
3686
|
0
|
|
|
|
|
0
|
$self->{_argv} = \@argv; |
3687
|
0
|
|
|
|
|
0
|
return; |
3688
|
|
|
|
|
|
|
} |
3689
|
|
|
|
|
|
|
|
3690
|
|
|
|
|
|
|
sub _sanitize |
3691
|
|
|
|
|
|
|
{ |
3692
|
|
|
|
|
|
|
# This is hard coded, and maybe a little stupid... |
3693
|
20
|
|
|
20
|
|
32
|
my $x = shift; |
3694
|
20
|
|
|
|
|
44
|
$x =~ s/ //g; |
3695
|
20
|
|
|
|
|
27
|
$x =~ s/\///g; |
3696
|
20
|
|
|
|
|
31
|
$x =~ s/\\//g; |
3697
|
20
|
|
|
|
|
36
|
$x; |
3698
|
|
|
|
|
|
|
} |
3699
|
|
|
|
|
|
|
|
3700
|
|
|
|
|
|
|
sub _get_instance |
3701
|
|
|
|
|
|
|
{ |
3702
|
1620
|
100
|
|
1620
|
|
8833
|
ref $_[0] and return $_[0]; |
3703
|
15
|
100
|
|
|
|
51
|
defined $glob_instance or $glob_instance = $_[0]->new(); |
3704
|
15
|
|
|
|
|
33
|
$glob_instance; |
3705
|
|
|
|
|
|
|
} |
3706
|
|
|
|
|
|
|
|
3707
|
|
|
|
|
|
|
sub _get_builder |
3708
|
|
|
|
|
|
|
{ |
3709
|
179
|
|
|
179
|
|
678
|
my $self = $_[0]->_get_instance(); |
3710
|
|
|
|
|
|
|
|
3711
|
179
|
100
|
|
|
|
1091
|
ref $self->{lang_supported}->{$self->{lang}} eq "CODE" and $self->{lang_supported}->{$self->{lang}}->($self); |
3712
|
179
|
50
|
|
|
|
825
|
defined($self->{lang_supported}->{$self->{lang}}) or croak("Unsupported compile language \"" . $self->{lang} . "\""); |
3713
|
|
|
|
|
|
|
|
3714
|
179
|
|
|
|
|
5824
|
$self->{lang_supported}->{$self->{lang}}->new(); |
3715
|
|
|
|
|
|
|
} |
3716
|
|
|
|
|
|
|
|
3717
|
|
|
|
|
|
|
sub _set_language |
3718
|
|
|
|
|
|
|
{ |
3719
|
0
|
|
|
0
|
|
0
|
my $self = shift->_get_instance(); |
3720
|
0
|
|
|
|
|
0
|
my ($lang, $impl) = @_; |
3721
|
|
|
|
|
|
|
|
3722
|
0
|
0
|
|
|
|
0
|
defined($lang) or croak("Missing language"); |
3723
|
|
|
|
|
|
|
|
3724
|
|
|
|
|
|
|
defined($impl) |
3725
|
|
|
|
|
|
|
and defined($self->{lang_supported}->{$lang}) |
3726
|
|
|
|
|
|
|
and $impl ne $self->{lang_supported}->{$lang} |
3727
|
0
|
0
|
0
|
|
|
0
|
and croak("Language implementor ($impl) doesn't match exisiting one (" . $self->{lang_supported}->{$lang} . ")"); |
|
|
|
0
|
|
|
|
|
3728
|
|
|
|
|
|
|
|
3729
|
|
|
|
|
|
|
defined($impl) |
3730
|
|
|
|
|
|
|
and !defined($self->{lang_supported}->{$lang}) |
3731
|
0
|
0
|
0
|
|
|
0
|
and $self->{lang_supported}->{$lang} = $impl; |
3732
|
|
|
|
|
|
|
|
3733
|
0
|
0
|
|
|
|
0
|
ref $self->{lang_supported}->{$lang} eq "CODE" and $self->{lang_supported}->{$lang}->($self); |
3734
|
0
|
0
|
|
|
|
0
|
defined($self->{lang_supported}->{$lang}) or croak("Unsupported language \"$lang\""); |
3735
|
|
|
|
|
|
|
|
3736
|
0
|
0
|
|
|
|
0
|
defined($self->{extra_compile_flags}->{$lang}) or $self->{extra_compile_flags}->{$lang} = []; |
3737
|
|
|
|
|
|
|
|
3738
|
0
|
|
|
|
|
0
|
$self->{lang} = $lang; |
3739
|
|
|
|
|
|
|
|
3740
|
0
|
|
|
|
|
0
|
return; |
3741
|
|
|
|
|
|
|
} |
3742
|
|
|
|
|
|
|
|
3743
|
|
|
|
|
|
|
sub _on_return_callback_helper |
3744
|
|
|
|
|
|
|
{ |
3745
|
0
|
|
|
0
|
|
0
|
my $callback = pop @_; |
3746
|
0
|
|
|
|
|
0
|
my $options = pop @_; |
3747
|
|
|
|
|
|
|
$options->{$callback} |
3748
|
|
|
|
|
|
|
and ref $options->{$callback} eq "CODE" |
3749
|
0
|
0
|
0
|
|
|
0
|
and $options->{$callback}->(); |
3750
|
0
|
0
|
0
|
|
|
0
|
@_ and wantarray and return @_; |
3751
|
0
|
0
|
|
|
|
0
|
1 == scalar @_ and return $_[0]; |
3752
|
0
|
|
|
|
|
0
|
return; |
3753
|
|
|
|
|
|
|
} |
3754
|
|
|
|
|
|
|
|
3755
|
|
|
|
|
|
|
sub _fill_defines |
3756
|
|
|
|
|
|
|
{ |
3757
|
177
|
|
|
177
|
|
994
|
my ($self, $src, $action_if_true, $action_if_false) = @_; |
3758
|
177
|
50
|
|
|
|
766
|
ref $self or $self = $self->_get_instance(); |
3759
|
|
|
|
|
|
|
|
3760
|
177
|
|
|
|
|
805
|
my $conftest = ""; |
3761
|
177
|
|
|
|
|
578
|
while (my ($defname, $defcnt) = each(%{$self->{defines}})) |
|
6203
|
|
|
|
|
21260
|
|
3762
|
|
|
|
|
|
|
{ |
3763
|
6026
|
100
|
|
|
|
15522
|
$defcnt->[0] or next; |
3764
|
5893
|
50
|
|
|
|
16242
|
defined $defcnt->[1] and $conftest .= "/* " . $defcnt->[1] . " */\n"; |
3765
|
5893
|
|
|
|
|
14782
|
$conftest .= join(" ", "#define", $defname, $defcnt->[0]) . "\n"; |
3766
|
|
|
|
|
|
|
} |
3767
|
177
|
|
|
|
|
638
|
$conftest .= "/* end of conftest.h */\n"; |
3768
|
|
|
|
|
|
|
|
3769
|
177
|
|
|
|
|
3971
|
$conftest; |
3770
|
|
|
|
|
|
|
} |
3771
|
|
|
|
|
|
|
|
3772
|
|
|
|
|
|
|
# |
3773
|
|
|
|
|
|
|
# default includes taken from autoconf/headers.m4 |
3774
|
|
|
|
|
|
|
# |
3775
|
|
|
|
|
|
|
|
3776
|
|
|
|
|
|
|
=head2 _default_includes |
3777
|
|
|
|
|
|
|
|
3778
|
|
|
|
|
|
|
returns a string containing default includes for program prologue taken |
3779
|
|
|
|
|
|
|
from C: |
3780
|
|
|
|
|
|
|
|
3781
|
|
|
|
|
|
|
#include |
3782
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H |
3783
|
|
|
|
|
|
|
# include |
3784
|
|
|
|
|
|
|
#endif |
3785
|
|
|
|
|
|
|
#ifdef HAVE_SYS_STAT_H |
3786
|
|
|
|
|
|
|
# include |
3787
|
|
|
|
|
|
|
#endif |
3788
|
|
|
|
|
|
|
#ifdef STDC_HEADERS |
3789
|
|
|
|
|
|
|
# include |
3790
|
|
|
|
|
|
|
# include |
3791
|
|
|
|
|
|
|
#else |
3792
|
|
|
|
|
|
|
# ifdef HAVE_STDLIB_H |
3793
|
|
|
|
|
|
|
# include |
3794
|
|
|
|
|
|
|
# endif |
3795
|
|
|
|
|
|
|
#endif |
3796
|
|
|
|
|
|
|
#ifdef HAVE_STRING_H |
3797
|
|
|
|
|
|
|
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H |
3798
|
|
|
|
|
|
|
# include |
3799
|
|
|
|
|
|
|
# endif |
3800
|
|
|
|
|
|
|
# include |
3801
|
|
|
|
|
|
|
#endif |
3802
|
|
|
|
|
|
|
#ifdef HAVE_STRINGS_H |
3803
|
|
|
|
|
|
|
# include |
3804
|
|
|
|
|
|
|
#endif |
3805
|
|
|
|
|
|
|
#ifdef HAVE_INTTYPES_H |
3806
|
|
|
|
|
|
|
# include |
3807
|
|
|
|
|
|
|
#endif |
3808
|
|
|
|
|
|
|
#ifdef HAVE_STDINT_H |
3809
|
|
|
|
|
|
|
# include |
3810
|
|
|
|
|
|
|
#endif |
3811
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H |
3812
|
|
|
|
|
|
|
# include |
3813
|
|
|
|
|
|
|
#endif |
3814
|
|
|
|
|
|
|
|
3815
|
|
|
|
|
|
|
=cut |
3816
|
|
|
|
|
|
|
|
3817
|
|
|
|
|
|
|
my $_default_includes = <<"_ACEOF"; |
3818
|
|
|
|
|
|
|
#include |
3819
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H |
3820
|
|
|
|
|
|
|
# include |
3821
|
|
|
|
|
|
|
#endif |
3822
|
|
|
|
|
|
|
#ifdef HAVE_SYS_STAT_H |
3823
|
|
|
|
|
|
|
# include |
3824
|
|
|
|
|
|
|
#endif |
3825
|
|
|
|
|
|
|
#ifdef STDC_HEADERS |
3826
|
|
|
|
|
|
|
# include |
3827
|
|
|
|
|
|
|
# include |
3828
|
|
|
|
|
|
|
#else |
3829
|
|
|
|
|
|
|
# ifdef HAVE_STDLIB_H |
3830
|
|
|
|
|
|
|
# include |
3831
|
|
|
|
|
|
|
# endif |
3832
|
|
|
|
|
|
|
#endif |
3833
|
|
|
|
|
|
|
#ifdef HAVE_STRING_H |
3834
|
|
|
|
|
|
|
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H |
3835
|
|
|
|
|
|
|
# include |
3836
|
|
|
|
|
|
|
# endif |
3837
|
|
|
|
|
|
|
# include |
3838
|
|
|
|
|
|
|
#endif |
3839
|
|
|
|
|
|
|
#ifdef HAVE_STRINGS_H |
3840
|
|
|
|
|
|
|
# include |
3841
|
|
|
|
|
|
|
#endif |
3842
|
|
|
|
|
|
|
#ifdef HAVE_INTTYPES_H |
3843
|
|
|
|
|
|
|
# include |
3844
|
|
|
|
|
|
|
#endif |
3845
|
|
|
|
|
|
|
#ifdef HAVE_STDINT_H |
3846
|
|
|
|
|
|
|
# include |
3847
|
|
|
|
|
|
|
#endif |
3848
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H |
3849
|
|
|
|
|
|
|
# include |
3850
|
|
|
|
|
|
|
#endif |
3851
|
|
|
|
|
|
|
_ACEOF |
3852
|
|
|
|
|
|
|
|
3853
|
3
|
|
|
3
|
|
62
|
sub _default_includes { $_default_includes } |
3854
|
|
|
|
|
|
|
|
3855
|
0
|
|
|
0
|
|
0
|
sub _default_main { $_[0]->_build_main("") } |
3856
|
|
|
|
|
|
|
|
3857
|
|
|
|
|
|
|
my $_main_tpl = <<"_ACEOF"; |
3858
|
|
|
|
|
|
|
int |
3859
|
|
|
|
|
|
|
main () |
3860
|
|
|
|
|
|
|
{ |
3861
|
|
|
|
|
|
|
%s; |
3862
|
|
|
|
|
|
|
return 0; |
3863
|
|
|
|
|
|
|
} |
3864
|
|
|
|
|
|
|
_ACEOF |
3865
|
|
|
|
|
|
|
|
3866
|
|
|
|
|
|
|
sub _build_main |
3867
|
|
|
|
|
|
|
{ |
3868
|
177
|
|
|
177
|
|
1115
|
my $self = shift->_get_instance(); |
3869
|
177
|
|
100
|
|
|
1316
|
my $body = shift || ""; |
3870
|
177
|
|
|
|
|
2890
|
sprintf($_main_tpl, $body); |
3871
|
|
|
|
|
|
|
} |
3872
|
|
|
|
|
|
|
|
3873
|
|
|
|
|
|
|
=head2 _default_includes_with_perl |
3874
|
|
|
|
|
|
|
|
3875
|
|
|
|
|
|
|
returns a string containing default includes for program prologue containing |
3876
|
|
|
|
|
|
|
I<_default_includes> plus |
3877
|
|
|
|
|
|
|
|
3878
|
|
|
|
|
|
|
#include |
3879
|
|
|
|
|
|
|
#include |
3880
|
|
|
|
|
|
|
|
3881
|
|
|
|
|
|
|
=cut |
3882
|
|
|
|
|
|
|
|
3883
|
|
|
|
|
|
|
my $_include_perl = <<"_ACEOF"; |
3884
|
|
|
|
|
|
|
#include |
3885
|
|
|
|
|
|
|
#include |
3886
|
|
|
|
|
|
|
#include /* for perl context in threaded perls */ |
3887
|
|
|
|
|
|
|
_ACEOF |
3888
|
|
|
|
|
|
|
|
3889
|
|
|
|
|
|
|
sub _default_includes_with_perl |
3890
|
|
|
|
|
|
|
{ |
3891
|
3
|
|
|
3
|
|
40
|
join("\n", $_[0]->_default_includes, $_include_perl); |
3892
|
|
|
|
|
|
|
} |
3893
|
|
|
|
|
|
|
|
3894
|
125
|
|
|
125
|
|
789
|
sub _cache_prefix { "ac" } |
3895
|
|
|
|
|
|
|
|
3896
|
|
|
|
|
|
|
sub _cache_name |
3897
|
|
|
|
|
|
|
{ |
3898
|
125
|
|
|
125
|
|
2080
|
my ($self, @names) = @_; |
3899
|
125
|
|
|
|
|
617
|
my $cache_name = join("_", $self->_cache_prefix(), "cv", @names); |
3900
|
125
|
|
|
|
|
469
|
$cache_name =~ tr/_A-Za-z0-9/_/c; |
3901
|
125
|
|
|
|
|
461
|
$cache_name; |
3902
|
|
|
|
|
|
|
} |
3903
|
|
|
|
|
|
|
|
3904
|
|
|
|
|
|
|
sub _get_log_fh |
3905
|
|
|
|
|
|
|
{ |
3906
|
554
|
|
|
554
|
|
3342
|
my $self = $_[0]->_get_instance(); |
3907
|
554
|
100
|
|
|
|
2230
|
unless (defined($self->{logfh})) |
3908
|
|
|
|
|
|
|
{ |
3909
|
9
|
50
|
|
|
|
51
|
my $open_mode = defined $self->{logfile_mode} ? $self->{logfile_mode} : ">"; |
3910
|
9
|
50
|
|
|
|
1736
|
open(my $fh, $open_mode, $self->{logfile}) or croak "Could not open file $self->{logfile}: $!"; |
3911
|
9
|
|
|
|
|
68
|
$self->{logfh} = [$fh]; |
3912
|
|
|
|
|
|
|
} |
3913
|
|
|
|
|
|
|
|
3914
|
554
|
|
|
|
|
1253
|
$self->{logfh}; |
3915
|
|
|
|
|
|
|
} |
3916
|
|
|
|
|
|
|
|
3917
|
|
|
|
|
|
|
sub _add_log_entry |
3918
|
|
|
|
|
|
|
{ |
3919
|
246
|
|
|
246
|
|
1640
|
my ($self, @logentries) = @_; |
3920
|
246
|
50
|
|
|
|
1082
|
ref($self) or $self = $self->_get_instance(); |
3921
|
246
|
|
|
|
|
1261
|
$self->_get_log_fh(); |
3922
|
246
|
|
|
|
|
1195
|
foreach my $logentry (@logentries) |
3923
|
|
|
|
|
|
|
{ |
3924
|
369
|
|
|
|
|
775
|
foreach my $fh (@{$self->{logfh}}) |
|
369
|
|
|
|
|
1068
|
|
3925
|
|
|
|
|
|
|
{ |
3926
|
375
|
|
|
|
|
687
|
print {$fh} "$logentry"; |
|
375
|
|
|
|
|
1862
|
|
3927
|
|
|
|
|
|
|
} |
3928
|
|
|
|
|
|
|
} |
3929
|
|
|
|
|
|
|
|
3930
|
246
|
|
|
|
|
649
|
return; |
3931
|
|
|
|
|
|
|
} |
3932
|
|
|
|
|
|
|
|
3933
|
|
|
|
|
|
|
sub _add_log_lines |
3934
|
|
|
|
|
|
|
{ |
3935
|
304
|
|
|
304
|
|
1641
|
my ($self, @logentries) = @_; |
3936
|
304
|
50
|
|
|
|
1707
|
ref($self) or $self = $self->_get_instance(); |
3937
|
304
|
|
|
|
|
1447
|
$self->_get_log_fh(); |
3938
|
304
|
|
|
|
|
2185
|
my $logmsg = join("\n", @logentries) . "\n"; |
3939
|
304
|
|
|
|
|
655
|
foreach my $fh (@{$self->{logfh}}) |
|
304
|
|
|
|
|
1874
|
|
3940
|
|
|
|
|
|
|
{ |
3941
|
304
|
|
|
|
|
618
|
print {$fh} $logmsg; |
|
304
|
|
|
|
|
2108
|
|
3942
|
|
|
|
|
|
|
} |
3943
|
|
|
|
|
|
|
|
3944
|
304
|
|
|
|
|
848
|
return; |
3945
|
|
|
|
|
|
|
} |
3946
|
|
|
|
|
|
|
|
3947
|
|
|
|
|
|
|
=head2 add_log_fh |
3948
|
|
|
|
|
|
|
|
3949
|
|
|
|
|
|
|
Push new file handles at end of log-handles to allow tee'ing log-output |
3950
|
|
|
|
|
|
|
|
3951
|
|
|
|
|
|
|
=cut |
3952
|
|
|
|
|
|
|
|
3953
|
|
|
|
|
|
|
sub add_log_fh |
3954
|
|
|
|
|
|
|
{ |
3955
|
2
|
|
|
2
|
1
|
3337
|
my ($self, @newh) = @_; |
3956
|
2
|
|
|
|
|
20
|
$self->_get_log_fh(); |
3957
|
|
|
|
|
|
|
SKIP_DUP: |
3958
|
2
|
|
|
|
|
15
|
foreach my $fh (@newh) |
3959
|
|
|
|
|
|
|
{ |
3960
|
2
|
|
|
|
|
15
|
foreach my $eh (@{$self->{logfh}}) |
|
2
|
|
|
|
|
10
|
|
3961
|
|
|
|
|
|
|
{ |
3962
|
2
|
50
|
|
|
|
12
|
$fh == $eh and next SKIP_DUP; |
3963
|
|
|
|
|
|
|
} |
3964
|
2
|
|
|
|
|
10
|
push @{$self->{logfh}}, $fh; |
|
2
|
|
|
|
|
14
|
|
3965
|
|
|
|
|
|
|
} |
3966
|
2
|
|
|
|
|
8
|
return; |
3967
|
|
|
|
|
|
|
} |
3968
|
|
|
|
|
|
|
|
3969
|
|
|
|
|
|
|
=head2 delete_log_fh |
3970
|
|
|
|
|
|
|
|
3971
|
|
|
|
|
|
|
Removes specified log file handles. This method allows you to shoot |
3972
|
|
|
|
|
|
|
yourself in the foot - it doesn't prove whether the primary nor the last handle |
3973
|
|
|
|
|
|
|
is removed. Use with caution. |
3974
|
|
|
|
|
|
|
|
3975
|
|
|
|
|
|
|
=cut |
3976
|
|
|
|
|
|
|
|
3977
|
|
|
|
|
|
|
sub delete_log_fh |
3978
|
|
|
|
|
|
|
{ |
3979
|
2
|
|
|
2
|
1
|
25
|
my ($self, @xh) = @_; |
3980
|
2
|
|
|
|
|
25
|
$self->_get_log_fh(); |
3981
|
|
|
|
|
|
|
SKIP_DUP: |
3982
|
2
|
|
|
|
|
10
|
foreach my $fh (@xh) |
3983
|
|
|
|
|
|
|
{ |
3984
|
2
|
|
|
|
|
14
|
foreach my $ih (0 .. $#{$self->{logfh}}) |
|
2
|
|
|
|
|
21
|
|
3985
|
|
|
|
|
|
|
{ |
3986
|
4
|
100
|
|
|
|
38
|
$fh == $self->{logfh}->[$ih] or next; |
3987
|
2
|
|
|
|
|
9
|
splice @{$self->{logfh}}, $ih, 1; |
|
2
|
|
|
|
|
16
|
|
3988
|
2
|
|
|
|
|
13
|
last; |
3989
|
|
|
|
|
|
|
} |
3990
|
|
|
|
|
|
|
} |
3991
|
2
|
|
|
|
|
7
|
return; |
3992
|
|
|
|
|
|
|
} |
3993
|
|
|
|
|
|
|
|
3994
|
|
|
|
|
|
|
sub _cache_type_name |
3995
|
|
|
|
|
|
|
{ |
3996
|
51
|
|
|
51
|
|
485
|
my ($self, @names) = @_; |
3997
|
51
|
|
|
|
|
251
|
$self->_cache_name(map { $_ =~ tr/*/p/; $_ } @names); |
|
84
|
|
|
|
|
276
|
|
|
84
|
|
|
|
|
608
|
|
3998
|
|
|
|
|
|
|
} |
3999
|
|
|
|
|
|
|
|
4000
|
|
|
|
|
|
|
=head2 _get_extra_compiler_flags |
4001
|
|
|
|
|
|
|
|
4002
|
|
|
|
|
|
|
Returns the determined flags required to run the compile stage as string |
4003
|
|
|
|
|
|
|
|
4004
|
|
|
|
|
|
|
=cut |
4005
|
|
|
|
|
|
|
|
4006
|
|
|
|
|
|
|
sub _get_extra_compiler_flags |
4007
|
|
|
|
|
|
|
{ |
4008
|
179
|
|
|
179
|
|
812
|
my $self = shift->_get_instance(); |
4009
|
179
|
|
|
|
|
467
|
my @ppflags = @{$self->{extra_preprocess_flags}}; |
|
179
|
|
|
|
|
705
|
|
4010
|
179
|
|
|
|
|
435
|
my @cflags = @{$self->{extra_compile_flags}->{$self->{lang}}}; |
|
179
|
|
|
|
|
715
|
|
4011
|
179
|
|
|
|
|
2339
|
join(" ", map { _quote_shell_arg $_ } (@ppflags, @cflags)); |
|
0
|
|
|
|
|
0
|
|
4012
|
|
|
|
|
|
|
} |
4013
|
|
|
|
|
|
|
|
4014
|
|
|
|
|
|
|
=head2 _get_extra_linker_flags |
4015
|
|
|
|
|
|
|
|
4016
|
|
|
|
|
|
|
Returns the determined flags required to run the link stage as string |
4017
|
|
|
|
|
|
|
|
4018
|
|
|
|
|
|
|
=cut |
4019
|
|
|
|
|
|
|
|
4020
|
|
|
|
|
|
|
sub _get_extra_linker_flags |
4021
|
|
|
|
|
|
|
{ |
4022
|
16
|
|
|
16
|
|
279
|
my $self = shift->_get_instance(); |
4023
|
16
|
|
|
|
|
60
|
my @libs = @{$self->{extra_libs}}; |
|
16
|
|
|
|
|
171
|
|
4024
|
16
|
|
|
|
|
60
|
my @lib_dirs = @{$self->{extra_lib_dirs}}; |
|
16
|
|
|
|
|
105
|
|
4025
|
16
|
|
|
|
|
57
|
my @ldflags = @{$self->{extra_link_flags}}; |
|
16
|
|
|
|
|
64
|
|
4026
|
16
|
|
|
|
|
319
|
join(" ", map { _quote_shell_arg $_ } (@ldflags, map("-L" . $self->_sanitize_prog($_), @lib_dirs), map("-l$_", @libs))); |
|
19
|
|
|
|
|
652
|
|
4027
|
|
|
|
|
|
|
} |
4028
|
|
|
|
|
|
|
|
4029
|
|
|
|
|
|
|
=head1 AUTHOR |
4030
|
|
|
|
|
|
|
|
4031
|
|
|
|
|
|
|
Alberto Simões, C<< >> |
4032
|
|
|
|
|
|
|
|
4033
|
|
|
|
|
|
|
Jens Rehsack, C<< >> |
4034
|
|
|
|
|
|
|
|
4035
|
|
|
|
|
|
|
=head1 NEXT STEPS |
4036
|
|
|
|
|
|
|
|
4037
|
|
|
|
|
|
|
Although a lot of work needs to be done, these are the next steps I |
4038
|
|
|
|
|
|
|
intend to take. |
4039
|
|
|
|
|
|
|
|
4040
|
|
|
|
|
|
|
- detect flex/lex |
4041
|
|
|
|
|
|
|
- detect yacc/bison/byacc |
4042
|
|
|
|
|
|
|
- detect ranlib (not sure about its importance) |
4043
|
|
|
|
|
|
|
|
4044
|
|
|
|
|
|
|
These are the ones I think not too much important, and will be |
4045
|
|
|
|
|
|
|
addressed later, or by request. |
4046
|
|
|
|
|
|
|
|
4047
|
|
|
|
|
|
|
- detect an 'install' command |
4048
|
|
|
|
|
|
|
- detect a 'ln -s' command -- there should be a module doing |
4049
|
|
|
|
|
|
|
this kind of task. |
4050
|
|
|
|
|
|
|
|
4051
|
|
|
|
|
|
|
=head1 BUGS |
4052
|
|
|
|
|
|
|
|
4053
|
|
|
|
|
|
|
A lot. Portability is a pain. B<>. |
4054
|
|
|
|
|
|
|
|
4055
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
4056
|
|
|
|
|
|
|
C, or through the web interface at |
4057
|
|
|
|
|
|
|
L. We will |
4058
|
|
|
|
|
|
|
be notified, and then you'll automatically be notified of progress |
4059
|
|
|
|
|
|
|
on your bug as we make changes. |
4060
|
|
|
|
|
|
|
|
4061
|
|
|
|
|
|
|
=head1 SUPPORT |
4062
|
|
|
|
|
|
|
|
4063
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
4064
|
|
|
|
|
|
|
|
4065
|
|
|
|
|
|
|
perldoc Config::AutoConf |
4066
|
|
|
|
|
|
|
|
4067
|
|
|
|
|
|
|
You can also look for information at: |
4068
|
|
|
|
|
|
|
|
4069
|
|
|
|
|
|
|
=over 4 |
4070
|
|
|
|
|
|
|
|
4071
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
4072
|
|
|
|
|
|
|
|
4073
|
|
|
|
|
|
|
L |
4074
|
|
|
|
|
|
|
|
4075
|
|
|
|
|
|
|
=item * CPAN Ratings |
4076
|
|
|
|
|
|
|
|
4077
|
|
|
|
|
|
|
L |
4078
|
|
|
|
|
|
|
|
4079
|
|
|
|
|
|
|
=item * MetaCPAN |
4080
|
|
|
|
|
|
|
|
4081
|
|
|
|
|
|
|
L |
4082
|
|
|
|
|
|
|
|
4083
|
|
|
|
|
|
|
=item * Git Repository |
4084
|
|
|
|
|
|
|
|
4085
|
|
|
|
|
|
|
L |
4086
|
|
|
|
|
|
|
|
4087
|
|
|
|
|
|
|
=back |
4088
|
|
|
|
|
|
|
|
4089
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
4090
|
|
|
|
|
|
|
|
4091
|
|
|
|
|
|
|
Michael Schwern for kind MacOS X help. |
4092
|
|
|
|
|
|
|
|
4093
|
|
|
|
|
|
|
Ken Williams for ExtUtils::CBuilder |
4094
|
|
|
|
|
|
|
|
4095
|
|
|
|
|
|
|
Peter Rabbitson for help on refactoring and making the API more Perl'ish |
4096
|
|
|
|
|
|
|
|
4097
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
4098
|
|
|
|
|
|
|
|
4099
|
|
|
|
|
|
|
Copyright 2004-2020 by the Authors |
4100
|
|
|
|
|
|
|
|
4101
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
4102
|
|
|
|
|
|
|
under the same terms as Perl itself. |
4103
|
|
|
|
|
|
|
|
4104
|
|
|
|
|
|
|
=head1 SEE ALSO |
4105
|
|
|
|
|
|
|
|
4106
|
|
|
|
|
|
|
ExtUtils::CBuilder(3) |
4107
|
|
|
|
|
|
|
|
4108
|
|
|
|
|
|
|
=cut |
4109
|
|
|
|
|
|
|
|
4110
|
|
|
|
|
|
|
1; # End of Config::AutoConf |