Fixed some issues found by winapi_check.
[wine] / tools / winapi / setup.pm
1 package setup;
2
3 use strict;
4
5 BEGIN {
6     use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
7     require Exporter;
8
9     @ISA = qw(Exporter);
10     @EXPORT = qw();
11     @EXPORT_OK = qw($current_dir $wine_dir $winapi_dir $winapi_check_dir);
12
13     use vars qw($current_dir $wine_dir $winapi_dir $winapi_check_dir);
14
15     my $dir;
16     my $tool;
17
18     if($0 =~ m%^((.*?)/?tools/([^/]+))/([^/]+)$%)
19     {
20         $winapi_dir = $1;
21         $winapi_check_dir = $1;
22         $dir = $3;
23         $tool = $4;
24         
25         if(defined($2) && $2 ne "")
26         {
27             $wine_dir = $2;
28         } else {
29             $wine_dir = ".";
30             
31         } 
32         
33         if($wine_dir =~ /^\./) {
34             $current_dir = ".";
35             my $pwd; chomp($pwd = `pwd`);
36             foreach my $n (1..((length($wine_dir) + 1) / 3)) {
37                 $pwd =~ s/\/([^\/]*)$//;
38                 $current_dir = "$1/$current_dir";
39             }
40             $current_dir =~ s%/\.$%%;
41         }
42         
43         $winapi_dir =~ s%^\./%%;
44         $winapi_dir =~ s/$dir/winapi/g;
45         
46         $winapi_check_dir =~ s%^\./%%;
47         $winapi_check_dir =~ s/$dir/winapi_check/g; 
48     } else {
49         print STDERR "$tool: You must run this tool in the main Wine directory or a sub directory\n";
50         exit 1;
51     }
52
53     push @INC, ($winapi_check_dir, $winapi_dir) if $tool eq "winapi_check";
54     push @INC, ($winapi_dir, $winapi_check_dir) if $tool eq "winapi_extract";
55     push @INC, ($winapi_dir, $winapi_check_dir) if $tool eq "winapi_fixup";
56 }
57
58 1;