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