Commit | Line | Data |
17af6fb0 |
1 | use File::Find; |
2 | use File::Basename; |
3 | use Cwd; |
4 | my $here = getcwd(); |
5 | my $perl = $^X; |
6 | $here =~ s,/,\\,g; |
7 | if ($perl =~ m#^\.\.#) |
8 | { |
9 | $perl = "$here\\$perl"; |
10 | } |
11 | my $make = shift; |
f76dcffd |
12 | $make .= " ".shift while $ARGV[0]=~/^-/; |
17af6fb0 |
13 | my $dep = shift; |
14 | my $dmod = -M $dep; |
15 | my $dir = shift; |
16 | chdir($dir) || die "Cannot cd to $dir\n"; |
17 | (my $ext = getcwd()) =~ s,/,\\,g; |
18 | my $no = join('|',qw(DynaLoader GDBM_File ODBM_File NDBM_File DB_File Syslog Sysv)); |
19 | $no = qr/^(?:$no)$/i; |
20 | my %ext; |
21 | find(\&find_xs,'.'); |
22 | |
23 | foreach my $dir (sort keys %ext) |
24 | { |
25 | if (chdir("$ext\\$dir")) |
26 | { |
27 | my $mmod = -M 'Makefile'; |
28 | if (!(-f 'Makefile') || $mmod > $dmod) |
29 | { |
0026721a |
30 | print "\nRunning Makefile.PL in $dir\n"; |
17af6fb0 |
31 | my $code = system($perl,"-I$here\\..\lib",'Makefile.PL','INSTALLDIRS=perl'); |
32 | warn "$code from $dir's Makefile.PL" if $code; |
33 | $mmod = -M 'Makefile'; |
34 | if ($mmod > $dmod) |
35 | { |
36 | warn "Makefile $mmod > $dmod ($dep)\n"; |
37 | } |
38 | } |
39 | print "\nMaking $dir\n"; |
40 | system($make); |
41 | chdir($here) || die "Cannot cd to $here:$!"; |
42 | } |
43 | else |
44 | { |
45 | warn "Cannot cd to $ext\\$dir:$!"; |
46 | } |
47 | } |
48 | |
49 | sub find_xs |
50 | { |
0026721a |
51 | if (/^(.*)\.pm$/i || /^(.*)_pm.PL$/i) |
17af6fb0 |
52 | { |
53 | my $name = $1; |
54 | return if $name =~ $no; |
55 | my $dir = $File::Find::dir; |
56 | $dir =~ s,./,,; |
57 | return if exists $ext{$dir}; |
58 | return unless -f "$ext/$dir/Makefile.PL"; |
59 | if ($dir =~ /$name$/i) |
60 | { |
61 | $ext{$dir} = $name; |
62 | } |
63 | } |
f76dcffd |
64 | } |