Commit | Line | Data |
8e232993 |
1 | package FindExt; |
2 | use strict; |
3 | use File::Find; |
4 | use File::Basename; |
5 | use Cwd; |
6 | |
7 | my $no = join('|',qw(DynaLoader GDBM_File ODBM_File NDBM_File DB_File Syslog Sysv)); |
8 | $no = qr/^(?:$no)$/i; |
9 | |
10 | my %ext; |
11 | my $ext; |
12 | sub scan_ext |
13 | { |
14 | my $here = getcwd(); |
15 | my $dir = shift; |
16 | chdir($dir) || die "Cannot cd to $dir\n"; |
17 | ($ext = getcwd()) =~ s,/,\\,g; |
18 | find(\&find_ext,'.'); |
19 | chdir($here) || die "Cannot cd to $here\n"; |
20 | my @ext = extensions(); |
21 | } |
22 | |
23 | sub dynamic_extensions |
24 | { |
25 | return grep $ext{$_} eq 'dynamic',keys %ext; |
26 | } |
27 | |
28 | sub noxs_extensions |
29 | { |
6b29183e |
30 | return grep $ext{$_} eq 'nonxs',keys %ext; |
8e232993 |
31 | } |
32 | |
33 | sub extensions |
34 | { |
35 | return keys %ext; |
36 | } |
37 | |
38 | sub find_ext |
39 | { |
6b29183e |
40 | if (/^(.*)\.pm$/i || /^(.*)_pm\.PL$/i || /^(.*)\.xs$/i) |
8e232993 |
41 | { |
42 | my $name = $1; |
43 | return if $name =~ $no; |
44 | my $dir = $File::Find::dir; |
45 | $dir =~ s,./,,; |
46 | return if exists $ext{$dir}; |
47 | return unless -f "$ext/$dir/Makefile.PL"; |
48 | if ($dir =~ /$name$/i) |
49 | { |
50 | if (-f "$ext/$dir/$name.xs") |
51 | { |
52 | $ext{$dir} = 'dynamic'; |
53 | } |
54 | else |
55 | { |
56 | $ext{$dir} = 'nonxs'; |
57 | } |
58 | } |
59 | } |
60 | } |
61 | |
62 | 1; |