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
23 use setup qw($current_dir $wine_dir $winapi_dir);
25 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
30 file_absolutize file_normalize
32 file_type files_filter
40 $current_dir $wine_dir $winapi_dir
43 use vars qw($current_dir $wine_dir $winapi_dir);
45 use output qw($output);
49 sub file_normalize($) {
52 foreach my $dir (split(m%/%, $current_dir)) {
53 if(s%^(\.\./)*\.\./$dir/%%) {
60 while(m%^(.*?)([^/\.]+)/\.\./(.*?)$%) {
61 if($2 ne "." && $2 ne "..") {
69 sub file_absolutize($) {
72 $_ = file_normalize($_);
73 if(!s%^$wine_dir/%%) {
74 $_ = "$current_dir/$_";
84 $_ = file_absolutize($_);
86 m%^(?:server|tests|tools)/% && return "";
87 m%^(?:programs)/% && return "wineapp";
88 m%^(?:libs)/% && return "library";
93 sub files_filter($@) {
97 foreach my $file (@_) {
98 if(file_type($file) eq $type) {
109 $_ = file_absolutize($_);
111 m%^(?:dlls|include)/% || return 1;
112 m%^dlls/wineps\.drv/data/% && return 1;
118 foreach my $file (@_) {
119 if(!file_skip($file)) {
127 sub file_directory($) {
135 s%^(?:\./)?(.*?)(?:/\.)?%$1%;
140 sub _get_files($$;$) {
145 $output->progress("$wine_dir: searching for /$pattern/");
154 while(defined(my $dir = shift @dirs)) {
155 opendir(DIR, $dir) || die "Can't open directory $dir: $!\n";
156 my @entries= readdir(DIR);
165 } elsif($basefile =~ /$pattern/ && (!defined($type) || file_type($_) eq $type)) {
175 sub get_c_files($;$) { return _get_files('\.c$', $_[0], $_[1]); }
176 sub get_h_files($;$) { return _get_files('\.h$', $_[0], $_[1]); }
177 sub get_spec_files($;$) { return _get_files('\.spec$', $_[0], $_[1]); }
178 sub get_makefile_in_files($;$) { return _get_files('^Makefile.in$', $_[0], $_[1]); }