5800750e525c650164093c261f46934e00defb62
[p5sagit/p5-mst-13.2.git] / win32 / buildext.pl
1 use File::Basename;
2 use Cwd;
3 use FindExt;
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;
12 $make .= " ".shift while $ARGV[0]=~/^-/;
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 FindExt::scan_ext($ext);
19
20 my @ext = FindExt::extensions();
21
22 foreach my $dir (sort @ext)
23  {
24   if (chdir("$ext\\$dir"))
25    {
26     my $mmod = -M 'Makefile';
27     if (!(-f 'Makefile') || $mmod > $dmod)
28      {
29       print "\nRunning Makefile.PL in $dir\n";
30       my $code = system($perl,"-I$here\\..\lib",'Makefile.PL','INSTALLDIRS=perl');
31       warn "$code from $dir's Makefile.PL" if $code;
32       $mmod = -M 'Makefile';
33       if ($mmod > $dmod)
34        {
35         warn "Makefile $mmod > $dmod ($dep)\n";
36        }
37      }  
38     print "\nMaking $dir\n";
39     system($make);
40     chdir($here) || die "Cannot cd to $here:$!";
41    }
42   else
43    {
44     warn "Cannot cd to $ext\\$dir:$!";
45    }
46  }
47