This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
save a dTHX
[perl5.git] / win32 / FindExt.pm
CommitLineData
8e232993
NIS
1package FindExt;
2use strict;
3use File::Find;
4use File::Basename;
5use Cwd;
6
7my $no = join('|',qw(DynaLoader GDBM_File ODBM_File NDBM_File DB_File Syslog Sysv));
8$no = qr/^(?:$no)$/i;
9
10my %ext;
11my $ext;
12sub 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
23sub dynamic_extensions
24{
25 return grep $ext{$_} eq 'dynamic',keys %ext;
26}
27
28sub noxs_extensions
29{
6b29183e 30 return grep $ext{$_} eq 'nonxs',keys %ext;
8e232993
NIS
31}
32
33sub extensions
34{
35 return keys %ext;
36}
37
38sub find_ext
39{
6b29183e 40 if (/^(.*)\.pm$/i || /^(.*)_pm\.PL$/i || /^(.*)\.xs$/i)
8e232993
NIS
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
621;