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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 use vars
qw($VERSION @ISA @EXPORT @EXPORT_OK);
29 @EXPORT_OK = qw($nativeapi);
31 use vars qw($nativeapi);
33 use config qw(file_type $current_dir $wine_dir $winapi_dir);
34 use options qw($options);
35 use output qw($output);
37 $nativeapi = 'nativeapi'->new;
41 my $class = ref($proto) || $proto;
43 bless ($self, $class);
45 my $functions = \%{$self->{FUNCTIONS}};
46 my $conditionals = \%{$self->{CONDITIONALS}};
47 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
48 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
50 my $api_file = "$winapi_dir/nativeapi.dat";
51 my $configure_ac_file = "$wine_dir/configure.ac";
52 my $config_h_in_file = "$wine_dir/include/config.h.in";
54 $api_file =~ s/^\.\///;
55 $configure_ac_file =~ s/^\.\///;
56 $config_h_in_file =~ s/^\.\///;
59 $$conditional_headers{"config.h"}++;
61 $output->progress("$api_file");
63 open(IN, "< $api_file") || die "Error: Can't open $api_file: $!\n";
66 s/^\s*(.*?)\s*$/$1/; # remove whitespace at begin and end of line
67 s/^(.*?)\s*#.*$/$1/; # remove comments
68 /^$/ && next; # skip empty lines
74 $output->progress("$configure_ac_file");
77 open(IN, "< $configure_ac_file") || die "Error: Can't open $configure_ac_file: $!\n";
79 while($again || (defined($_ = <IN>))) {
86 # remove trailing whitespace
89 # remove leading whitespace
92 $_ = $current . " " . $next;
99 # remove leading and trailing whitespace
108 if(/AC_CHECK_HEADERS\(\s*([^,\)]*)(?:,|\))?/) {
110 $headers =~ s/^\s*\[\s*(.*?)\s*\]\s*$/$1/;
111 foreach my $name (split(/\s+/, $headers)) {
112 $$conditional_headers{$name}++;
114 } elsif(/AC_HEADER_STAT\(\)/) {
115 # This checks for a bunch of standard headers
116 # There's stdlib.h, string.h and sys/types.h too but we don't
117 # want to force ifdefs for those at this point.
118 foreach my $name ("sys/stat.h", "memory.h", "strings.h",
119 "inttypes.h", "stdint.h", "unistd.h") {
120 $$conditional_headers{$name}++;
122 } elsif(/AC_CHECK_FUNCS\(\s*([^,\)]*)(?:,|\))?/) {
124 $funcs =~ s/^\s*\[\s*(.*?)\s*\]\s*$/$1/;
125 foreach my $name (split(/\s+/, $funcs)) {
126 $$conditional_functions{$name}++;
128 } elsif(/AC_FUNC_ALLOCA/) {
129 $$conditional_headers{"alloca.h"}++;
130 } elsif (/AC_DEFINE\(\s*HAVE_(.*?)_H/) {
135 next if $name =~ m%correct/%;
137 $$conditional_headers{$name}++;
143 $output->progress("$config_h_in_file");
145 open(IN, "< $config_h_in_file") || die "Error: Can't open $config_h_in_file: $!\n";
148 # remove leading and trailing whitespace
154 if(/^\#undef\s+(\S+)$/) {
155 $$conditionals{$1}++;
165 sub is_function($$) {
167 my $functions = \%{$self->{FUNCTIONS}};
171 return ($$functions{$name} || 0);
174 sub is_conditional($$) {
176 my $conditionals = \%{$self->{CONDITIONALS}};
180 return ($$conditionals{$name} || 0);
183 sub found_conditional($$) {
185 my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
189 $$conditional_found{$name}++;
192 sub is_conditional_header($$) {
194 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
198 return ($$conditional_headers{$name} || 0);
201 sub is_conditional_function($$) {
203 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
207 return ($$conditional_functions{$name} || 0);
210 sub global_report($) {
213 my $output = \${$self->{OUTPUT}};
214 my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
215 my $conditionals = \%{$self->{CONDITIONALS}};
218 foreach my $name (sort(keys(%$conditionals))) {
219 if($name =~ /^(?:const|inline|size_t)$/) { next; }
221 if(0 && !$$conditional_found{$name}) {
222 push @messages, "config.h.in: conditional $name not used\n";
226 foreach my $message (sort(@messages)) {
227 $output->write($message);