wpcap: Handle different layout of the native packet header structure on 32-bit.
[wine.git] / tools / winapi / setup.pm
blobf23bba1ad1b899c07e8361699dc1bb87dae453f6
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
19 package setup;
21 use strict;
22 use warnings 'all';
24 BEGIN {
25 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
26 require Exporter;
28 @ISA = qw(Exporter);
29 @EXPORT = qw();
30 @EXPORT_OK = qw($current_dir $wine_dir $winapi_dir);
32 use vars qw($current_dir $wine_dir $winapi_dir);
34 my $tool = $0;
35 $tool =~ s%^(?:.*?/)?([^/]+)$%$1%;
37 if(defined($current_dir) && defined($wine_dir) &&
38 defined($winapi_dir))
40 # Nothing
41 } elsif($0 =~ m%^(.*?)/?tools/([^/]+)/[^/]+$%) {
42 my $dir = $2;
44 if(defined($1) && $1 ne "")
46 $wine_dir = $1;
47 } else {
48 $wine_dir = ".";
52 require Cwd;
53 my $cwd = Cwd::cwd();
55 if($wine_dir =~ /^\./) {
56 $current_dir = ".";
57 my $pwd; chomp($pwd = $cwd);
58 foreach my $n (1..((length($wine_dir) + 1) / 3)) {
59 $pwd =~ s/\/([^\/]*)$//;
60 $current_dir = "$1/$current_dir";
62 $current_dir =~ s%/\.$%%;
63 } elsif($wine_dir eq $cwd) {
64 $wine_dir = ".";
65 $current_dir = ".";
66 } elsif($cwd =~ m%^$wine_dir/(.*?)?$%) {
67 $current_dir = $1;
68 $wine_dir = ".";
69 foreach my $dir (split(m%/%, $current_dir)) {
70 $wine_dir = "../$wine_dir";
72 $wine_dir =~ s%/\.$%%;
73 } else {
74 print STDERR "$tool: You must run this tool in the main Wine directory or a sub directory\n";
75 exit 1;
78 $winapi_dir = "$wine_dir/tools/winapi";
79 $winapi_dir =~ s%^\./%%;
81 push @INC, $winapi_dir;
82 } else {
83 print STDERR "$tool: You must run this tool in the main Wine directory or a sub directory\n";
84 exit 1;