2 # Copyright 1999, 2000, 2001 Patrik Stridvall
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 use vars
qw($VERSION @ISA @EXPORT @EXPORT_OK);
28 @EXPORT_OK = qw($nativeapi);
30 use vars qw($nativeapi);
32 use config qw(&file_type $current_dir $wine_dir $winapi_check_dir);
33 use options qw($options);
34 use output qw($output);
36 $nativeapi = 'nativeapi'->new;
40 my $class = ref($proto) || $proto;
42 bless ($self, $class);
44 my $functions = \%{$self->{FUNCTIONS}};
45 my $conditionals = \%{$self->{CONDITIONALS}};
46 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
47 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
49 my $api_file = "$winapi_check_dir/nativeapi.dat";
50 my $configure_ac_file = "$wine_dir/configure.ac";
51 my $config_h_in_file = "$wine_dir/include/config.h.in";
53 $api_file =~ s/^\.\///;
54 $configure_ac_file =~ s/^\.\///;
55 $config_h_in_file =~ s/^\.\///;
58 $$conditional_headers{"config.h"}++;
60 $output->progress("$api_file");
62 open(IN, "< $api_file");
65 s/^\s*(.*?)\s*$/$1/; # remove whitespace at begin and end of line
66 s/^(.*?)\s*#.*$/$1/; # remove comments
67 /^$/ && next; # skip empty lines
73 $output->progress("$configure_ac_file");
76 open(IN, "< $configure_ac_file");
78 while($again || (defined($_ = <IN>))) {
85 # remove trailing whitespace
88 # remove leading whitespace
91 $_ = $current . " " . $next;
98 # remove leading and trailing whitespace
107 if(/AC_CHECK_HEADERS\(\s*([^,\)]*)(?:,|\))?/) {
109 $headers =~ s/^\s*\[\s*(.*?)\s*\]\s*$/$1/;
110 foreach my $name (split(/\s+/, $headers)) {
111 $$conditional_headers{$name}++;
113 } elsif(/AC_CHECK_FUNCS\(\s*([^,\)]*)(?:,|\))?/) {
115 $funcs =~ s/^\s*\[\s*(.*?)\s*\]\s*$/$1/;
116 foreach my $name (split(/\s+/, $funcs)) {
117 $$conditional_functions{$name}++;
119 } elsif(/AC_FUNC_ALLOCA/) {
120 $$conditional_headers{"alloca.h"}++;
121 } elsif (/AC_DEFINE\(\s*HAVE_(.*?)_H/) {
126 next if $name =~ m%correct/%;
128 $$conditional_headers{$name}++;
134 $output->progress("$config_h_in_file");
136 open(IN, "< $config_h_in_file");
139 # remove leading and trailing whitespace
145 if(/^\#undef\s+(\S+)$/) {
146 $$conditionals{$1}++;
158 my $functions = \%{$self->{FUNCTIONS}};
162 return ($$functions{$name} || 0);
167 my $conditionals = \%{$self->{CONDITIONALS}};
171 return ($$conditionals{$name} || 0);
174 sub found_conditional {
176 my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
180 $$conditional_found{$name}++;
183 sub is_conditional_header {
185 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
189 return ($$conditional_headers{$name} || 0);
192 sub is_conditional_function {
194 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
198 return ($$conditional_functions{$name} || 0);
204 my $output = \${$self->{OUTPUT}};
205 my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
206 my $conditionals = \%{$self->{CONDITIONALS}};
209 foreach my $name (sort(keys(%$conditionals))) {
210 if($name =~ /^const|inline|size_t$/) { next; }
212 if(0 && !$$conditional_found{$name}) {
213 push @messages, "config.h.in: conditional $name not used\n";
217 foreach my $message (sort(@messages)) {
218 $output->write($message);