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