5 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
10 @EXPORT_OK = qw($nativeapi);
12 use vars qw($nativeapi);
16 my $class = ref($proto) || $proto;
18 bless ($self, $class);
20 my $options = \${$self->{OPTIONS}};
21 my $output = \${$self->{OUTPUT}};
22 my $functions = \%{$self->{FUNCTIONS}};
23 my $conditionals = \%{$self->{CONDITIONALS}};
24 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
25 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
30 my $configure_in_file = shift;
31 my $config_h_in_file = shift;
33 $api_file =~ s/^\.\///;
34 $configure_in_file =~ s/^\.\///;
35 $config_h_in_file =~ s/^\.\///;
37 if($$options->progress) {
38 $$output->progress("$api_file");
41 open(IN, "< $api_file");
44 s/^\s*(.*?)\s*$/$1/; # remove whitespace at begin and end of line
45 s/^(.*?)\s*#.*$/$1/; # remove comments
46 /^$/ && next; # skip empty lines
52 if($$options->progress) {
53 $$output->progress("$configure_in_file");
57 open(IN, "< $configure_in_file");
59 while($again || (defined($_ = <IN>))) {
66 # remove trailing whitespace
69 # remove leading whitespace
72 $_ = $current . " " . $next;
79 # remove leading and trailing whitespace
88 if(/^AC_CHECK_HEADERS\(\s*([^,\)]*)(?:,|\))?/) {
89 foreach my $name (split(/\s+/, $1)) {
90 $$conditional_headers{$name}++;
92 } elsif(/^AC_CHECK_FUNCS\(\s*([^,\)]*)(?:,|\))?/) {
93 foreach my $name (split(/\s+/, $1)) {
94 $$conditional_functions{$name}++;
96 } elsif(/^AC_FUNC_ALLOCA/) {
97 $$conditional_headers{"alloca.h"}++;
103 if($$options->progress) {
104 $$output->progress("$config_h_in_file");
107 open(IN, "< $config_h_in_file");
110 # remove leading and trailing whitespace
116 if(/^\#undef\s+(\S+)$/) {
117 $$conditionals{$1}++;
129 my $functions = \%{$self->{FUNCTIONS}};
133 return $$functions{$name};
138 my $conditionals = \%{$self->{CONDITIONALS}};
142 return $$conditionals{$name};
145 sub found_conditional {
147 my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
151 $$conditional_found{$name}++;
154 sub is_conditional_header {
156 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
160 return $$conditional_headers{$name};
163 sub is_conditional_function {
165 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
169 return $$conditional_functions{$name};
175 my $output = \${$self->{OUTPUT}};
176 my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
177 my $conditionals = \%{$self->{CONDITIONALS}};
180 foreach my $name (sort(keys(%$conditionals))) {
181 if($name =~ /^const|inline|size_t$/) { next; }
183 if(0 && !$$conditional_found{$name}) {
184 push @messages, "config.h.in: conditional $name not used\n";
188 foreach my $message (sort(@messages)) {
189 $$output->write($message);