summaryrefslogtreecommitdiff
path: root/win32/FindExt.pm
blob: 831250313dd1c905e00a09f30de72037913b0aa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package FindExt;
use strict;
use File::Find;
use File::Basename;
use Cwd;

my $no = join('|',qw(DynaLoader GDBM_File ODBM_File NDBM_File DB_File
		     Syslog SysV Langinfo));
$no = qr/^(?:$no)$/i;

my %ext;
my $ext;
sub scan_ext
{
 my $here = getcwd();
 my $dir  = shift;
 chdir($dir) || die "Cannot cd to $dir\n";
 ($ext = getcwd()) =~ s,/,\\,g;
 find(\&find_ext,'.');
 chdir($here) || die "Cannot cd to $here\n";
 my @ext = extensions();
}

sub dynamic_extensions
{
 return grep $ext{$_} eq 'dynamic',keys %ext;
}

sub noxs_extensions
{
 return grep $ext{$_} eq 'nonxs',keys %ext;
}

sub extensions
{
 return keys %ext;
}

sub find_ext
{
 if (/^(.*)\.pm$/i || /^(.*)_pm\.PL$/i || /^(.*)\.xs$/i)
  {
   my $name = $1;
   return if $name =~ $no; 
   my $dir = $File::Find::dir; 
   $dir =~ s,./,,;
   return if exists $ext{$dir};
   return unless -f "$ext/$dir/Makefile.PL";
   if ($dir =~ /$name$/i)
    {
     if (-f "$ext/$dir/$name.xs")
      {
       $ext{$dir} = 'dynamic'; 
      }
     else
      {
       $ext{$dir} = 'nonxs'; 
      }
    }
  }
}

1;