1999-09-23 17:14:20 +02:00
|
|
|
package nativeapi;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
my $proto = shift;
|
|
|
|
my $class = ref($proto) || $proto;
|
|
|
|
my $self = {};
|
|
|
|
bless ($self, $class);
|
|
|
|
|
2000-04-15 22:39:55 +02:00
|
|
|
my $options = \${$self->{OPTIONS}};
|
1999-10-31 03:08:38 +01:00
|
|
|
my $output = \${$self->{OUTPUT}};
|
1999-09-23 17:14:20 +02:00
|
|
|
my $functions = \%{$self->{FUNCTIONS}};
|
1999-10-24 23:45:39 +02:00
|
|
|
my $conditionals = \%{$self->{CONDITIONALS}};
|
|
|
|
my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
|
1999-10-31 03:08:38 +01:00
|
|
|
my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
|
1999-09-23 17:14:20 +02:00
|
|
|
|
2000-04-15 22:39:55 +02:00
|
|
|
$$options = shift;
|
1999-10-31 03:08:38 +01:00
|
|
|
$$output = shift;
|
1999-10-24 23:45:39 +02:00
|
|
|
my $api_file = shift;
|
|
|
|
my $configure_in_file = shift;
|
|
|
|
my $config_h_in_file = shift;
|
1999-09-23 17:14:20 +02:00
|
|
|
|
1999-11-08 00:35:03 +01:00
|
|
|
$api_file =~ s/^\.\///;
|
|
|
|
$configure_in_file =~ s/^\.\///;
|
|
|
|
$config_h_in_file =~ s/^\.\///;
|
|
|
|
|
2000-04-15 22:39:55 +02:00
|
|
|
if($$options->progress) {
|
|
|
|
$$output->progress("$api_file");
|
|
|
|
}
|
1999-10-31 03:08:38 +01:00
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
open(IN, "< $api_file");
|
2000-04-15 22:39:55 +02:00
|
|
|
local $/ = "\n";
|
1999-09-23 17:14:20 +02:00
|
|
|
while(<IN>) {
|
|
|
|
s/^\s*?(.*?)\s*$/$1/; # remove whitespace at begin and end of line
|
|
|
|
s/^(.*?)\s*#.*$/$1/; # remove comments
|
|
|
|
/^$/ && next; # skip empty lines
|
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
$$functions{$_}++;
|
|
|
|
}
|
|
|
|
close(IN);
|
|
|
|
|
2000-04-15 22:39:55 +02:00
|
|
|
if($$options->progress) {
|
|
|
|
$$output->progress("$configure_in_file");
|
|
|
|
}
|
1999-10-31 03:08:38 +01:00
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
my $again = 0;
|
1999-10-31 03:08:38 +01:00
|
|
|
open(IN, "< $configure_in_file");
|
1999-10-24 23:45:39 +02:00
|
|
|
local $/ = "\n";
|
|
|
|
while($again || (defined($_ = <IN>))) {
|
|
|
|
$again = 0;
|
|
|
|
chomp;
|
2000-09-04 22:20:47 +02:00
|
|
|
if(/^(.*?)\\$/) {
|
|
|
|
my $current = $1;
|
|
|
|
my $next = <IN>;
|
|
|
|
if(defined($next)) {
|
|
|
|
# remove trailing whitespace
|
|
|
|
$current =~ s/\s+$//;
|
|
|
|
|
|
|
|
# remove leading whitespace
|
|
|
|
$next =~ s/^\s+//;
|
|
|
|
|
|
|
|
$_ = $current . " " . $next;
|
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
$again = 1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
2000-09-04 22:20:47 +02:00
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
# remove leading and trailing whitespace
|
|
|
|
s/^\s*(.*?)\s*$/$1/;
|
|
|
|
|
2000-09-04 22:20:47 +02:00
|
|
|
# skip emty lines
|
|
|
|
if(/^$/) { next; }
|
|
|
|
|
|
|
|
# skip comments
|
|
|
|
if(/^dnl/) { next; }
|
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
if(/^AC_CHECK_HEADERS\(\s*(.*?)\)\s*$/) {
|
|
|
|
my @arguments = split(/,/,$1);
|
1999-10-31 03:08:38 +01:00
|
|
|
foreach my $name (split(/\s+/, $arguments[0])) {
|
|
|
|
$$conditional_headers{$name}++;
|
|
|
|
}
|
|
|
|
} elsif(/^AC_CHECK_FUNCS\(\s*(.*?)\)\s*$/) {
|
|
|
|
my @arguments = split(/,/,$1);
|
|
|
|
foreach my $name (split(/\s+/, $arguments[0])) {
|
|
|
|
$$conditional_functions{$name}++;
|
1999-10-24 23:45:39 +02:00
|
|
|
}
|
|
|
|
} elsif(/^AC_FUNC_ALLOCA/) {
|
|
|
|
$$conditional_headers{"alloca.h"}++;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
close(IN);
|
|
|
|
|
2000-04-15 22:39:55 +02:00
|
|
|
if($$options->progress) {
|
|
|
|
$$output->progress("$config_h_in_file");
|
|
|
|
}
|
1999-10-31 03:08:38 +01:00
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
open(IN, "< $config_h_in_file");
|
|
|
|
local $/ = "\n";
|
|
|
|
while(<IN>) {
|
2000-09-04 22:20:47 +02:00
|
|
|
# remove leading and trailing whitespace
|
|
|
|
s/^\s*(.*?)\s*$/$1/;
|
|
|
|
|
|
|
|
# skip emty lines
|
|
|
|
if(/^$/) { next; }
|
|
|
|
|
|
|
|
if(/^\#undef\s+(\S+)$/) {
|
1999-10-24 23:45:39 +02:00
|
|
|
$$conditionals{$1}++;
|
|
|
|
}
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
|
|
|
close(IN);
|
|
|
|
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub is_function {
|
|
|
|
my $self = shift;
|
|
|
|
my $functions = \%{$self->{FUNCTIONS}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$functions{$name};
|
|
|
|
}
|
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
sub is_conditional {
|
|
|
|
my $self = shift;
|
|
|
|
my $conditionals = \%{$self->{CONDITIONALS}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$conditionals{$name};
|
|
|
|
}
|
|
|
|
|
2000-09-04 22:20:47 +02:00
|
|
|
sub found_conditional {
|
|
|
|
my $self = shift;
|
|
|
|
my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
$$conditional_found{$name}++;
|
|
|
|
}
|
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
sub is_conditional_header {
|
|
|
|
my $self = shift;
|
|
|
|
my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$conditional_headers{$name};
|
|
|
|
}
|
|
|
|
|
1999-10-31 03:08:38 +01:00
|
|
|
sub is_conditional_function {
|
|
|
|
my $self = shift;
|
|
|
|
my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$conditional_functions{$name};
|
|
|
|
}
|
|
|
|
|
2000-09-04 22:20:47 +02:00
|
|
|
sub global_report {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $output = \${$self->{OUTPUT}};
|
|
|
|
my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
|
|
|
|
my $conditionals = \%{$self->{CONDITIONALS}};
|
|
|
|
|
|
|
|
my @messages;
|
|
|
|
foreach my $name (sort(keys(%$conditionals))) {
|
|
|
|
if($name =~ /^const|inline|size_t$/) { next; }
|
|
|
|
|
|
|
|
if(0 && !$$conditional_found{$name}) {
|
|
|
|
push @messages, "config.h.in: conditional $name not used\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $message (sort(@messages)) {
|
|
|
|
$$output->write($message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-23 17:14:20 +02:00
|
|
|
1;
|