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