This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Correct a Greengrocer's apostrophe.
[perl5.git] / win32 / FindExt.pm
CommitLineData
8e232993 1package FindExt;
28b605d8
JH
2
3our $VERSION = '1.00';
4
f7d17498
NIS
5# We (probably) have not got a Config.pm yet
6BEGIN { $INC{'Config.pm'} = __FILE__ };
7
8e232993
NIS
8use strict;
9use File::Find;
10use File::Basename;
11use Cwd;
12
86c8d741
GS
13my $no = join('|',qw(DynaLoader GDBM_File ODBM_File NDBM_File DB_File
14 Syslog SysV Langinfo));
8e232993
NIS
15$no = qr/^(?:$no)$/i;
16
17my %ext;
18my $ext;
19sub 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
30sub dynamic_extensions
31{
32 return grep $ext{$_} eq 'dynamic',keys %ext;
33}
34
35sub noxs_extensions
36{
6b29183e 37 return grep $ext{$_} eq 'nonxs',keys %ext;
8e232993
NIS
38}
39
40sub extensions
41{
42 return keys %ext;
43}
44
45sub 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
691;