Re: [ID 20020416.001] 'close' does not report failure when buffer flush fails
[p5sagit/p5-mst-13.2.git] / win32 / buildext.pl
1 =head1 NAME
2
3 buildext.pl - build extensions
4
5 =head1 SYNOPSIS
6
7     buildext.pl make [-make_opts] dep directory [target]
8
9 E.g.
10
11     buildext.pl nmake -nologo perldll.def ..\ext
12
13     buildext.pl nmake -nologo perldll.def ..\ext clean
14
15     buildext.pl dmake perldll.def ..\ext
16
17     buildext.pl dmake perldll.def ..\ext clean
18
19 =cut
20
21 use File::Basename;
22 use Cwd;
23 use FindExt;
24 my $here = getcwd();
25 my $perl = $^X;
26 $here =~ s,/,\\,g;
27 if ($perl =~ m#^\.\.#)
28  {
29   $perl = "$here\\$perl";
30  }
31 my $make = shift;
32 $make .= " ".shift while $ARGV[0]=~/^-/;
33 my $dep  = shift;
34 my $dmod = -M $dep;
35 my $dir  = shift;
36 chdir($dir) || die "Cannot cd to $dir\n";
37 my $targ  = shift;
38 (my $ext = getcwd()) =~ s,/,\\,g;
39 FindExt::scan_ext($ext);
40
41 my @ext = FindExt::extensions();
42
43 foreach my $dir (sort @ext)
44  {
45   if (chdir("$ext\\$dir"))
46    {
47     my $mmod = -M 'Makefile';
48     if (!(-f 'Makefile') || $mmod > $dmod)
49      {
50       print "\nRunning Makefile.PL in $dir\n";
51       my @perl = ($perl, "-I$here\\..\\lib", 'Makefile.PL',
52                   'INSTALLDIRS=perl', 'PERL_CORE=1');
53       print join(' ', @perl), "\n";
54       my $code = system(@perl);
55       warn "$code from $dir's Makefile.PL" if $code;
56       $mmod = -M 'Makefile';
57       if ($mmod > $dmod)
58        {
59         warn "Makefile $mmod > $dmod ($dep)\n";
60        }
61      }  
62     if ($targ)
63      {
64       print "Making $targ in $dir\n$make $targ\n";
65       system("$make $targ");
66      }
67     else
68      {
69       print "Making $dir\n$make\n";
70       system($make);
71      }
72     chdir($here) || die "Cannot cd to $here:$!";
73    }
74   else
75    {
76     warn "Cannot cd to $ext\\$dir:$!";
77    }
78  }
79