5 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
10 @EXPORT_OK = qw($nativeapi);
12 use vars qw($nativeapi);
14 use config qw(&file_type $current_dir $wine_dir $winapi_check_dir);
15 use options qw($options);
16 use output qw($output);
18 $nativeapi = 'nativeapi'->new;
22 my $class = ref($proto) || $proto;
24 bless ($self, $class);
26 my $functions = \%{$self->{FUNCTIONS}};
27 my $conditionals = \%{$self->{CONDITIONALS}};
28 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
29 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
31 my $api_file = "$winapi_check_dir/nativeapi.dat";
32 my $configure_in_file = "$wine_dir/configure.in";
33 my $config_h_in_file = "$wine_dir/include/config.h.in";
35 $api_file =~ s/^\.\///;
36 $configure_in_file =~ s/^\.\///;
37 $config_h_in_file =~ s/^\.\///;
39 if($options->progress) {
40 $output->progress("$api_file");
43 open(IN, "< $api_file");
46 s/^\s*(.*?)\s*$/$1/; # remove whitespace at begin and end of line
47 s/^(.*?)\s*#.*$/$1/; # remove comments
48 /^$/ && next; # skip empty lines
54 if($options->progress) {
55 $output->progress("$configure_in_file");
59 open(IN, "< $configure_in_file");
61 while($again || (defined($_ = <IN>))) {
68 # remove trailing whitespace
71 # remove leading whitespace
74 $_ = $current . " " . $next;
81 # remove leading and trailing whitespace
90 if(/^AC_CHECK_HEADERS\(\s*([^,\)]*)(?:,|\))?/) {
91 foreach my $name (split(/\s+/, $1)) {
92 $$conditional_headers{$name}++;
94 } elsif(/^AC_CHECK_FUNCS\(\s*([^,\)]*)(?:,|\))?/) {
95 foreach my $name (split(/\s+/, $1)) {
96 $$conditional_functions{$name}++;
98 } elsif(/^AC_FUNC_ALLOCA/) {
99 $$conditional_headers{"alloca.h"}++;
105 if($options->progress) {
106 $output->progress("$config_h_in_file");
109 open(IN, "< $config_h_in_file");
112 # remove leading and trailing whitespace
118 if(/^\#undef\s+(\S+)$/) {
119 $$conditionals{$1}++;
131 my $functions = \%{$self->{FUNCTIONS}};
135 return $$functions{$name};
140 my $conditionals = \%{$self->{CONDITIONALS}};
144 return $$conditionals{$name};
147 sub found_conditional {
149 my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
153 $$conditional_found{$name}++;
156 sub is_conditional_header {
158 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
162 return $$conditional_headers{$name};
165 sub is_conditional_function {
167 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
171 return $$conditional_functions{$name};
177 my $output = \${$self->{OUTPUT}};
178 my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
179 my $conditionals = \%{$self->{CONDITIONALS}};
182 foreach my $name (sort(keys(%$conditionals))) {
183 if($name =~ /^const|inline|size_t$/) { next; }
185 if(0 && !$$conditional_found{$name}) {
186 push @messages, "config.h.in: conditional $name not used\n";
190 foreach my $message (sort(@messages)) {
191 $output->write($message);