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