This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[PATCH: perl@11564] introducing perlivp
[perl5.git] / win32 / FindExt.pm
CommitLineData
8e232993
NIS
1package FindExt;
2use strict;
3use File::Find;
4use File::Basename;
5use Cwd;
6
86c8d741
GS
7my $no = join('|',qw(DynaLoader GDBM_File ODBM_File NDBM_File DB_File
8 Syslog SysV Langinfo));
8e232993
NIS
9$no = qr/^(?:$no)$/i;
10
11my %ext;
12my $ext;
13sub scan_ext
14{
15 my $here = getcwd();
16 my $dir = shift;
17 chdir($dir) || die "Cannot cd to $dir\n";
18 ($ext = getcwd()) =~ s,/,\\,g;
19 find(\&find_ext,'.');
20 chdir($here) || die "Cannot cd to $here\n";
21 my @ext = extensions();
22}
23
24sub dynamic_extensions
25{
26 return grep $ext{$_} eq 'dynamic',keys %ext;
27}
28
29sub noxs_extensions
30{
6b29183e 31 return grep $ext{$_} eq 'nonxs',keys %ext;
8e232993
NIS
32}
33
34sub extensions
35{
36 return keys %ext;
37}
38
39sub find_ext
40{
6b29183e 41 if (/^(.*)\.pm$/i || /^(.*)_pm\.PL$/i || /^(.*)\.xs$/i)
8e232993
NIS
42 {
43 my $name = $1;
44 return if $name =~ $no;
45 my $dir = $File::Find::dir;
46 $dir =~ s,./,,;
47 return if exists $ext{$dir};
48 return unless -f "$ext/$dir/Makefile.PL";
49 if ($dir =~ /$name$/i)
50 {
51 if (-f "$ext/$dir/$name.xs")
52 {
53 $ext{$dir} = 'dynamic';
54 }
55 else
56 {
57 $ext{$dir} = 'nonxs';
58 }
59 }
60 }
61}
62
631;